Skip to content

FastAPI Backend Template is a boilerplate for building scalable and efficient FastAPI applications with async PostgreSQL, Docker support, and a modular structure.

License

Notifications You must be signed in to change notification settings

Dimakoua/fastapi_backend_template

Repository files navigation

FastAPI Backend Template

FastAPI Python License

Overview

Welcome to the FastAPI Backend Template! This project serves as a boilerplate for building scalable and efficient backend applications using FastAPI, a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python-type hints.

Features

  • FastAPI: Leverages FastAPI for rapid development and high performance.
  • Asynchronous PostgreSQL: Utilizes asynchronous SQLAlchemy with AsyncPG for non-blocking database operations.
  • Modular Structure: Organized codebase following best practices for scalability and maintainability.

Getting Started

Prerequisites

  • Python 3.9+
  • Docker (optional, for containerized deployment)
  • PostgreSQL

Installation

  1. Clone the repository:

    git clone https://github.com/Dimakoua/fastapi_backend_template.git
    cd fastapi_backend_template
  2. Create a virtual environment:

    python -m venv .venv
  3. Activate the virtual environment:

    • On Linux/macOS:

      source .venv/bin/activate
    • On Windows (PowerShell):

      .venv\Scripts\Activate.ps1
  4. Install dependencies:

    pip install -r requirements.txt
  5. Set up environment variables:

    Rename .envrc.example to .envrc and adjust the configurations as needed.

  6. Start the application:

    uvicorn main:app --reload

    The API will be accessible at http://127.0.0.1:8000.

  7. Access the Docs:

    The API will be accessible at http://127.0.0.1:8000/docs.

Project Structure

fastapi_backend_template/
├── application/
│   └── register_user/
├── controllers/
│   └── auth_controller/
├── middlewares/
├── models/
│   └── user/
├── repositories/
│   └── user_repository/
├── shared/
├── static/
├── .devcontainer/
├── .github/
│   └── workflows/
├── .envrc.example
├── .gitignore
├── .pylintrc
├── LICENSE
├── config.py
├── conftest.py
├── create_db.py
├── database.py
├── facade.py
├── main.py
├── readme.md
└── requirements.txt

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License. See LICENSE for details.

About

FastAPI Backend Template is a boilerplate for building scalable and efficient FastAPI applications with async PostgreSQL, Docker support, and a modular structure.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published