Skip to content

Conversation

@mE-uMAr
Copy link

@mE-uMAr mE-uMAr commented Nov 26, 2025

feat: Add modular architecture, MSSR pattern, and full project generation

Summary

Transforms fastapi-new from a basic project initializer into a complete modular project generator with professional architecture patterns and CLI tools.

Before → After

Before:

  • Only generated main.py with basic FastAPI setup

After:

  • Full project structure with modular architecture
  • MSSR pattern (Model-Schema-Service-Repository)
  • Complete CLI toolset for development
  • Auto-registration system
  • Multi-database support

New Features

🏗️ Modular Architecture

  • Auto-registration of application modules via INSTALLED_APPS
  • Clean separation with core/, apps/, and db/ directories
  • Automatic route discovery and loading

📦 MSSR Pattern

New createapp command generates structured modules:

app/apps/users/
├── models.py        # Data models
├── schemas.py       # Pydantic validation
├── services.py      # Business logic
├── repositories.py  # Data access
├── routes.py        # API endpoints
└── dependencies.py  # FastAPI dependencies

🔧 New CLI Commands

  • fastapi-new createapp <name> - Generate MSSR modules
  • fastapi-new add-db <engine> - Configure database (postgres/mysql/sqlite/mongodb)
  • fastapi-new list - View installed modules
  • fastapi-new doctor - Diagnose project health

📁 Complete Project Structure

myproject/
├── app/
│   ├── main.py          # Enhanced with auto-registration
│   ├── core/            # Configuration & utilities
│   ├── apps/            # Application modules
│   └── db/              # Database layer
├── .env                 # Environment config
└── pyproject.toml

Usage Example

# Create project with full structure
fastapi-new myapi
cd myapi

# Generate modules
fastapi-new createapp users
fastapi-new createapp products

# Configure database
fastapi-new add-db postgres --install

# Start server
uv run fastapi dev

Technical Details

  • Templates: 20+ .tpl files for clean code generation
  • Tests: 28 comprehensive tests covering all CLI commands
  • Python: 3.10+ support
  • Philosophy: Minimal boilerplate (~157 lines of starter code), maximum flexibility

Changes

Added Files

  • CLI commands: createapp.py, adddb.py, listapps.py, doctor.py
  • Templates: templates/project/ (13 files), templates/app/ (7 files)
  • Tests: Full coverage for new features
  • Utilities: Template engine and CLI helpers

Enhanced

  • new.py - Now generates complete structure instead of just main.py
  • README - Complete rewrite in FastAPI official docs style

Testing

✅ 28 tests, all passing
✅ Multi-OS (Linux, macOS, Windows)
✅ Python 3.10-3.14

Breaking Changes

None - existing usage continues to work with enhanced features.


Type: Feature Enhancement
Impact: High - Major new functionality
Docs: Complete

@mE-uMAr mE-uMAr changed the title feat: Add modular architecture, MSSR pattern, and full project generation upgrade: Add modular architecture, MSSR pattern, and full project generation Nov 26, 2025
@mE-uMAr mE-uMAr marked this pull request as draft November 26, 2025 20:40
@mE-uMAr mE-uMAr closed this Nov 26, 2025
@mE-uMAr mE-uMAr changed the title upgrade: Add modular architecture, MSSR pattern, and full project generation feat: Add modular architecture, MSSR pattern, and full project generation Nov 26, 2025
@mE-uMAr mE-uMAr reopened this Nov 26, 2025
@mE-uMAr mE-uMAr marked this pull request as ready for review November 27, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant