Skip to main content

CLI tool for scaffolding clean architecture in FastAPI projects

Project description

Fast Clean Architecture

Python 3.9+ License: MIT Code style: black

A powerful CLI tool that transforms how you build FastAPI applications by automatically generating clean architecture scaffolding with domain-driven design patterns. Say goodbye to boilerplate code and hello to maintainable, scalable applications.

๐ŸŽฏ What is Fast Clean Architecture?

Fast Clean Architecture (FCA) is a sophisticated code generation tool that creates well-structured FastAPI projects following clean architecture principles. It generates complete application scaffolding including entities, repositories, services, API controllers, and moreโ€”all organized in a clean, maintainable structure.

The Problem It Solves

  • Boilerplate Fatigue: Eliminates repetitive setup code for FastAPI projects
  • Architecture Inconsistency: Enforces clean architecture patterns across your entire codebase
  • Scaling Challenges: Provides a scalable foundation that grows with your application
  • Team Alignment: Ensures all developers follow the same architectural patterns
  • Time to Market: Accelerates development by generating production-ready code structure

๐Ÿš€ Key Features

Core Architecture Features

  • ๐Ÿ—๏ธ Clean Architecture: Enforces separation of concerns with distinct layers (Domain, Application, Infrastructure, Presentation)
  • ๐ŸŽฏ Domain-Driven Design: Supports bounded contexts and domain modeling patterns
  • ๐Ÿ“ฆ Modular Structure: Organizes code into systems and modules for better maintainability
  • ๐Ÿ”„ CQRS Support: Built-in command and query separation patterns
  • ๐ŸŽจ API Versioning: Native support for versioned APIs (v1, v2, v3) with proper routing

Code Generation & Templates

  • โšก Automated Scaffolding: Generate entities, repositories, services, controllers, and schemas
  • ๐ŸŽจ Customizable Templates: Jinja2-powered templates that you can modify to fit your needs
  • ๐Ÿ“‹ Batch Operations: Create multiple components from YAML specifications
  • ๐Ÿ”ง Template Validation: Built-in validation ensures generated code quality and security

Developer Experience

  • ๐Ÿ’ป Intuitive CLI: Rich command-line interface with helpful output and error messages
  • ๐Ÿ“Š Project Monitoring: Built-in analytics, error tracking, and health monitoring
  • ๐Ÿ”’ Security Features: Template validation, input sanitization, and secure file operations
  • โš™๏ธ Configuration Management: YAML-based project configuration with versioning

Modern Python & FastAPI Integration

  • ๐Ÿ Modern Python: Built for Python 3.9+ with full async/await support
  • ๐Ÿ” Type Safety: Complete type hints and Pydantic validation throughout
  • ๐Ÿ“ฆ Dependency Management: Support for both Poetry and pip workflows
  • ๐Ÿš€ FastAPI Ready: Generated code integrates seamlessly with FastAPI applications

๐Ÿ—๏ธ Architecture Overview

FCA generates a clean, layered architecture that follows industry best practices:

