Skip to content

A microservices-based application built on asynchronous processing and concurrent data handling.

License

Notifications You must be signed in to change notification settings

itz-Amethyst/fastapi-whistler-microservices

Repository files navigation

FastAPI-Whistler Microservices Project

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.

Purpose:

The main purpose of this proejct is to explore the potentials of FastAPI in building high scale applications

Features

  • 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.

Built With :

FastAPI SQLAlchemy Asyncpg Alembic pymongo Beanie structlog tenacity aiohttp PyJWT emails aiosmtplib APScheduler prometheus-fastapi-instrumentator aiofiles


You can use my .env as an example but be aware to change that later


  • Note: After running the project you can authenticate with User: admin , Password: test credentials in order to have access to apis

Running with Docker

To quickly get started with Docker, follow these steps:

Start the services using Docker Compose:

docker-compose up

This command will start all the services defined in docker-compose.yml file, including:

  • db: PostgreSQL database
  • web: Your FastAPI application
  • pgadmin: PgAdmin for managing the PostgreSQL database
  • prometheus: Prometheus for monitoring
  • grafana: 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

Stop the services:

docker-compose down

Running localy:

Running Locally with Poetry

(Because we're using PostgreSQL docker image as a database we have to first start the db)

  1. 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.

  1. Install the dependencies using Poetry:
poetry install
  1. Run the FastAPI application using Uvicorn:
poetry run uvicorn main:app --reload

FastAPI application will be available at http://localhost:8000.

Contribution

Feel free to open a PR; I'd appreciate that!

About

A microservices-based application built on asynchronous processing and concurrent data handling.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages