How prp-for-your-portrait-right-protection/backend-repo works
Project type and purpose
• This is a standalone backend service (likely Flask or FastAPI) providing endpoints to upload/originate videos, process them (e.g. block characters, whitelist faces), and manage users.
• It uses a relational database (db/) for metadata and a bucket (bucket/) for storing raw/processed video files.
Main components
A. API Layer (Controllers)
• app.py: the entrypoint / WSGI app
• apis/*.py: each file defines resource routes (User, OriginVideo, ProcessedVideo, BlockCharacter, WhitelistFace)
B. Business Logic Layer (Modules)
• module/crud_module.py: generic CRUD operations
• module/user_module.py, token.py: authentication & user management
• module/file_module.py: file‑handling operations (upload/download)
• module/db_module.py: data‑access abstractions
C. Data Layer
• db/db_connection.py & db/db_config.py: connection setup to the relational database
• db/schema.py & db/enum_classes.py: ORM models or schema definitions
D. Storage Layer
• bucket/m_connection.py & bucket/m_config.py: connection setup to object storage (S3, GCS or local bucket)
E. Supporting Components
• static/status_code.py: shared HTTP/status codes
• requirements.txt & Dockerfile: runtime environment and containerization
Relationships & Data Flow
1. Client → HTTP(S) request → API Layer (app.py)
2. API Layer routes to appropriate controller in apis/*.py
3. Controller calls Service/Module functions
• Authentication module (token.py) validates tokens
• CRUD module orchestrates DB reads/writes via db_module
• File module interacts with bucket layer for upload/download
4. Module calls Data Layer for persistence or bucket for file storage
5. Data Layer executes queries against the relational DB or object store
6. Responses bubble back up: Module → Controller → Client
Architectural patterns & principles
• Layered (n‑tier) architecture separating controllers, business logic, and data access
• Single responsibility per module: auth, user‑mgmt, file‑mgmt, CRUD
• Configuration externalized (db_config, module_config, m_config)
• Containerized deployment (Dockerfile)
Key details not to miss
• Token flow: Login request → token module → token output → subsequent request header
• Distinguish between raw video upload (OriginVideo API) and processed output (ProcessedVideo API)
• Bucket connection separate from DB connection