๐Ÿ“ project_root/
โ”œโ”€โ”€ ๐Ÿ“ systems/                    # Bounded contexts (business domains)
โ”‚   โ””โ”€โ”€ ๐Ÿ“ {system_name}/           # e.g., user_management, order_processing
โ”‚       โ””โ”€โ”€ ๐Ÿ“ {module_name}/       # e.g., users, authentication
โ”‚           โ”œโ”€โ”€ ๐Ÿ“ domain/          # ๐ŸŽฏ Business Logic Layer
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ entities/    # Core business entities
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ events/      # Domain events for decoupling
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ exceptions/  # Domain-specific exceptions
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ interfaces/  # Repository & service contracts
โ”‚           โ”‚   โ””โ”€โ”€ ๐Ÿ“ value_objects/ # Immutable value objects
โ”‚           โ”œโ”€โ”€ ๐Ÿ“ application/     # ๐Ÿ”„ Use Cases & Application Services
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ dtos/        # Data Transfer Objects
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ services/    # Application services
โ”‚           โ”‚   โ””โ”€โ”€ ๐Ÿ“ use_cases/   # Use case implementations
โ”‚           โ”‚       โ”œโ”€โ”€ ๐Ÿ“ commands/ # Command handlers (CQRS)
โ”‚           โ”‚       โ””โ”€โ”€ ๐Ÿ“ queries/  # Query handlers (CQRS)
โ”‚           โ”œโ”€โ”€ ๐Ÿ“ infrastructure/  # ๐Ÿ”ง External Concerns
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ config/      # Configuration management
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ database/    # Database layer
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ migrations/ # Database migrations
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ models/    # ORM models
โ”‚           โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“ repositories/ # Repository implementations
โ”‚           โ”‚   โ””โ”€โ”€ ๐Ÿ“ external/    # External service clients
โ”‚           โ”œโ”€โ”€ ๐Ÿ“ presentation/    # ๐ŸŒ API Layer (Versioned)
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ controllers/ # API controllers
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ v1/      # Version 1 controllers
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ v2/      # Version 2 controllers
โ”‚           โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“ v3/      # Version 3 controllers
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ middleware/  # Custom middleware
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ routes/      # FastAPI routers
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ v1/      # Version 1 routes
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ v2/      # Version 2 routes
โ”‚           โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“ v3/      # Version 3 routes
โ”‚           โ”‚   โ””โ”€โ”€ ๐Ÿ“ schemas/     # Pydantic schemas
โ”‚           โ”‚       โ”œโ”€โ”€ ๐Ÿ“ v1/      # Version 1 schemas
โ”‚           โ”‚       โ”œโ”€โ”€ ๐Ÿ“ v2/      # Version 2 schemas
โ”‚           โ”‚       โ””โ”€โ”€ ๐Ÿ“ v3/      # Version 3 schemas
โ”‚           โ””โ”€โ”€ ๐Ÿ“„ {module_name}_module_api.py # Module API entry point
โ””โ”€โ”€ ๐Ÿ“„ fca_config.yaml            # Project configuration

Layer Responsibilities

Layer Purpose Components
๐ŸŽฏ Domain Core business logic and rules Entities, Value Objects, Domain Events, Interfaces
๐Ÿ”„ Application Use cases and application services Services, Commands, Queries, DTOs
๐Ÿ”ง Infrastructure External concerns and implementations Repositories, Database Models, External Services
๐ŸŒ Presentation API layer with versioning support Controllers, Routes, Schemas, Middleware

๐Ÿ“‹ Prerequisites

Before you start, ensure you have:

  • Python 3.9+ installed on your system
  • Basic understanding of FastAPI and web API development
  • Familiarity with clean architecture principles (helpful but not required)
  • A directory where you want to create your FastAPI project
  • Package Manager: pip or Poetry

๐Ÿ’ก Note: FCA generates the architectural foundation for your FastAPI application. You'll create the main FastAPI app instance and wire dependencies together.

๐Ÿ“ฆ Installation

Quick Installation

# Using pip (recommended)
pip install fast-clean-architecture

# Using Poetry
poetry add fast-clean-architecture

Verify Installation

fca-scaffold --version
fca-scaffold --help

๐Ÿš€ Quick Start Guide

Let's build a complete user management API from scratch:

Step 1: Create Your FastAPI Project Foundation

# Create a new directory for your project
mkdir my-clean-api && cd my-clean-api

# Option A: Using Poetry (Recommended)
poetry init --name my-clean-api
poetry add fastapi uvicorn

# Option B: Using pip
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install fastapi uvicorn

Step 2: Initialize FCA in Your Project

# Interactive initialization (recommended for beginners)
fca-scaffold init

# Or specify details directly
fca-scaffold init --name "my-clean-api" --description "A clean architecture FastAPI project"

This creates the fca_config.yaml configuration file that tracks your project structure.

Step 3: Create Your First System (Bounded Context)

# Create a user management system
fca-scaffold create-system-context user-management --description "User management and authentication"

Step 4: Create a Module Within the System

# Create a users module
fca-scaffold create-module user-management users --description "User domain logic"

Step 5: Generate Domain Components

# Generate core domain components
fca-scaffold create-component user-management users entities user
fca-scaffold create-component user-management users value_objects user_email
fca-scaffold create-component user-management users interfaces user_repository
fca-scaffold create-component user-management users exceptions user_not_found

Step 6: Generate Application Layer

