How kodaimura/scaf-fast works
Project Type and Purpose
• It implements clean-architecture principles: HTTP handlers → use cases → modules/repositories → database/Redis.
• Core services include account management (signup, login, logout, token refresh) and token blacklist support.
File-Structure Analysis
• Top-level: Dockerfile, docker-compose for local/prod, Makefile, alembic.ini, requirements.txt
• app/main.py and app/router.py boot up the FastAPI application and route definitions.
• app/handler: HTTP layer (DTOs, handlers).
• app/usecase: business logic (account operations).
• app/module: data models (_model.py), repository implementations (_repository.py), and module wiring (module.py).
• app/core: cross-cutting concerns (config, DB, Redis, JWT, crypto, logging, common response structures, base repository).
• alembic scripts under app/alembic for database migrations.
a. API Layer
• FastAPI Application (app/main.py)
• Router (app/router.py)
• HTTP Handlers (app/handler/*)
b. Business-Logic Layer
• Use Cases (app/usecase/account/*)
c. Data-Access Layer
• Module Definitions & Repositories (app/module/account, app/module/blacklist)
• Core Repository Base (app/core/repository.py)
d. Infrastructure
• Relational Database (PostgreSQL inferred)
• Redis (for token blacklist/cache)
• Alembic Migration Service
• Docker & Docker-Compose for containerization
e. Cross-Cutting Services
• Configuration (app/core/config.py)
• JWT Service (app/core/jwt.py)
• Crypto Utilities (app/core/crypto.py)
• Logging (app/core/logger.py)
Relationships and Data Flow
• Client → HTTP Router → Handler DTO → Handler logic calls → Use Case
• Use Case invokes → Module Repository → Database (CRUD) or → Redis (cache/blacklist)
• Database migration flow: Developer runs Alembic scripts → Database schema evolves
• Docker-Compose orchestrates containers: app, database, redis
Architectural Patterns
• Clean (Onion) Architecture: clear separation between HTTP, business logic, and data access.
• Repository Pattern abstracts persistence.
• Dependency Injection of modules and core services (config, DB, JWT, Redis).
• Containerized deployment via Docker images and Compose files.
Final Recommendations
• Be exhaustive in listing all account and blacklist endpoints.
• Token flow: issuance (JWT) and revocation (blacklist in Redis).
• Docker-Compose relationships: network links between app, db, redis.
• Migration pipeline: source code → alembic → schema.