This project is a simple REST API built using FastAPI and docker. It provides endpoints for managing customers and invoices.
- CRUD operations for customers and invoices.
- Containerized FastAPI application using Docker.
- Fake in-memory database storage using Python dictionaries.
- Defined Pydantic models for validation and serialization.
-
Clone the repository:
git clone Working-with-fastAPI cd Working-with-fastAPI -
Build the Docker image:
docker build -t fastapi_image .
-
Run the container:
docker run -d -p 8000:80 fastapi_image
- Visit
http://localhost:8000in your browser to see the API in action.
- visit
http://127.0.0.1:8000/docs#/to see the requests built.
Here's a quick overview of the available endpoints:
GET /: Base URL which returns a welcome message.POST /customer: Create a new customer.GET /customer/{customer_id}: Fetch details of a specific customer by their ID.POST /customer/{customer_id}/invoice: Create a new invoice for a customer.GET /customer/{customer_id}/invoice: Retrieve all invoices for a specific customer.GET /invoice/{invoice_no}: Fetch details of a specific invoice.GET /invoice/{invoice_no}/{stockcode}/: Fetch a specific stock code on the invoice.POST /invoice/{invoice_no}/{stockcode}/: Add a stock code to the invoice.