# Generate application services and use cases
fca-scaffold create-component user-management users services user_service
fca-scaffold create-component user-management users use_cases/commands create_user_command
fca-scaffold create-component user-management users use_cases/queries get_user_query
fca-scaffold create-component user-management users dtos user_dto

Step 7: Generate Infrastructure Layer

# Generate infrastructure components
fca-scaffold create-component user-management users infrastructure/repositories user_repository
fca-scaffold create-component user-management users infrastructure/models user_model

Step 8: Generate API Layer (Versioned)

# Generate versioned API components
fca-scaffold create-component user-management users controllers/v1 user_controller
fca-scaffold create-component user-management users routes/v1 user_routes
fca-scaffold create-component user-management users schemas/v1 user_schema

Step 9: Create Your FastAPI Application

Create a main.py file to wire everything together:

# main.py
from fastapi import FastAPI
from systems.user_management.users.presentation.routes.v1.user_routes import router as user_router_v1

app = FastAPI(
    title="My Clean Architecture API",
    description="FastAPI application with clean architecture",
    version="1.0.0"
)

# Include versioned routers
app.include_router(user_router_v1, prefix="/api/v1", tags=["users-v1"])

@app.get("/")
async def root():
    return {"message": "Clean Architecture API is running!", "version": "1.0.0"}

@app.get("/health")
async def health_check():
    return {"status": "healthy", "service": "my-clean-api"}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

Step 10: Run Your Application

# Run the development server
uvicorn main:app --reload

# Or run directly
python main.py

Your API is now running at:

๐Ÿ“š Comprehensive CLI Reference

Project Initialization Commands

# Initialize a new FCA project
fca-scaffold init [OPTIONS]
  --name TEXT         Project name
  --description TEXT  Project description
  --version TEXT      Initial version (default: 0.1.0)

# Create a complete scalable baseline project
fca-scaffold create-scalable-baseline PROJECT_NAME [OPTIONS]
  --description TEXT  Project description
  --version TEXT      Project version
  --deps [poetry|pip] Dependency manager (default: poetry)

System and Module Management

# Create a new system (bounded context)
fca-scaffold create-system-context SYSTEM_NAME [OPTIONS]
  --description TEXT  System description

# Create a module within a system
fca-scaffold create-module SYSTEM_NAME MODULE_NAME [OPTIONS]
  --description TEXT  Module description

# Migrate existing modules to API versioning
fca-scaffold migrate-to-api-versioning [OPTIONS]
  --system TEXT   Target system
  --module TEXT   Target module

Component Generation

# Create individual components
fca-scaffold create-component SYSTEM MODULE COMPONENT_TYPE COMPONENT_NAME [OPTIONS]
  --template-dir PATH  Custom template directory
  --force             Overwrite existing files
  --dry-run           Preview without creating files

Available Component Types

Layer Component Types Examples
Domain entities, value_objects, interfaces, events, exceptions user, user_email, user_repository
Application services, dtos, use_cases/commands, use_cases/queries user_service, user_dto, create_user
Infrastructure repositories, models, external, config user_repository, user_model
Presentation controllers/v1, routes/v1, schemas/v1, middleware user_controller, user_routes

Batch Operations

# Create multiple components from YAML specification
fca-scaffold batch-create SPEC_FILE [OPTIONS]
  --dry-run   Preview changes
  --force     Overwrite existing files
  --verbose   Detailed output

YAML Specification Example

# components_spec.yaml
systems:
  - name: ecommerce
    description: "E-commerce system"
    modules:
      - name: products
        description: "Product catalog module"
        components:
          domain:
            entities: [Product, Category]
            value_objects: [ProductPrice, ProductSKU]
            interfaces: [ProductRepository, CategoryRepository]
          application:
            services: [ProductService, CategoryService]
            commands: [CreateProduct, UpdateProduct]
            queries: [GetProduct, ListProducts]
          infrastructure:
            repositories: [ProductRepository, CategoryRepository]
            models: [ProductModel, CategoryModel]
          presentation:
            controllers/v1: [ProductController, CategoryController]
            routes/v1: [ProductRoutes, CategoryRoutes]
            schemas/v1: [ProductSchema, CategorySchema]

Project Management & Monitoring

