user-management-api/
โ
โโโ README.md
โโโ requirements.txt
โโโ requirements-cli.txt # CLI-specific dependencies
โโโ .env
โโโ .gitignore
โโโ docker-compose.yml # Include Kafka services
โโโ Dockerfile
โโโ Dockerfile.cli # Separate CLI container
โ
โโโ src/
โ โ
โ โโโ __init__.py
โ โ
โ โโโ domain/ # ๐๏ธ DOMAIN LAYER (Core Business Logic)
โ โ โโโ __init__.py
โ โ โโโ entities/
โ โ โ โโโ __init__.py
โ โ โ โโโ user.py # Domain entities with business rules
โ โ โโโ exceptions/
โ โ โ โโโ __init__.py
โ โ โ โโโ user_exceptions.py # Domain-specific exceptions
โ โ โโโ events/ # ๐ Domain events
โ โ โโโ __init__.py
โ โ โโโ base.py # Base domain event
โ โ โโโ user_events.py # User domain events
โ โ
โ โโโ application/ # ๐ฏ APPLICATION LAYER (Use Cases & Business Logic)
โ โ โโโ __init__.py
โ โ โโโ dtos/
โ โ โ โโโ __init__.py
โ โ โ โโโ user_dtos.py # Data Transfer Objects
โ โ โ โโโ message_dtos.py # ๐ Message/Event DTOs
โ โ โโโ interfaces/
โ โ โ โโโ __init__.py
โ โ โ โโโ repositories/
โ โ โ โ โโโ __init__.py
โ โ โ โ โโโ user_repository.py # Repository abstractions
โ โ โ โโโ messaging/ # ๐ Messaging interfaces
โ โ โ โโโ __init__.py
โ โ โ โโโ event_publisher.py # Event publishing interface
โ โ โ โโโ message_handler.py # Message handling interface
โ โ โโโ services/
โ โ โโโ __init__.py
โ โ โโโ user_service.py # Application services
โ โ โโโ event_service.py # ๐ Event handling service
โ โ
โ โโโ infrastructure/ # ๐ง INFRASTRUCTURE LAYER (External Concerns)
โ โ โโโ __init__.py
โ โ โโโ database/
โ โ โ โโโ __init__.py
โ โ โ โโโ base.py # SQLAlchemy base
โ โ โ โโโ session.py # Database session
โ โ โ โโโ models/
โ โ โ โโโ __init__.py
โ โ โ โโโ user_model.py # SQLAlchemy models
โ โ โโโ repositories/
โ โ โ โโโ __init__.py
โ โ โ โโโ user_repository.py # Repository implementations
โ โ โโโ messaging/ # ๐ Kafka & Messaging
โ โ โ โโโ __init__.py
โ โ โ โโโ kafka/
โ โ โ โ โโโ __init__.py
โ โ โ โ โโโ config.py # Kafka configuration
โ โ โ โ โโโ producer.py # Kafka producer
โ โ โ โ โโโ consumer.py # Kafka consumer
โ โ โ โ โโโ topics.py # Topic definitions
โ โ โ โโโ publishers/
โ โ โ โ โโโ __init__.py
โ โ โ โ โโโ user_event_publisher.py # User event publisher
โ โ โ โโโ handlers/
โ โ โ โโโ __init__.py
โ โ โ โโโ user_message_handler.py # User message handler
โ โ โโโ config/
โ โ โ โโโ __init__.py
โ โ โ โโโ settings.py # Application configuration
โ โ โโโ dependencies.py # Dependency injection
โ โ
โ โโโ presentation/ # ๐ PRESENTATION LAYER (API Controllers)
โ โ โโโ __init__.py
โ โ โโโ api/ # ๐ Renamed for clarity
โ โ โ โโโ __init__.py
โ โ โ โโโ controllers/
โ โ โ โ โโโ __init__.py
โ โ โ โ โโโ user_controller.py # FastAPI controllers
โ โ โ โโโ middleware/
โ โ โ โ โโโ __init__.py
โ โ โ โ โโโ error_handler.py # Global exception handling
โ โ โ โ โโโ cors.py # CORS configuration
โ โ โ โโโ schemas/
โ โ โ โโโ __init__.py
โ โ โ โโโ responses.py # API response schemas
โ โ โโโ main.py # FastAPI app entry point
โ โ
โ โโโ cli/ # ๐ฅ๏ธ CLI LAYER (Command Line Interface)
โ โ โโโ __init__.py
โ โ โโโ commands/
โ โ โ โโโ __init__.py
โ โ โ โโโ user_commands.py # User CLI commands
โ โ โ โโโ kafka_commands.py # Kafka CLI commands
โ โ โโโ formatters/
โ โ โ โโโ __init__.py
โ โ โ โโโ table_formatter.py # Table output formatting
โ โ โ โโโ json_formatter.py # JSON output formatting
โ โ โโโ validators/
โ โ โ โโโ __init__.py
โ โ โ โโโ input_validators.py # CLI input validation
โ โ โโโ main.py # CLI app entry point
โ โ
โ โโโ messaging/ # ๐ MESSAGING LAYER (Event-Driven Architecture)
โ โโโ __init__.py
โ โโโ consumers/
โ โ โโโ __init__.py
โ โ โโโ user_consumer.py # User event consumer
โ โ โโโ base_consumer.py # Base consumer class
โ โโโ processors/
โ โ โโโ __init__.py
โ โ โโโ user_event_processor.py # Event processing logic
โ โโโ main.py # Message consumer entry point
โ
โโโ tests/ # ๐งช TEST LAYER
โ โโโ __init__.py
โ โโโ conftest.py
โ โโโ unit/
โ โ โโโ __init__.py
โ โ โโโ domain/
โ โ โ โโโ __init__.py
โ โ โ โโโ entities/
โ โ โ โ โโโ test_user.py
โ โ โ โโโ events/ # ๐ Domain events tests
โ โ โ โโโ test_user_events.py
โ โ โโโ application/
โ โ โ โโโ __init__.py
โ โ โ โโโ services/
โ โ โ โโโ test_user_service.py
โ โ โ โโโ test_event_service.py # ๐ Event service tests
โ โ โโโ infrastructure/
โ โ โ โโโ __init__.py
โ โ โ โโโ repositories/
โ โ โ โ โโโ test_user_repository.py
โ โ โ โโโ messaging/ # ๐ Messaging tests
โ โ โ โโโ test_kafka_producer.py
โ โ โ โโโ test_kafka_consumer.py
โ โ โโโ cli/ # ๐ CLI tests
โ โ โ โโโ __init__.py
โ โ โ โโโ commands/
โ โ โ โโโ test_user_commands.py
โ โ โโโ messaging/ # ๐ Messaging layer tests
โ โ โโโ test_user_consumer.py
โ โโโ integration/
โ โ โโโ __init__.py
โ โ โโโ test_user_endpoints.py
โ โ โโโ test_kafka_integration.py # ๐ Kafka integration tests
โ โ โโโ test_cli_integration.py # ๐ CLI integration tests
โ โโโ e2e/
โ โโโ __init__.py
โ โโโ test_user_flow.py
โ โโโ test_event_flow.py # ๐ Event-driven flow tests
โ
โโโ migrations/ # ๐ฆ DATABASE MIGRATIONS
โ โโโ versions/
โ โโโ alembic.ini
โ โโโ env.py
โ โโโ script.py.mako
โ
โโโ docs/ # ๐ DOCUMENTATION
โ โโโ architecture.md
โ โโโ api.md
โ โโโ cli.md # ๐ CLI documentation
โ โโโ kafka.md # ๐ Kafka documentation
โ โโโ deployment.md
โ
โโโ scripts/ # ๐จ UTILITY SCRIPTS
โ โโโ start-api.sh
โ โโโ start-cli.sh # ๐ CLI startup script
โ โโโ start-consumers.sh # ๐ Kafka consumers
โ โโโ test.sh
โ โโโ migrate.sh
โ
โโโ docker/ # ๐ณ DOCKER CONFIGURATIONS
โ โโโ api.Dockerfile
โ โโโ cli.Dockerfile # ๐ CLI container
โ โโโ consumer.Dockerfile # ๐ Message consumer container
โ โโโ kafka/ # ๐ Kafka setup
โ โโโ docker-compose.kafka.yml
โ โโโ kafka-setup.sh
โ
โโโ .github/ # ๐ CI/CD & GitHub Configuration
โโโ workflows/
โ โโโ api-ci.yml
๏ฟฝ๏ฟฝ โโโ cli-ci.yml # ๐ CLI CI/CD
โ โโโ kafka-ci.yml # ๐ Kafka integration CI
โ โโโ integration-tests.yml
โโโ ISSUE_TEMPLATE/
โโโ bug_report.md
โโโ feature_request.md