Skip to content

signorinileandro/fastapi-billing-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧾 FastAPI Billing API

REST API for billing management built with FastAPI, PostgreSQL, Docker Compose, and SQLAlchemy. Allows client registration and invoice creation through clear, automatically documented endpoints.

FastAPI Badge PostgreSQL Badge Docker Badge Python Badge


📌 Features

  • ✅ Create and list clients
  • ✅ Create and list invoices
  • ✅ SQLAlchemy ORM integration
  • ✅ Pydantic validation
  • ✅ Automatic Swagger/ReDoc documentation
  • ✅ Fully containerized with Docker
  • ✅ Comprehensive testing with Pytest
  • ✅ Database connection waiting with Dockerize

🏗️ Project Structure

fastapi-billing-api/
├── app/
│   ├── __init__.py
│   ├── crud.py          # Database operations
│   ├── database.py      # Database configuration
│   ├── main.py          # FastAPI application
│   ├── models.py        # SQLAlchemy models
│   └── schemas.py       # Pydantic schemas
├── tests/
│   └── test_api.py      # API tests
├── Dockerfile           # Container configuration
├── docker-compose.yml   # Multi-service setup
├── requirements.txt     # Python dependencies
└── README.md

🚀 Getting Started

Prerequisites

  • Docker and Docker Compose
  • Git

1. Clone the Repository

git clone https://github.com/yourusername/fastapi-billing-api.git
cd fastapi-billing-api

2. Start the Application

docker compose up --build

The API will be available at:

3. Stop the Application

docker compose down

📬 API Endpoints

🔸 Clients

➕ Create Client

POST /clients/
Content-Type: application/json

{
  "name": "John Doe",
  "email": "john@example.com"
}

📋 List Clients

GET /clients/

🔸 Invoices

➕ Create Invoice

POST /invoices/
Content-Type: application/json

{
  "amount": 1250.50,
  "client_id": 1
}

📋 List Invoices

GET /invoices/

🧪 Running Tests

Make sure the database is running:

docker compose up -d db

Run the test suite:

docker compose run --rm web pytest

Run tests with coverage:

docker compose run --rm web pytest --cov=app

🛠️ Development

Environment Variables

The application uses the following environment variables:

  • DATABASE_URL: PostgreSQL connection string (automatically set in Docker Compose)

Local Development

For local development with hot reload:

docker compose up

🔧 Technologies Used


About

Billing API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors