How mlldzi/example works
Project type and purpose
• This is a full-stack, microservices-based MVP.
• Frontend: a Vue 3 / Vite single-page application (SPA).
• Backend: two Python microservices (auth_service, user_service) sharing common modules, plus a Celery worker for asynchronous tasks.
• Docker-Compose for local orchestration, plus individual Dockerfiles per component.
File structure
Top-level:
– backend/
• auth_service/ (REST API for authentication)
• user_service/ (REST API for user management)
• shared/ (common config, models, exception definitions, utilities)
– celery_worker/ (defines Celery tasks)
– frontend/ (Vue SPA)
– docker-compose.yml (defines inter-service networking, volumes, environment, message broker, and database)
– docs/ (architecture, deployment, service details)
Key insights from docs/ and README
• Each backend service is a standalone Docker container with its own requirements.txt and app.py.
• Shared code is mounted or packaged so that both services import the same config, models, and utilities.
• Celery worker relies on the same shared modules to deserialize tasks.
• Docker-Compose orchestrates the two services, a message broker (e.g., Redis or RabbitMQ), a database (PostgreSQL or similar), and the Celery worker.
• Frontend Dockerfile builds and serves the static SPA, likely through a lightweight web server.
Main components & interactions
a. Frontend SPA (Vue3 + Vite)
– Runs in the user’s browser, served by a container.
– Consumes REST endpoints of auth_service and user_service.
b. auth_service
– Exposes /api/v1/auth/* endpoints (login, signup, token refresh).
– Reads shared/config/settings for environment, JWT settings.
– Uses shared/utils/security for token creation/validation.
– Persists authentication data in the database via shared/models.
– Publishes asynchronous events (e.g., “user_created”) to the message broker.
c. user_service
– Exposes /api/v1/users/* endpoints (profile, preferences).
– Reads shared/config/settings for DB credentials.
– Uses shared/models/user_schemas for validation.
– Subscribes to events from auth_service via message broker.
d. Celery Worker
– Consumes tasks from the broker (e.g., send email, audit logs).
– Tasks defined in celery_worker/tasks.py.
– Uses shared/utils/celery_client to connect and shared/models for payload schemas.
e. Database
– A single or multiple DB instances (PostgreSQL).
– Both auth_service and user_service connect to it (separate schemas or one schema).
f. Message Broker
– Redis or RabbitMQ used by both services and the Celery worker for asynchronous messaging.
Architectural patterns and design principles
• Microservices: each backend service is autonomous with its own Dockerfile.
• Shared-library pattern: common logic (config, models, exceptions, utilities) extracted into backend/shared and reused via relative imports or packaging.
• Asynchronous, event-driven communication: Celery + broker for deferred jobs.
• RESTful API design with versioned endpoints (/api/v1/…).
• Containerization & orchestration: Docker + Docker-Compose ensures replicable environments.
• Clear separation of concerns: frontend vs. backend vs. background processing.