Why we built fastapi-base-service

I want this repository to be able to create a server that can handle HTTP requests, WebSocket requests, and gRPC in less than one day. This codebase should be available for immediate use whenever I have ideas related to AI or GPT. I have a funny example, check it out

Welcome to Python-Base-Service

A clear and fast Python codebase for building services that handle HTTP, SSE, and WS requests. In the fastapi-base-service, I have developed the following features, with ongoing features in the pipeline using the FastAPI framework. This framework provides robust features that enable developers to create web/apps quickly, within 1-2 days:

  • Support for managing logs (Format, Output, Level).
  • Support for database operations (RDBMS like Postgres, MongoDB).
  • Support for Authentication with JWT (Sample Payload, Create, GetClaims).
  • Support for Redis operations (Connect, Get, Set, Invalidate).
  • Support for AWS S3 operations (Connect, Get, Upload).
  • Support for Elasticsearch (Connect, Insert, Search).
  • Support for middleware (Rate Limit, Blocking).
  • Easy integration with HTTP request handling (Status, Response, graceful shutdown).
  • Support common utility features with datetime, async, sync, loop.
  • Helpful documentation for learning Python clearly.
  • Support for GRPC.
  • Support for WebSocket.

Demo of a Basic System

Context : I have a wrapper chat GPT backend, give user request and send to LLM to get answer then stream for user. I will use this base service to built 2 main APIs : User can chat with LLM - SSE, User search message in chat history, some APIs users...

  • Support standard authentication functions (Sign In, Sign Up, Change Password, Get Profile, Change API Key).
  • Support full-text search using Elasticsearch's API to search messages for users.
  • Support chat with LLM
  • API documentation.
  • Python and FastAPI documentation (configurations, conventions, HTTP).

Demo Architecture

Frontend add on project here > Check it out ...


This version improves readability and maintains your original format and intent.

How to run this project

# must run
Python 3.11.4
python3 -m venv venv
source venv/bin/active

# For dev
make install
make run

# for deploy


Question for myself

  1. What generator run ? async generator run ?
  2. what is block in asyncio ? bestpractice with even-loop ?
  3. Should we create connection pool like session in endpoints ?
  4. Why something openAPI docs not works ?

Docs to support about Python, Async, Project

  1. Why I not used env file
  2. Python AsyncIO, a dificult things !

I was inspired by the repository : fastapi-best-practices

Thanks for visting me, If you think this is helpful repo, give me a star :3