This project is a collection of microservices for managing Products
, Orders
, Discounts
, and Users
. Each service is built using FastAPI, with PostgreSQL as the primary database. The Discount Service uses MongoDB
. The project also includes support for managing generic pictures associated with different entities.
-
Service Communication
In this microservices architecture, services communicate with each other through APIs when required.
-
Async-Oriented Architecture
This project uses asynchronous programming to handle tasks, including in some areas, concurrency has been applied to further optimize performance.
The main purpose of this proejct is to explore the potentials of FastAPI in building high scale applications
Product Management
: CRUD operations for products, including image upload (handled via sql queries).Order Management
: Create and manage orders, track order status (handled via sql queries).Discount Management
: Apply and manage discounts on products or orders.User Management
: User registration, authentication with scope permissions through application.Generic Picture Support
: Upload and associate images with various entities.
To quickly get started with Docker, follow these steps:
docker-compose up
This command will start all the services defined in docker-compose.yml file, including:
db
: PostgreSQL databaseweb
: Your FastAPI applicationpgadmin
: PgAdmin for managing the PostgreSQL databaseprometheus
: Prometheus for monitoringgrafana
: Grafana for visualization
You can access your FastAPI application at http://localhost:8000
PgAdmin at http://localhost:5050
Grafana at http://localhost:3000
and Prometheus at http://localhost:9090
docker-compose down
Running Locally with Poetry
(Because we're using PostgreSQL
docker image as a database we have to first start the db)
- Start the PostgreSQL database service using Docker Compose:
./scripts/run_migration.sh
This script starts the PostgreSQL Docker container and then performs database migrations to prepare the model for use.
- Install the dependencies using Poetry:
poetry install
- Run the FastAPI application using Uvicorn:
poetry run uvicorn main:app --reload
FastAPI application will be available at http://localhost:8000.
Feel free to open a PR; I'd appreciate that!