How shareeep/campusg works
Project Type and Purpose
• CampusG is a full‑stack, microservices‑based food‑delivery platform.
• It exposes a React/Vite frontend for customers and runners, multiple Flask microservices for domain logic, and uses Kafka and Temporal for distributed‑transaction orchestration (sagas).
• External dependencies include Clerk for authentication, Stripe for payments, and an Outsystems Timer API.
Top‑Level File Structure & Architectural Patterns
• frontend/ → React + TypeScript + Vite + TailwindCSS UI
• services/ → six Flask‑based microservices:
• user‑service, order_service, payment‑service, notification‑service
• three saga‑orchestrators: create‑order (Kafka‑based), accept‑order (Temporal), complete‑order (Temporal)
• kafka/ → topic definitions for event bus
• temporal/ → server configuration for Temporal workflows
• grafana/ → monitoring dashboards provisioning
• docker-compose.yml spins up all services, Kafka, Temporal, databases, Grafana
Main Components & Their Responsibilities
A. Client Layer
• Web App (React/Vite): UI for placing, accepting, tracking orders
B. API/Orchestration Layer
• Create‑Order Saga (Flask + Kafka): orchestrates order creation, payment authorization, timer setup
• Accept‑Order Saga (Temporal): orchestrates runner acceptance and timer notifications
• Complete‑Order Saga (Temporal): orchestrates delivery completion, payout, final status update
C. Core Domain Services
• User Service (Flask + PostgreSQL): manages profiles, Clerk auth, Stripe customer/connect accounts
• Order Service (Flask + PostgreSQL): order lifecycle CRUD and status transitions
• Payment Service (Flask + PostgreSQL): Stripe integration for payments/refunds/payouts
• Notification Service (Flask + PostgreSQL + Kafka consumer): logs domain events for observability
D. Infrastructure
• Kafka Cluster: event bus for Create‑Order Saga commands/events and Notification logging
• Temporal Server: durable workflow engine for Accept‑Order & Complete‑Order sagas
• PostgreSQL Databases: one per service / orchestrator for state persistence
• Grafana: monitoring dashboards
• External APIs: Clerk (OAuth), Stripe (payments), Outsystems Timer (HTTP timer API)
Component Interactions & Data Flows
• Frontend → HTTP call → Create‑Order Saga API
→ emits Kafka “CreateOrder” command
→ Order Service (create order)
→ User Service (get payment info)
→ Payment Service (authorize payment)
→ Saga updates order status, calls Timer Service to start countdown
• Frontend → HTTP call → Accept‑Order Saga
→ Temporal worker invokes Order Service (assign runner)
→ HTTP → Timer Service (stop timer)
• Frontend → HTTP call → Complete‑Order Saga
→ Temporal worker invokes Order Service (mark delivered/completed)
→ invokes User Service (fetch runner’s connect ID)
→ invokes Payment Service (fetch payment ID & payout)
• All services emit domain events to Kafka; Notification Service consumes and pushes metrics to Grafana.
Architectural Patterns & Principles
• Microservices: single‑responsibility services, separate codebases and data stores
• Saga orchestration: reliable distributed transactions via choreography (Kafka) and orchestration (Temporal)
• API‑first design: each service exposes REST/Swagger APIs (api-specs/)
• Database per service: ensures loose coupling and independent scaling
• Event‑driven: Kafka topics as central message bus
• Durable workflows: Temporal for long‑running, compensating workflows
Essential Elements
• Component labels (with technology stacks, e.g., “Payment Service (Flask/SQLAlchemy)”)