How harshit27gupta/events works
Project Type and Purpose
• This is a full-stack, microservices-based events and ticketing platform.
• Frontend: React app in apps/web.
• Backend: multiple Node/Express TypeScript services (gateway, auth, events, orders) and a FastAPI ML service.
• Shared code: packages/common for logging, config, Mongo/Redis clients.
• Supporting infra: MongoDB (one DB per service), Redis, RabbitMQ.
Main Components
• Web UI (apps/web): React SPA served via Docker.
• API Gateway (services/gateway): Express BFF handling CORS, cookies → Authorization, rate limiting, circuit breaker.
• Auth Service (services/auth): signup/login/logout/refresh, session storage in Redis, JWT generation/verification.
• Events Service (services/events): CRUD operations with RBAC, payload validation, organizer ownership.
• Orders Service (services/orders): seat holds in Redis (TTL), idempotent purchase, Mongo transactions, simulated payments.
• ML Service (services/ml-service): FastAPI recommendation endpoints.
• Shared Library (packages/common): singleton clients (Mongo, Redis), config, logger, middleware.
• Datastores:
• MongoDB – separate database instance per service (users, events, orders)
• Redis – holds, idempotency cache, refresh tokens, payment intents
• RabbitMQ – message broker (for future domain events)
Relationships and Data Flow
• Browser ←→ Web UI (static assets + JS)
• Web UI –HTTP(cookies)→ API Gateway (port 8080)
• API Gateway routes:
• /api/auth/* → Auth Service
• /api/events/* → Events Service
• /api/orders/* → Orders Service
• Gateway uses in-process HTTP clients (packages/common/api.ts) and applies circuit breaker.
• Auth & Orders services read/write to Redis for tokens, holds, idempotency.
• Each service uses its own MongoDB for persistence.
• Orders service also writes to Mongo inside multi-document transaction when confirming purchase.
• ML Service (port 5000) can be called directly from UI or proxied via Gateway.
• RabbitMQ sits off-to-the-side for domain events (not yet in main flow).
Architectural Patterns & Design Principles
• BFF (Backend-for-Frontend) pattern in Gateway.
• Circuit Breaker (opossum) at gateway → Events/Orders calls.
• Singleton pattern in shared clients.
• Repository pattern for DB access in each service.
• Idempotency key pattern in Orders (safe retries).
• TTL-based seat hold pattern in Redis.
• Transactional writes with Mongo session.
• Zod schema validation for payloads.
Essential Elements to Capture
• Notes on patterns: circuit breaker at gateway, idempotency in orders, transactional writes.
• Shared code in a single block and show each service importing from it.