4.3 KiB
4.3 KiB
Logistics Management System API
A comprehensive API for managing logistics operations including warehouses, inventory, orders, shipments, and more.
Features
- User Management: Authentication, authorization, and user management
- Product Management: Create, update, and track products
- Warehouse Management: Manage multiple warehouses and their details
- Inventory Management: Track inventory levels across warehouses
- Order Management: Process customer orders from creation to delivery
- Shipment Management: Track shipments between warehouses or to customers
- Health Check: Monitor system health and database connectivity
Tech Stack
- Framework: FastAPI
- Database: SQLite with SQLAlchemy ORM
- Authentication: JWT token-based authentication
- Migration: Alembic for database migrations
- Validation: Pydantic models for request/response validation
Project Structure
├── app # Application source code
│ ├── api # API endpoint definitions
│ │ └── endpoints # API endpoints for each domain
│ ├── core # Core application code (config, security, etc.)
│ ├── db # Database-related code (session, migrations)
│ ├── models # SQLAlchemy models
│ ├── schemas # Pydantic schemas
│ └── services # Business logic services
├── migrations # Alembic migrations
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
└── requirements.txt # Python dependencies
Getting Started
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
Installation
-
Clone the repository:
git clone <repository-url> cd logisticsmanagementsystem
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows, use: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run database migrations:
alembic upgrade head
-
Start the development server:
uvicorn main:app --reload
The API will be available at http://localhost:8000
.
API Documentation
Once the server is running, you can access the interactive API documentation:
- Swagger UI:
http://localhost:8000/docs
- ReDoc:
http://localhost:8000/redoc
Key Endpoints
-
Authentication:
POST /api/v1/auth/login
: Login and obtain access tokenPOST /api/v1/auth/register
: Register a new user
-
Users:
GET /api/v1/users/me
: Get current user informationPUT /api/v1/users/me
: Update current user information
-
Products:
GET /api/v1/products
: List all productsPOST /api/v1/products
: Create a new productGET /api/v1/products/{id}
: Get product details
-
Warehouses:
GET /api/v1/warehouses
: List all warehousesPOST /api/v1/warehouses
: Create a new warehouseGET /api/v1/warehouses/{id}
: Get warehouse details
-
Inventory:
GET /api/v1/inventory
: List all inventory itemsGET /api/v1/inventory/low-stock
: Get items with low stock levelsPOST /api/v1/inventory
: Create a new inventory item
-
Orders:
GET /api/v1/orders
: List all ordersPOST /api/v1/orders
: Create a new orderGET /api/v1/orders/{id}
: Get order details
-
Shipments:
GET /api/v1/shipments
: List all shipmentsPOST /api/v1/shipments
: Create a new shipmentGET /api/v1/shipments/{id}
: Get shipment detailsGET /api/v1/shipments/tracking/{tracking_number}
: Track a shipment
-
Health:
GET /health
: Check API and database healthGET /api/v1/health
: Detailed API health check
Running in Production
For production deployment:
- Set up a proper database (SQLite is for development only)
- Change the
SECRET_KEY
to a secure random string - Configure CORS settings for your frontend domain
- Use a proper ASGI server like Uvicorn or Gunicorn
Example production start command:
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4
License
This project is licensed under the MIT License.