Skip to content

abdulghaffarnba/inventory-order-mgt-services

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logistics Inventory & Order Management Service

Production-ready Inventory & Order Management API built using:

  • FastAPI
  • PostgreSQL
  • SQLAlchemy
  • Alembic
  • Docker

This service manages Products and Orders with transactional stock handling and concurrency safety.


Prerequisites

Ensure the following are installed:

  • Python 3.10+
  • PostgreSQL (if running locally without Docker)
  • Docker
  • Docker Compose

Running the Application (Traditional Setup)

1. Clone the Repository

git clone https://github.com/abdulghaffarnba/inventory-order-mgt-services.git
cd inventory-order-mgt-services

2. Create Virtual Environment (Recommended)

python -m venv venv

Activate the Environment

macOS / Linux:

source venv/bin/activate

Windows:

venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Create Environment File

Create a .env file in the root directory.

ENVIRONMENT=local
LOG_LEVEL=INFO

PSQL_HOST_SERVER=localhost
PSQL_USER=postgres
PSQL_PASSWORD=postgres
PSQL_DATABASE=logistics
PSQL_PORT=5432

Ensure the PostgreSQL database logistics exists if running locally.

5. Run Database Migrations

alembic upgrade head

6. Start the Application

uvicorn application:application --reload --port 8000

7. Verify Application

curl http://localhost:8000/health

Expected response:

{
  "message":"local API is working!"
}

Running with Docker (Recommended)

Docker setup will:

  • Start PostgreSQL
  • Create the database
  • Run Alembic migrations
  • Start the API

1. Build and Start Containers

docker compose up --build

2. Access the Application

Base URL:

http://localhost:8000

Health check:

curl http://localhost:8000/health

3. Stop Containers

docker compose down

To reset the database:

docker compose down -v

Running Tests

pytest

API Documentation

Swagger UI:

http://localhost:8000/docs

ReDoc:

http://localhost:8000/redoc

OpenAPI JSON:

http://localhost:8000/openapi.json

Production Run (Gunicorn)

gunicorn -k uvicorn.workers.UvicornWorker application:application

Recommended for production:

  • Managed PostgreSQL
  • Secure secret management
  • Container orchestration (ECS/Kubernetes)
  • Auth

Health Endpoint

GET /health

Used for monitoring and readiness checks.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors