Metadata-Version: 2.4
Name: create-modern-fastapi
Version: 0.4.3
Summary: A CLI tool to create a FastAPI project.
Requires-Python: >=3.12
Requires-Dist: click>=8.3.1
Requires-Dist: jinja2>=3.1.6
Requires-Dist: pydantic>=2.12.5
Requires-Dist: questionary>=2.1.1
Description-Content-Type: text/markdown


# Clean Architecture Template for FastAPI Applications

![SQLModel](https://img.shields.io/badge/version-0.4.0-black)
![SQLModel](https://img.shields.io/badge/ORM-SQLModel-blue)

This template provides a clean and well-structured foundation for building FastAPI applications using Clean Architecture principles. It uses **SQLModel** as the ORM and **PostgreSQL** as the database. It clearly separates business logic, use cases, infrastructure, and the API layer to ensure maintainability, testability, and scalability. With an explicit project structure and built-in testing strategy, it serves as a solid starting point for developing professional and production-ready backends.

## Requirements
- Python 3.10 or higher
- PostgreSQL 
- [uv](https://docs.astral.sh/uv/getting-started/installation/) for managing virtual environments and dependencies
- [justfile](https://just.systems/man/en/packages.html) for command runner

## Todo

| Description | Status |
|---|---|
| Setup project structure | ✅ |
| Create database models and implement database connection | ✅ |
| Test with real database (e.g., PostgreSQL, MySQL) | ✅ |
| Setup migration (alembic) | ✅ |
| Test on real project | ☕ |
| Implement end-to-end tests setup | ⛔ |
| Implement integration tests setup | ⛔ |

## Setup

1. Create project with 
   ```bash
   uvx create-modern-fastapi
   ```
3. Navigate to the project directory:
4. Install dependencies:
   ```bash
   uv sync
   ```  
5. Run the application:
   ```bash
   just start
    ```

## Flow

```mermaid
flowchart LR
    ENTRY[Entry Point]
    PRESENTATION[Presentation]
    APPLICATION[Application]
    INFRASTRUCTURE[Infrastructure]
    DOMAIN[Domain]

    ENTRY --> PRESENTATION
    PRESENTATION --> APPLICATION
    PRESENTATION --> INFRASTRUCTURE
    PRESENTATION --> DOMAIN
    APPLICATION --> DOMAIN
    INFRASTRUCTURE --> DOMAIN
```

## Project Structure

In progress...

<!-- 
```
.
├── justfile
├── main.py -------------- --- Entry point of the application
├── pyproject.toml ------- --- Project configuration and dependencies
├── README.md ------------ --- This file
├── src/
│   ├── application/
│   │   ├── interface/ ---- --- Contains interfaces for repositories, services, etc.
│   │   └── use_case/ ----- --- Contains application use cases (1 file per use case)
│   ├── config.py
│   ├── domain/
│   │   ├── entities/ ----- --- Contains domain entities
│   │   ├── exceptions/ --- --- Contains custom exceptions for the domain
│   │   └── value_objects/  --- Contains value objects for the domain
│   ├── infrastructure/ --- --- Contains implementations of interfaces defined in the application layer
│   │   └── database/ ----- --- Contains database connection and models
│   │   │   ├── database.py --- Contains database connection and session management
│   │   │   ├── interface.py -- Contains database interface definitions
│   │   │   ├── models/ --- --- Contains database models 
│   │   │   └── seed/ ----- --- Contains database seeding scripts
│   └── presentation/ ----- --- Contains FastAPI application and API routes
│       ├── app.py -------- --- Contains FastAPI application setup
│       ├── core/ --------- --- Contains core components like error_handling, middleware, etc.
│       ├── deps/ --------- --- Contains dependency injection components
│       ├── routes/ ------- --- Contains API route definitions
│       └── schemas/ ------ --- Contains Pydantic schemas for request and response validation
├── tests/ 
│   ├── clean/ ------------ --- Contains tests for clean architecture dependency rules
│   ├── conftest.py ------- --- Contains fixtures for tests
│   ├── e2e/ -------------- --- Contains end-to-end tests (in progress)
│   ├── integration/ ------ --- Contains integration tests (in progress)
│   ├── unit/ ------------- --- Contains unit tests for application logic
│   └── utils.py ---------- --- Contains utility functions for tests
└── uv.lock

``` -->

## Testing 

To run tests, use the following command:

- Run unit tests:
   ```bash
   just test-unit
   ```
- Run tests with coverage:
   ```bash
   just test-coverage
   ``` 
- Run test for clean architecture dependency rules:
   ```bash
   just test-clean
   ```