# Project status and information
fca-scaffold status              # Show project overview
fca-scaffold config show         # Display current configuration
fca-scaffold config validate     # Validate configuration file
fca-scaffold system-status       # System health and analytics
fca-scaffold version            # Show version information

Global Options

These options work with most commands:

--dry-run     # Preview changes without writing files
--force       # Overwrite existing files
--verbose     # Show detailed output
--config PATH # Use custom config file
--help        # Show command help

๐Ÿ”ง Advanced Features

API Versioning Strategy

FCA provides built-in support for API versioning, allowing you to maintain multiple API versions simultaneously:

# Generate components for different API versions
fca-scaffold create-component user-management users controllers/v1 user_controller
fca-scaffold create-component user-management users controllers/v2 user_controller
fca-scaffold create-component user-management users controllers/v3 user_controller

# Each version can have different schemas and routes
fca-scaffold create-component user-management users schemas/v1 user_schema
fca-scaffold create-component user-management users schemas/v2 user_schema  # Enhanced schema
fca-scaffold create-component user-management users schemas/v3 user_schema  # Latest schema

Configuration Management

The fca_config.yaml file tracks your entire project structure:

project:
  name: my-clean-api
  description: A clean architecture FastAPI project
  version: 1.0.0
  created_at: 2024-01-15T10:30:00Z
  updated_at: 2024-01-15T10:30:00Z
  
systems:
  user-management:
    description: User management and authentication
    created_at: 2024-01-15T10:35:00Z
    updated_at: 2024-01-15T10:35:00Z
    modules:
      users:
        description: User domain logic
        created_at: 2024-01-15T10:40:00Z
        updated_at: 2024-01-15T10:40:00Z
        components:
          domain:
            entities: ["user"]
            value_objects: ["user_email"]
            interfaces: ["user_repository"]
          application:
            services: ["user_service"]
            commands: ["create_user_command"]
            queries: ["get_user_query"]
          infrastructure:
            repositories: ["user_repository"]
            models: ["user_model"]
          presentation:
            controllers:
              v1: ["user_controller"]
            routes:
              v1: ["user_routes"]
            schemas:
              v1: ["user_schema"]

System Monitoring & Analytics

FCA includes built-in monitoring capabilities:

# View comprehensive system status
fca-scaffold system-status --verbose

Monitoring Features:

  • ๐Ÿ“Š Usage Analytics: Track command usage patterns and component creation frequency
  • ๐Ÿ› Error Tracking: Monitor and log errors with detailed context and stack traces
  • ๐Ÿ’พ Health Monitoring: System resource usage, performance metrics, and disk space
  • ๐Ÿ”’ Security Monitoring: Template validation results and input sanitization tracking
  • ๐Ÿ“ˆ Performance Metrics: Command execution times and system responsiveness

Dependency Management Options

FCA supports both modern and traditional Python dependency management:

Poetry (Recommended)

# Create project with Poetry
fca-scaffold create-scalable-baseline my-api --deps poetry

# Generates:
# - pyproject.toml with dependencies
# - Poetry-specific README sections
# - Modern Python project structure

Pip (Traditional)

# Create project with pip
fca-scaffold create-scalable-baseline my-api --deps pip

# Generates:
# - requirements.txt and requirements-dev.txt
# - pip-specific README sections
# - Traditional Python project structure

๐ŸŽจ Customization & Templates

Understanding the Template System

FCA uses Jinja2 templates to generate code. You can customize these templates to match your coding standards and preferences.

Copying Default Templates

# Copy default templates to your project
cp -r $(python -c "import fast_clean_architecture; print(fast_clean_architecture.__path__[0])")/templates ./custom_templates

Template Structure

