Skip to content

The repository follows best practices for organizing a backend project, incorporating key components such as routers, models, schemas, and services to maintain scalability, maintainability, and ease of testing.

Notifications You must be signed in to change notification settings

umayyayla/fastapi-backend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Backend Architecture

Welcome to the FastAPI Backend Architecture repository! This project showcases a structured and scalable backend architecture built using FastAPI, a modern web framework for building APIs with Python 3.10.

The repository follows best practices for organizing a backend project, incorporating key components such as routers, models, schemas, and services to maintain scalability, maintainability, and ease of testing.

📑 Documentation

All the project details, including architectural decisions, folder structures, setup instructions, and usage guidelines, are comprehensively documented in the Project Documentation (PDF). Please refer to this file for in-depth information.

Key Highlights of the Architecture:

  • Modular Design: The project is structured in a way that separates concerns across routers, models, schemas, and core functionalities, ensuring modularity and flexibility.
  • Database Integration: The architecture supports easy integration with databases using SQLAlchemy or similar ORMs.
  • Cython Optimizations: Certain parts of the codebase are optimized using Cython for performance improvement (optional).
  • Dependency Injection: Designed to support FastAPI’s dependency injection for services, ensuring clean, testable, and extendable code.
  • Async Capabilities: Fully async-enabled, allowing for high concurrency and performance.

🚀 Getting Started

To get started with this project, follow the steps below:

Prerequisites

Ensure you have the following installed:

  • Python 3.10+
  • Docker (optional for containerization)
  • PostgreSQL or another relational database (if applicable)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/fastapi-backend-architecture.git
    cd fastapi-backend-architecture
  2. Set up a virtual environment and install dependencies:

    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
  3. Run the FastAPI application:

    uvicorn api.main:app --reload
  4. Access the application:

Using Docker

To run the project using Docker:

  1. Build the Docker image:

    docker build -t fastapi-backend .
  2. Run the Docker container:

    docker run -p 8080:8080 fastapi-backend
  3. The app will be available at: http://localhost:8080

🏗️ Project Structure

Here’s an overview of the folder structure:

fastapi-backend/
├── api/
│   ├── aws/                   # AWS-related files (optional)
│   ├── core/                  # Core configurations, middleware, and database
│   ├── migrations/            # Database migration scripts (Alembic)
│   ├── models/                # SQLAlchemy models and database schemas
│   ├── routers/               # API route handlers/endpoints
│   ├── schemas/               # Pydantic models for request/response validation
│   ├── utils/                 # Utility functions
│   ├── logging_config.py      # Logging configuration
│   └── main.py                # FastAPI application entry point
├── tests/                     # Unit and integration tests
├── docs/                      # Documentation files (PDF, guides)
├── requirements.txt           # Python dependencies
├── Dockerfile                 # Docker configuration for containerization
├── README.md                  # Project overview and instructions
└── setup.py                   # Python package configuration

🧪 Running Tests

To run tests, use:

pytest tests/
Make sure you have your testing environment set up. You can use tools like pytest and coverage to ensure code quality.

🛠️ Deployment

For deployment, you can use services like:

  • Docker: Containerize your app and deploy it on any platform.
  • Heroku: Easily deploy your FastAPI app on Heroku using the Dockerfile.
  • AWS: Use AWS EC2 or other AWS services to deploy your backend.

Please refer to the PDF Documentation for more details about deployment strategies and configurations.

📂 Additional Resources

About

The repository follows best practices for organizing a backend project, incorporating key components such as routers, models, schemas, and services to maintain scalability, maintainability, and ease of testing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 93.1%
  • Dockerfile 4.6%
  • Mako 2.3%