This is the backend service for the Logistics Application, built with FastAPI, PostgreSQL, and Docker. It handles inventory management, order processing, and strict concurrency control.
- Docker Desktop (Must be installed and running)
- Git
Run this command to build and start the database and API containers.
docker-compose up --buildThe API will start on http://localhost:3000 check docker-compose.yml.
Once the server is running (in a new terminal), set up the database tables:
docker-compose exec web alembic upgrade headTo verify the application logic and locking mechanisms:
docker-compose exec web pytestTo stop and remove the containers:
docker-compose downOnce running, you can access the interactive API docs here:
Swagger UI: http://localhost:3000/docs
Concurrency Handling: To prevent race conditions (overselling stock), this project uses Pessimistic Locking (SELECT ... FOR UPDATE) in SQLAlchemy. This ensures that when an order is being processed, the specific product row is locked until the transaction commits, preventing other parallel requests from modifying the stock simultaneously.
Repo of logistics-frontend: https://github.com/manojitht/logistics-frontend