custom_templates/
โ”œโ”€โ”€ domain/
โ”‚   โ”œโ”€โ”€ entities/
โ”‚   โ”‚   โ””โ”€โ”€ entity.py.j2
โ”‚   โ”œโ”€โ”€ value_objects/
โ”‚   โ”‚   โ””โ”€โ”€ value_object.py.j2
โ”‚   โ””โ”€โ”€ interfaces/
โ”‚       โ””โ”€โ”€ repository.py.j2
โ”œโ”€โ”€ application/
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ””โ”€โ”€ service.py.j2
โ”‚   โ””โ”€โ”€ use_cases/
โ”‚       โ”œโ”€โ”€ commands/
โ”‚       โ”‚   โ””โ”€โ”€ command.py.j2
โ”‚       โ””โ”€โ”€ queries/
โ”‚           โ””โ”€โ”€ query.py.j2
โ”œโ”€โ”€ infrastructure/
โ”‚   โ”œโ”€โ”€ repositories/
โ”‚   โ”‚   โ””โ”€โ”€ repository.py.j2
โ”‚   โ””โ”€โ”€ models/
โ”‚       โ””โ”€โ”€ model.py.j2
โ””โ”€โ”€ presentation/
    โ”œโ”€โ”€ controllers/
    โ”‚   โ””โ”€โ”€ controller.py.j2
    โ”œโ”€โ”€ routes/
    โ”‚   โ””โ”€โ”€ routes.py.j2
    โ””โ”€โ”€ schemas/
        โ””โ”€โ”€ schema.py.j2

Available Template Variables

Templates have access to these variables:

