How och1ai/taller1 works
Project Type and Purpose
• This is a single-purpose microservice in a larger ecosystem: a RESTful User Service API built with FastAPI.
• It provides user management (CRUD), JWT-based authentication/authorization, and audit logging, all backed by a PostgreSQL database.
• There is also a small mock_main_api container used for local/integration testing of how the User Service would interact with a “main” application.
High-Level Components
a. Clients
• Web/UIs or other services that consume the REST API
• Automated test runner (test_api.py, run_tests.sh)
• Swagger/OpenAPI UI and ReDoc
b. API Layer (user_service/app/main.py)
• FastAPI application with routers under /api/v1
• Dependency‐injection system for DB sessions and security
c. Business Logic Layer
• Endpoint controllers (app/api/v1/endpoints/*.py)
• Authentication (app/core/auth.py), security (app/core/security.py), configuration (app/core/config.py)
d. Data Access Layer
• CRUD classes implementing the Repository pattern (app/crud/*.py)
• Pydantic schemas (app/schemas/*.py)
• SQLAlchemy models (app/models/*.py)
• Alembic‐style migrations and seeders
e. Database Layer
• PostgreSQL instance defined in docker-compose.yml
• Tables: users, audit_logs
f. Auxiliary Services
• mock_main_api container to simulate interactions
• Local script runners for testing, migration, and seeding
Relationships and Data Flows
• Clients → HTTP request → FastAPI API Layer
• API Layer ↔ DI of DB Session → Business Logic Layer → CRUD → PostgreSQL
• On sensitive admin actions, Observer pattern logs to audit_logs table
• External service (mock_main_api) calls user routes during integration tests
• Tests invoke endpoints (via base URL) and validate responses
Architectural Patterns & Design Principles
• Layered Architecture separating concerns end-to-end
• Repository Pattern for abstracting database operations
• Dependency Injection via FastAPI’s Depends
• Factory for token creation (JWT) in app/core/auth.py
• Observer for audit logging inside endpoint handlers
• Singleton for global settings in app/core/config.py
• Soft Delete strategy in CRUD remove operations
Essential Elements to Capture
• The FastAPI server container (user_service) exposing /api/v1 endpoints
• The PostgreSQL container with tables users and audit_logs
• The mock_main_api container used for integration tests
• The test runner and Swagger/OpenAPI UIs as consuming clients
• The dependency injection pipeline (DB session, security)
• The audit observer hooking into delete/update operations
• Docker Compose topology: network links among user_service, postgres, mock_main_api
Leveraging Existing PlantUML Files
• The project includes docs/architecture.puml, docs/database.puml, docs/auth_flow.puml. Use or adapt these as a starting point.