How gcrsaldanha/codeflix-catalog-admin works
Project Type and Purpose
• This is a full-stack backend application (no separate JS frontend) built with Python 3, Django REST Framework, and a Domain-Driven Design (DDD) organization under src/core.
• It provides CRUD and media-upload APIs for Categories, Genres, Cast Members, and Videos, plus asynchronous processing via RabbitMQ and optional Google Cloud Storage or local storage for video files.
File Structure
• src/core/: Core DDD modules organized by domain (category, genre, cast_member, video) and cross-cutting shared code (authentication, event bus, storage).
• domain/ holds entities, value objects, repository interfaces.
• application/use_cases/ implements business logic.
• infra/ contains in-memory repos, RabbitMQ consumers/producers, GCS/local storage.
• src/django_project/: The Django project wrapper with four “apps” (category_app, genre_app, cast_member_app, video_app). Each app maps REST endpoints to serializers, repositories, and use-cases.
Extract Key Points from the README
• The system relies on:
• Django ORM (models & migrations) for data persistence in a relational DB (assumed PostgreSQL or default SQLite).
• RabbitMQ for dispatching and consuming video-processing events.
• JWT authentication (pluggable via core/_shared/infrastructure/auth).
• Commands: startconsumer (to run the RabbitMQ listener) and runserver (to serve HTTP).
• The readme highlights an evolutionary, module-by-module approach—each domain feature follows the same layering (domain → use case → infra → Django app).
a. Main Components
• Clients: Web UI or Postman (external actors issuing HTTP requests).
• Django REST API:
• Four Django apps exposing endpoints (/categories, /genres, /cast_members, /videos).
• Controllers/Views → Serializers → “Repository” adapters → Use Cases → Domain Entities.
• Domain & Application Layer (src/core):
• Shared domain logic, events, notification, handlers.
• Use Cases for each aggregate.
• Infrastructure Layer:
• Relational Database (via Django ORM).
• RabbitMQ (message bus & consumer).
• Storage Adapters: GCS or Local (media files).
• Auth Service (JWT or external Keycloak).
• Asynchronous Workers:
• video_converted_rabbitmq_consumer listens for “video converted” events.
• Use Cases for processing audio/video or dispatching new events.
b. Relationships & Interactions
• HTTP flow: Client → Django REST endpoint → Use Case → DB → Response.
• Upload flow: Client uploads media → API writes to storage adapter → Use Case publishes “upload_video” event to RabbitMQ.
• Consume flow: RabbitMQ → startconsumer process → Domain event handler → updates DB or triggers further processes.
• Auth flow: HTTP request → JWT Auth middleware → Auth Service (validate/issue tokens).
c. Architectural Patterns & Design Principles
• Layered Architecture: Presentation (Django views) → Application (use cases) → Domain → Infrastructure.
• DDD aggregates and boundaries clearly separated.
• Ports & Adapters (Hexagonal): Domain code depends on interfaces; adapters in infra implement them.
• Event-Driven for asynchronous video processing.
d. Key Technologies & Frameworks
• Python 3, Django, Django REST Framework
• RabbitMQ (pika or kombu via rabbitmq_dispatcher)
• Google Cloud Storage (via gcs_storage.py) or Local FS
• PyTest for unit & integration tests, pytest-django for e2e
• JWT authentication layer (pluggable)