Skip to content

moeez4316/fastapi-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Microservices

A production-ready microservices architecture built with FastAPI, PostgreSQL, and Docker.

Architecture

Services

Service Port Description
User Service 8001 User registration and management
Product Service 8002 Product catalog with CRUD
Order Service 8003 Order placement with stock management

Tech Stack

  • Framework — FastAPI
  • Database — PostgreSQL 15
  • ORM — SQLAlchemy 2.0 async
  • Driver — psycopg3
  • Gateway — Nginx
  • Containerization — Docker + Docker Compose
  • Package Manager — uv

Running the Project

Prerequisites

  • Docker Desktop
  • Git

Setup

  1. Clone the repository
git clone <your-repo-url>
cd fastapi-microservices
  1. Create environment file
cp .env.example .env
  1. Start all services
docker-compose up --build

API Access

All APIs are accessible through Nginx at http://localhost:

Endpoint Service
/api/users/ User Service
/api/products/ Product Service
/api/orders/ Order Service

Swagger Docs (Development)

Service URL
User Service http://localhost:8001/docs
Product Service http://localhost:8002/docs
Order Service http://localhost:8003/docs

Development Workflow

Run only databases in Docker, services locally with hot reload:

# Terminal 1 - databases only
docker-compose up users-db products-db orders-db

# Terminal 2 - user service
cd user_service && uv run uvicorn main:app --reload --port 8001

# Terminal 3 - product service  
cd product_service && uv run uvicorn main:app --reload --port 8002

# Terminal 4 - order service
cd order_service && uv run uvicorn main:app --reload --port 8003

About

Production-ready microservices backend built with FastAPI, PostgreSQL, and Docker. Features three independent services with async SQLAlchemy, Nginx gateway, and inter-service communication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors