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.
- 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.
- Python 3.9+
- Docker (optional, for containerized deployment)
- PostgreSQL
-
Clone the repository:
git clone https://github.com/Dimakoua/fastapi_backend_template.git cd fastapi_backend_template -
Create a virtual environment:
python -m venv .venv
-
Activate the virtual environment:
-
On Linux/macOS:
source .venv/bin/activate -
On Windows (PowerShell):
.venv\Scripts\Activate.ps1
-
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Rename
.envrc.exampleto.envrcand adjust the configurations as needed. -
Start the application:
uvicorn main:app --reload
The API will be accessible at
http://127.0.0.1:8000. -
Access the Docs:
The API will be accessible at
http://127.0.0.1:8000/docs.
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
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See LICENSE for details.