141 lines
4.3 KiB
Markdown
141 lines
4.3 KiB
Markdown
# 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
|
|
|
|
1. Clone the repository:
|
|
```
|
|
git clone <repository-url>
|
|
cd logisticsmanagementsystem
|
|
```
|
|
|
|
2. Create a virtual environment (optional but recommended):
|
|
```
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows, use: venv\Scripts\activate
|
|
```
|
|
|
|
3. Install dependencies:
|
|
```
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
4. Run database migrations:
|
|
```
|
|
alembic upgrade head
|
|
```
|
|
|
|
5. 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 token
|
|
- `POST /api/v1/auth/register`: Register a new user
|
|
|
|
- **Users**:
|
|
- `GET /api/v1/users/me`: Get current user information
|
|
- `PUT /api/v1/users/me`: Update current user information
|
|
|
|
- **Products**:
|
|
- `GET /api/v1/products`: List all products
|
|
- `POST /api/v1/products`: Create a new product
|
|
- `GET /api/v1/products/{id}`: Get product details
|
|
|
|
- **Warehouses**:
|
|
- `GET /api/v1/warehouses`: List all warehouses
|
|
- `POST /api/v1/warehouses`: Create a new warehouse
|
|
- `GET /api/v1/warehouses/{id}`: Get warehouse details
|
|
|
|
- **Inventory**:
|
|
- `GET /api/v1/inventory`: List all inventory items
|
|
- `GET /api/v1/inventory/low-stock`: Get items with low stock levels
|
|
- `POST /api/v1/inventory`: Create a new inventory item
|
|
|
|
- **Orders**:
|
|
- `GET /api/v1/orders`: List all orders
|
|
- `POST /api/v1/orders`: Create a new order
|
|
- `GET /api/v1/orders/{id}`: Get order details
|
|
|
|
- **Shipments**:
|
|
- `GET /api/v1/shipments`: List all shipments
|
|
- `POST /api/v1/shipments`: Create a new shipment
|
|
- `GET /api/v1/shipments/{id}`: Get shipment details
|
|
- `GET /api/v1/shipments/tracking/{tracking_number}`: Track a shipment
|
|
|
|
- **Health**:
|
|
- `GET /health`: Check API and database health
|
|
- `GET /api/v1/health`: Detailed API health check
|
|
|
|
## Running in Production
|
|
|
|
For production deployment:
|
|
|
|
1. Set up a proper database (SQLite is for development only)
|
|
2. Change the `SECRET_KEY` to a secure random string
|
|
3. Configure CORS settings for your frontend domain
|
|
4. 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. |