{# System context #}
{{ system_name }}        # snake_case: user_management
{{ SystemName }}         # PascalCase: UserManagement
{{ system_name_camel }}  # camelCase: userManagement

{# Module context #}
{{ module_name }}        # snake_case: users
{{ ModuleName }}         # PascalCase: Users
{{ module_name_camel }}  # camelCase: users

{# Component context #}
{{ component_name }}     # snake_case: user_service
{{ ComponentName }}      # PascalCase: UserService
{{ component_name_camel }}# camelCase: userService

{# Import paths #}
{{ entity_import }}      # Relative import path
{{ repository_import }}  # Relative import path
{{ service_import }}     # Relative import path

{# Metadata #}
{{ generated_at }}       # ISO timestamp
{{ generator_version }}  # Tool version
{{ project_name }}       # Project name
{{ project_description }}# Project description

Using Custom Templates

# Use your custom templates
fca-scaffold create-component --template-dir ./custom_templates user-management users entities user

Example Custom Template

# custom_templates/domain/entities/entity.py.j2
"""{{ ComponentName }} entity for {{ project_name }}.

Generated at: {{ generated_at }}
Generator version: {{ generator_version }}
"""

from datetime import datetime
from typing import Optional
from uuid import UUID, uuid4

from pydantic import BaseModel, Field


class {{ ComponentName }}(BaseModel):
    """{{ ComponentName }} domain entity.
    
    This entity represents the core business logic for {{ component_name }}s
    in the {{ system_name }} system.
    """
    
    id: UUID = Field(default_factory=uuid4, description="Unique identifier")
    created_at: datetime = Field(default_factory=datetime.utcnow, description="Creation timestamp")
    updated_at: Optional[datetime] = Field(default=None, description="Last update timestamp")
    
    # Add your domain-specific fields here
    
    class Config:
        """Pydantic configuration."""
        
        json_encoders = {
            datetime: lambda v: v.isoformat(),
            UUID: lambda v: str(v)
        }
        
    def update_timestamp(self) -> None:
        """Update the last modified timestamp."""
        self.updated_at = datetime.utcnow()

๐Ÿ“– Real-World Examples

Complete E-commerce System

Let's build a comprehensive e-commerce system:

# Initialize the project
fca-scaffold init --name "ecommerce-api" --description "E-commerce platform with clean architecture"

# Create bounded contexts (systems)
fca-scaffold create-system-context catalog --description "Product catalog management"
fca-scaffold create-system-context orders --description "Order processing and management"
fca-scaffold create-system-context payments --description "Payment processing"
fca-scaffold create-system-context users --description "User management and authentication"

# Create modules for catalog system
fca-scaffold create-module catalog products --description "Product management"
fca-scaffold create-module catalog categories --description "Category management"
fca-scaffold create-module catalog inventory --description "Inventory tracking"

# Create modules for orders system
fca-scaffold create-module orders orders --description "Order processing"
fca-scaffold create-module orders cart --description "Shopping cart"
fca-scaffold create-module orders shipping --description "Shipping management"

# Generate complete product module
fca-scaffold create-component catalog products entities product
fca-scaffold create-component catalog products value_objects product_price
fca-scaffold create-component catalog products value_objects product_sku
fca-scaffold create-component catalog products interfaces product_repository
fca-scaffold create-component catalog products services product_service
fca-scaffold create-component catalog products use_cases/commands create_product
fca-scaffold create-component catalog products use_cases/queries get_product
fca-scaffold create-component catalog products infrastructure/repositories product_repository
fca-scaffold create-component catalog products infrastructure/models product_model
fca-scaffold create-component catalog products controllers/v1 product_controller
fca-scaffold create-component catalog products routes/v1 product_routes
fca-scaffold create-component catalog products schemas/v1 product_schema

# Generate order processing components
fca-scaffold create-component orders orders entities order
fca-scaffold create-component orders orders entities order_item
fca-scaffold create-component orders orders value_objects order_status
fca-scaffold create-component orders orders services order_service
fca-scaffold create-component orders orders use_cases/commands create_order
fca-scaffold create-component orders orders use_cases/commands update_order_status
fca-scaffold create-component orders orders use_cases/queries get_order
fca-scaffold create-component orders orders controllers/v1 order_controller
fca-scaffold create-component orders orders routes/v1 order_routes
fca-scaffold create-component orders orders schemas/v1 order_schema

Blog Platform with Multi-tenancy

# Initialize blog platform
fca-scaffold init --name "blog-platform" --description "Multi-tenant blog platform"

# Create systems
fca-scaffold create-system-context content --description "Content management"
fca-scaffold create-system-context users --description "User and tenant management"
fca-scaffold create-system-context analytics --description "Analytics and reporting"

# Create content modules
fca-scaffold create-module content posts --description "Blog post management"
fca-scaffold create-module content comments --description "Comment system"
fca-scaffold create-module content media --description "Media management"
fca-scaffold create-module content tags --description "Tagging system"

# Generate complete post management
fca-scaffold create-component content posts entities post
fca-scaffold create-component content posts entities post_revision
fca-scaffold create-component content posts value_objects post_status
fca-scaffold create-component content posts value_objects post_slug
fca-scaffold create-component content posts services post_service
fca-scaffold create-component content posts use_cases/commands create_post
fca-scaffold create-component content posts use_cases/commands publish_post
fca-scaffold create-component content posts use_cases/queries get_published_posts
fca-scaffold create-component content posts controllers/v1 post_controller
fca-scaffold create-component content posts routes/v1 post_routes
fca-scaffold create-component content posts schemas/v1 post_schema

Microservices Architecture

FCA is perfect for microservices where each service follows clean architecture:

# User Service
fca-scaffold init --name "user-service"
fca-scaffold create-system-context users
fca-scaffold create-module users authentication
fca-scaffold create-module users profiles

# Order Service
fca-scaffold init --name "order-service"
fca-scaffold create-system-context orders
fca-scaffold create-module orders processing
fca-scaffold create-module orders fulfillment

# Notification Service
fca-scaffold init --name "notification-service"
fca-scaffold create-system-context notifications
fca-scaffold create-module notifications email
fca-scaffold create-module notifications sms
fca-scaffold create-module notifications push

๐Ÿงช Testing Your Generated Code

FCA generates testable code. Here's how to add tests:

Test Structure

tests/
โ”œโ”€โ”€ unit/
โ”‚   โ”œโ”€โ”€ domain/
โ”‚   โ”‚   โ”œโ”€โ”€ test_entities.py
โ”‚   โ”‚   โ””โ”€โ”€ test_value_objects.py
โ”‚   โ”œโ”€โ”€ application/
โ”‚   โ”‚   โ”œโ”€โ”€ test_services.py
โ”‚   โ”‚   โ””โ”€โ”€ test_use_cases.py
โ”‚   โ””โ”€โ”€ infrastructure/
โ”‚       โ””โ”€โ”€ test_repositories.py
โ”œโ”€โ”€ integration/
โ”‚   โ”œโ”€โ”€ test_api_endpoints.py
โ”‚   โ””โ”€โ”€ test_database.py
โ””โ”€โ”€ e2e/
    โ””โ”€โ”€ test_user_workflows.py

Running Tests

# Install testing dependencies
pip install pytest pytest-cov pytest-asyncio httpx

# Run all tests
pytest

# Run with coverage
pytest --cov=systems --cov-report=html

# Run specific test categories
pytest tests/unit/          # Unit tests only
pytest tests/integration/   # Integration tests only
pytest tests/e2e/          # End-to-end tests only

๐Ÿ”ง Development & Contributing

Setting Up Development Environment

# Clone the repository
git clone https://github.com/alden-technologies/fast-clean-architecture.git
cd fast-clean-architecture

# Install with development dependencies
poetry install --with dev

# Activate the virtual environment
poetry shell

# Install pre-commit hooks
pre-commit install

Code Quality Standards

# Format code
black fast_clean_architecture tests

# Sort imports
isort fast_clean_architecture tests

# Type checking
mypy fast_clean_architecture

# Linting
flake8 fast_clean_architecture

# Security scanning
bandit -r fast_clean_architecture

# Dependency vulnerability scanning
safety check

# Run all quality checks
make quality  # or poetry run poe quality

Security & Dependency Management

This project maintains high security standards:

  • ๐Ÿ”’ Dependency Pinning: All dependencies pinned with SHA256 hashes
  • ๐Ÿ›ก๏ธ Security Patches: Regular updates for security vulnerabilities
  • ๐Ÿ” Vulnerability Scanning: Automated scanning with Safety and Bandit
  • ๐Ÿ“‹ Supply Chain Security: Verified package integrity

Recent Security Updates:

  • Black 24.3.0+: Fixes CVE-2024-21503 (ReDoS vulnerability)
  • Pip 25.0+: Fixes PVE-2025-75180 (malicious wheel execution)
  • Setuptools 78.1.1+: Fixes CVE-2025-47273 (path traversal vulnerability)

Contributing Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes following the coding standards
  4. Add tests for your changes
  5. Run the test suite: pytest
  6. Run code quality checks: make quality
  7. Commit your changes: git commit -m 'Add amazing feature'
  8. Push to the branch: git push origin feature/amazing-feature
  9. Open a Pull Request

๐Ÿ“š Documentation

Project Governance

User Guides

Technical Documentation

๐Ÿค Community & Support

Getting Help

Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • ๐Ÿ› Bug Reports: How to report issues effectively
  • โœจ Feature Requests: Proposing new features
  • ๐Ÿ”ง Code Contributions: Development workflow and standards
  • ๐Ÿ“– Documentation: Improving docs and examples
  • ๐Ÿงช Testing: Adding and improving tests

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • ๐Ÿ—๏ธ Architecture: Inspired by Uncle Bob's Clean Architecture principles
  • โšก CLI Framework: Built with Typer for excellent developer experience
  • ๐ŸŽจ Templates: Powered by Jinja2 for flexible code generation
  • ๐Ÿ”ง Configuration: Pydantic for robust configuration management
  • ๐Ÿš€ FastAPI: Designed specifically for FastAPI applications
  • ๐Ÿ Python Community: For the amazing ecosystem and tools

Made with โค๏ธ by Adegbenga Agoro, Founder of Alden Technologies

Fast Clean Architecture - Transforming how you build FastAPI applications, one component at a time.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_clean_architecture-1.4.2.tar.gz (263.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast_clean_architecture-1.4.2-py3-none-any.whl (120.8 kB view details)

Uploaded Python 3

File details

Details for the file fast_clean_architecture-1.4.2.tar.gz.

File metadata

  • Download URL: fast_clean_architecture-1.4.2.tar.gz
  • Upload date:
  • Size: 263.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.1 Darwin/24.5.0

File hashes

Hashes for fast_clean_architecture-1.4.2.tar.gz
Algorithm Hash digest
SHA256 d908d9b2ed6db899199f65e25e7f75c04e77b1e4247454a4dc1938277e484a5d
MD5 53840934b320398afe6a42c03ab18a65
BLAKE2b-256 5f79fac076dd3ee4a22ea756fd631b93289b0c65bd37e3546b1b674cb8e063a3

See more details on using hashes here.

File details

Details for the file fast_clean_architecture-1.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for fast_clean_architecture-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3365ec4ac466e7aa11a27b846e049ebd696da16ac3c2dc37cecc449d145d3bf7
MD5 d457e6c30c0bf572150038813303818f
BLAKE2b-256 1f51fd0cf89730ad8693a9300125e0c2b5a8b3b095acbeefbe06b8b1e5e72d51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page