How oniichannikita/trailveil works
Project type and purpose
• This is a full‑stack, containerized microservices e‑commerce platform.
• Key functions: user management (auth, users), product catalog (product), ordering (order), reviews (review), admin console (admin), real‑time chat (chat), plus a central API gateway and a React frontend (trailveil_react).
• Kubernetes manifests (ingress.yaml, deployment.yaml, service.yaml, nginx-pod.yaml) and a docker‑compose.yml orchestrate multi‑service deployment.
File structure
• Top‑level microservice folders:
• admin, auth, users, product, order, review – each is a Django project with one “_app” handling models, serializers, views, migrations.
• chat – a Python service with FastAPI (main.py), SQLAlchemy (database.py/models.py), Celery worker for asynchronous tasks.
• gateway – a Django “api gateway” serving as the single entry point for frontend, routing to downstream services.
• trailveil_react – the React SPA (components, pages, services, store, hooks) that consumes the gateway’s REST and WebSocket endpoints.
• Dockerfiles in each service directory and a top‑level docker-compose.yml define containers; Kubernetes YAMLs declare pods, services, ingress rules.
• init_scripts holds SQL scripts for initializing the Postgres instance (psg).
README
• Minimal README shows how to connect to Postgres:
docker exec -it psg psql -U postgres
• Implication: a central Postgres container (psg) serves all Django apps.
Main components and interactions
a. Components
• Client (Browser)
• React SPA (trailveil_react)
• API Gateway service (gateway)
• Microservices: auth, users, product, order, review, admin, chat (+ chat’s Celery worker)
• Postgres database
• Message broker (e.g., Redis or RabbitMQ) for Celery tasks
• Kubernetes cluster with NGINX Ingress
b. Relationships and data flow
• Browser → HTTP/HTTPS via Ingress → API Gateway
• Gateway routes REST calls to respective microservices (auth, users, product, order, review, admin)
• Chat interactions use a WebSocket channel exposed by gateway → chat service
• Microservices read/write to Postgres over TCP
• chat service enqueues tasks to the message broker; Celery worker consumes tasks, updates DB or publishes events
• Kubernetes Ingress directs external traffic to gateway and to static asset service for React (or served via CDN)
c. Architectural patterns and principles
• Microservices pattern: each business domain in its own deployable unit
• API Gateway pattern: single entry point, cross‑cutting concerns (authentication, rate limiting) centralized
• Asynchronous messaging: Celery for long‑running tasks (chat notifications, background jobs)
• Containerization and orchestration: Docker + Kubernetes
• 12‑factor app principles: separate configurations (Dockerfiles, env vars), backing services as attached resources
d. Technologies and frameworks
• Django + Django REST Framework for most services
• FastAPI or similar (chat) + Celery for asynchronous processing
• React + Redux/RTK Query on the frontend
• Postgres as the primary relational datastore
• Redis or RabbitMQ as Celery broker (infer from celery_worker.py)
• NGINX Ingress Controller in Kubernetes
Detail level
• K8s objects: Ingress at the edge, Service abstractions in front of each Deployment.
• Seven microservices plus chat and admin, the gateway, and the React SPA.
• If space allows, indicate the SQL init scripts hooking into the Postgres container at startup.