How adityasharma-tech/synapse works
Project Type and Purpose
• This is a Lerna-managed monorepo containing a full-stack streaming platform.
• Frontends:
• apps/auth – an Angular-Vite SPA handling user login/registration flows.
• apps/web – a React/TSX/Vite site for browsing, streaming, chat, and payments.
• Backends & Services:
• apps/server – a Node/Express REST + WebSocket API server.
• apps/queue-worker– a background worker (mail, SMS, transient tasks) using RabbitMQ.
• apps/permit-service – a microservice for permission checks or feature gating.
• Shared packages:
• drizzle-client – DB schema and migrations (Postgres via Drizzle ORM).
• rmq-client – RabbitMQ abstraction.
• zod-client – Zod validators for request/response schemas.
• lib – common error handlers, logging, async wrappers.
Key Architectural Patterns
• Micro-frontend pattern: separate Angular auth app and React main web app.
• Micro-services: distinct Node services (main API, queue worker, permit service).
• Event-driven async processing via RabbitMQ.
• Shared monorepo libraries to enforce type-safe contracts (Zod, Drizzle, shared lib).
• REST + WebSocket hybrid for real-time chat/stream controls.
• Docker + docker-compose + Nginx for local/on-premise deployment.
Main Components
a. Frontend Layer
• Angular Auth App (apps/auth)
• React Web App (apps/web)
b. API Layer (apps/server)
• REST Controllers (auth, user, admin, webhook, stream)
• WebSocket Gateway (chat, live events)
• Middleware (Auth, Rate Limit, Validation)
c. Background Processing
• RabbitMQ Broker
• Queue Worker (mail.service.ts, worker.ts)
d. Microservice: Permit Service
e. Data Layer
• Postgres DB (Drizzle migrations + client)
• Redis Cache / session store
f. External Integrations
• Cloudinary (media uploads)
• Cashfree Payments (webhook callbacks)
• SMTP / SMS gateways
Relationships & Data Flows
1. User → Angular Auth App or React Web App
2. Frontends ↔ apps/server over HTTPS for REST and wss:// for WebSocket
3. apps/server → Postgres via drizzle-client
4. apps/server ↔ Redis for caching, rate limiting, sessions
5. apps/server → RabbitMQ (publish events)
6. Queue Worker ← RabbitMQ (consume jobs: send mail/SMS, other tasks)
7. apps/server → Permit Service (HTTP/RPC) for feature checks
8. apps/server → External APIs: Cloudinary, Cashfree
9. Cashfree → apps/server/webhook endpoint → triggers DB updates / RabbitMQ
Elements
• Clear labels on each container/component (e.g., “apps/server (Express + WebSocket)”).
• Annotations for major shared libraries in the monorepo (drizzle-client, zod-client, rmq-client).
• A load-balancer or ingress (Nginx) in front of the API if depicting production infra.
• Captures front-to-back separation
• Shows real-time vs. async flows
• Highlights data persistence and caching
• Details external integrations and microservices
• Reflects the Lerna monorepo’s shared-library strategy