
- Created customer, driver, and order models with SQLAlchemy - Implemented CRUD API endpoints for all entities - Set up SQLite database with Alembic migrations - Added health check and base URL endpoints - Configured CORS middleware for all origins - Updated README with comprehensive documentation
Delivery Business API
A simple FastAPI backend for managing a delivery business with customers, drivers, and orders.
Features
- Customer Management: Create, read, update, and delete customers
- Driver Management: Manage drivers with availability and ratings
- Order Management: Handle delivery orders with status tracking
- SQLite Database: Lightweight database with Alembic migrations
- Health Check: Monitor service health at
/health
- Interactive API Docs: Available at
/docs
and/redoc
Setup and Installation
-
Install dependencies:
pip install -r requirements.txt
-
Run database migrations:
alembic upgrade head
-
Start the application:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
The API will be available at http://localhost:8000
API Endpoints
Base
GET /
- Service informationGET /health
- Health checkGET /docs
- Interactive API documentationGET /openapi.json
- OpenAPI schema
Customers
POST /api/v1/customers
- Create customerGET /api/v1/customers
- List customersGET /api/v1/customers/{id}
- Get customer by IDPUT /api/v1/customers/{id}
- Update customerDELETE /api/v1/customers/{id}
- Delete customer
Drivers
POST /api/v1/drivers
- Create driverGET /api/v1/drivers
- List drivers (supportsavailable_only
filter)GET /api/v1/drivers/{id}
- Get driver by IDPUT /api/v1/drivers/{id}
- Update driverDELETE /api/v1/drivers/{id}
- Delete driver
Orders
POST /api/v1/orders
- Create orderGET /api/v1/orders
- List orders (supportsstatus
filter)GET /api/v1/orders/{id}
- Get order by IDPUT /api/v1/orders/{id}
- Update orderPATCH /api/v1/orders/{id}/assign-driver/{driver_id}
- Assign driver to orderPATCH /api/v1/orders/{id}/status
- Update order statusDELETE /api/v1/orders/{id}
- Delete order
Database
The application uses SQLite database located at /app/storage/db/db.sqlite
. Database migrations are managed using Alembic.
Order Status Flow
Orders progress through the following statuses:
PENDING
- Order created, awaiting confirmationCONFIRMED
- Order confirmed, driver assignedPICKED_UP
- Package picked up by driverIN_TRANSIT
- Package in transitDELIVERED
- Package delivered successfullyCANCELLED
- Order cancelled
Development
The application includes:
- CORS middleware configured to allow all origins
- Automatic API documentation generation
- Database relationship management
- Error handling and validation
Description
Languages
Python
97.4%
Mako
2.6%