Skip to content

Latest commit

 

History

History
104 lines (72 loc) · 3.35 KB

project-structure.md

File metadata and controls

104 lines (72 loc) · 3.35 KB

FastAPI Archetype Structure

This document provides an overview of the structure of the FastAPI archetype, detailing the purpose of each folder and file.

The archetype consist of a FastAPI application with a modular structure, following Domain Driven Design (DDD) principles, and best practices for Docker, development, testing, and deployment.

Folders

docker

Contains Docker-related configuration files.

  • Dockerfile: Configures the Docker container for the FastAPI application. It uses a multi-stage build to optimize the image size.
  • docker-compose.yml: Defines services, networks, and volumes for Docker containers.
  • logs: Directory to store application logs.
    • app.log: Log file for the application.

docs

Contains documentation files.

  • alembic.md: Documentation related to Alembic, a database migration tool.
  • poetry.md: Documentation related to Poetry, a dependency management tool.
  • project-structure.md: Documentation related to the project structure.
  • deployment.md: Documentation related to deployment.

logs

Directory to store application logs.

  • app.log: Log file for the application.

src

Contains the source code of the FastAPI application.

controller

Contains controllers for handling HTTP requests.

  • api: Module for API-related functionality.
    • endpoints: Endpoints for different resources.
      • base.py: Base endpoint definitions and common utilities.
      • customer.py: Endpoint definitions related to customers (example).
    • schemas: Pydantic schemas for request/response validation.
      • customer.py: Customer-related schemas (example).
      • error_message.py: Error message schemas.
  • errors: Error handling utilities.
    • error_responses.py: Definitions for error responses.
    • exception_manager.py: Exception handling utilities.
    • exception_mapper.py: Mapping of exceptions to HTTP responses.
    • exceptions.py: Custom exception definitions.
  • utils: Utility functions.
    • pagination.py: Pagination utilities.

core

Contains core components of the application.

  • config.py: Configuration settings.
  • logger.py: Logging configuration.

domain

Contains domain-specific logic.

repository

Handles database operations.

  • create_db.py: Script to create the database.
  • crud: CRUD operations.
    • address.py: CRUD operations related to addresses (example).
    • base.py: Base CRUD operations.
    • customer.py: CRUD operations related to customers (example).
  • exceptions.py: Custom repository exceptions.
  • models: Database models.
    • base.py: Base database model.
    • customer.py: Customer database model (example).
  • session.py: Database session management.

service

Contains business logic.

  • customer: Customer service module (example).
    • mapper.py: Mapping functions.
    • service.py: Customer service implementation.
  • exceptions.py: Custom service exceptions.

tests

Contains unit tests.

Files

  • LICENSE: License file for the project.
  • README.md: Project README file.
  • poetry.lock: Lock file generated by Poetry for dependency management.
  • poetry.toml: Poetry configuration file.
  • pylintrc: Configuration file for Pylint.
  • pyproject.toml: Project configuration file for tools like Poetry and Flake8.
  • requirements-dev.txt: Development dependencies.
  • requirements.txt: Main dependencies.