How nahyan0077/eduverse-backend works
Eduverse is a microservices backend organized around a shared architectural pattern: each service has presentation controllers/routes, application use cases, domain entities/interfaces, and infrastructure adapters for MongoDB, Kafka, sockets, and external APIs. That structure is consistent across the repo and is the main diagram boundary to capture.
The request entrypoint is the api-gateway. It exposes the public HTTP surface, applies rate limiting, and proxies requests to the downstream services. It also contains boot-time config/environment wiring, so the diagram should show it as the single front door rather than a business-capability service.
auth-service is responsible for authentication and account lifecycle. It contains login, signup, Google auth, logout, OTP verification, password reset, and user lookup flows. It uses MongoDB for user and OTP persistence, bcrypt/JWT utilities for credential handling, and Kafka producers/consumers to fan out account-related events such as verification mail, forgot-password flow, user creation, and instructor moderation events.
user-service is the administrative/user-management domain. Its use cases focus on creating users, listing students and instructors, updating profiles, blocking/unblocking users, and approving/rejecting instructor applications. It persists users in MongoDB and publishes/consumes Kafka events for moderation and profile synchronization, so it acts as the platform’s central user-state coordinator outside of authentication.
course-service is the largest domain slice and covers course catalog and learning operations. It owns categories, courses, assessments, enrollments, reviews, results, and certificate generation. It uses MongoDB for all course-domain aggregates and listens to Kafka events such as course purchase success, user creation, and instructor verification/rejection to keep course access and teaching status in sync. The certificate assets/fonts in the repo indicate server-side certificate generation is part of this service.
payment-service handles monetization and payment-session orchestration. It supports one-time course payments and subscription payments, stores payment/session records in MongoDB, and integrates with Stripe via its webhook controller and session/payment use cases. It emits Kafka events like course purchase success and chat subscription success, which are the key downstream triggers for entitlement updates in other services.
chat-service manages messaging and real-time communication. It includes chat threads, messages, unread counts, user presence/last-seen style updates, and a socket bootstrap, which makes it the only service with a WebSocket-style runtime boundary. MongoDB stores chat/message state, while Kafka consumers keep chat subscriptions and user-created state synchronized with other services.
notification-service is the asynchronous outbound messaging layer. It consumes Kafka events for forgot-password, instructor verification/rejection, and user updates, then sends mail through SendGrid helpers. This service is intentionally narrow: it does not own core business state, only notification delivery and email-template orchestration.
Kafka is the main integration bus across the platform. Synchronous HTTP is used for user-facing API calls through the gateway, while cross-service side effects are propagated by Kafka producers/consumers. The important event flows to capture are account verification/reset, instructor approval workflow, purchase success leading to enrollment/access updates, and chat subscription propagation.
MongoDB is the primary persistence technology in each business service, but each service owns its own data model and repository layer. There is no shared database module across services; instead, the repo is structured for service-level data ownership and isolation, which is a key architectural boundary.
The deployment story is containerized and cloud-native. Every service has its own Dockerfile, there are GitHub Actions build workflows per service, and Kubernetes manifests under manifests/k8s define deployments plus an ingress controller. Local Kafka development is supported via kafka-dev/docker-compose.yaml, reinforcing that Kafka is a required platform dependency in both local and production setups.
A useful architecture diagram should therefore show: client traffic entering the API gateway; the gateway routing to the six backend services; MongoDB per service; Kafka as the shared async backbone between auth, user, course, payment, chat, and notification; and external providers for Stripe and SendGrid. The only real-time path to highlight separately is chat service socket handling, since it bypasses the ordinary request/response flow.
Main entry points: docker-compose.yaml Kafka bus · server.ts API Gateway · createPayment.ts Payment store · createUser.ts Auth store
Components 24
Platform
Shared infrastructure and deployment layer
- Clients · Browsers or API consumers calling the public backend
- Kafka bus · Shared async backbone for cross-service side effects
kafka-dev/docker-compose.yaml - MongoDB · Service-owned MongoDB persistence across the platform
- Stripe · External billing and webhook provider
- SendGrid · External email delivery provider
API Gateway
Public HTTP entrypoint and request proxy
- API Gateway · Public HTTP surface, rate limiting, config wiring, and downstream proxying
api-gateway/src/presentation/server.ts
Auth Service
Authentication and account lifecycle
- Auth API · Login, signup, OTP, password reset, Google auth, logout, and user lookup flows
auth-service/src/presentation/server.ts - Auth core · Credential handling, verification, and account lifecycle orchestration
auth-service/src/application/useCases/loginUserUseCase.ts - Auth store · User and OTP persistence plus account-related Kafka producers/consumers
auth-service/src/infrastructure/database/mongodb/repositories/createUser.ts
User Service
Administrative user-state management
- User API · User listing, profile updates, blocking, and instructor moderation
user-service/src/presentation/server.ts - User core · Administrative user management and moderation workflows
user-service/src/application/useCases/createUserUseCase.ts - User store · User persistence and moderation/profile synchronization events
user-service/src/infrastructure/database/mongo/respositories/createUser.ts
Course Service
Catalog, enrollment, assessment, and certificates
- Course API · Catalog, assessment, enrollment, review, result, and certificate routes
course-service/src/presentation/server.ts - Course core · Catalog, learning, assessment, and certificate generation logic
course-service/src/application/useCases/course/createCourseUseCase.ts - Course store · Course-domain persistence plus event-driven access synchronization
course-service/src/infrastructure/database/mongodb/repositories/course/createCourse.ts
Payment Service
Payment-session and monetization orchestration
- Payment API · Payment, session, subscription, and Stripe webhook controllers
payment-service/src/presentation/server.ts - Payment core · Session creation, payment updates, and subscription orchestration
payment-service/src/application/useCases/createSessionUseCase.ts - Payment store · Payment/session persistence and purchase-success event publishing
payment-service/src/infrastructure/database/mongo/repositories/createPayment.ts
Chat Service
Messaging and realtime communication
- Chat API · Chat thread, message, unread-count, and presence-related routes
chat-service/src/presentation/server.ts - Socket layer · WebSocket-style bootstrap for realtime chat communication
chat-service/src/_boot/socket.ts - Chat core · Thread, message, unread-count, and last-seen coordination
chat-service/src/application/useCases/createChatUseCase.ts - Chat store · Chat/message persistence and synchronization consumers
chat-service/src/infrastructure/database/mongodb/repositories/createChat.ts
Notification Service
Outbound email delivery
- Notification API · Minimal HTTP surface for notification-related actions
notification-service/src/presentation/server.ts - Mail worker · Kafka-driven email templates and SendGrid delivery
notification-service/src/infrastructure/services/mail/sendVerificationMail.ts
Connections 39
- Clients → API Gateway: HTTP · Client traffic enters through the gateway
- API Gateway → Auth API: route · Gateway proxies auth requests
- API Gateway → User API: route · Gateway proxies user-management requests
- API Gateway → Course API: route · Gateway proxies course requests
- API Gateway → Payment API: route · Gateway proxies billing requests
- API Gateway → Chat API: route · Gateway proxies chat HTTP requests
- API Gateway → Notification API: route · Gateway proxies notification-related requests
- Auth API → Auth core: uses · Controllers invoke authentication use cases
- Auth core → Auth store: persist/event · Auth logic writes users/OTP data and emits account events
- Auth store → MongoDB: mongo · Auth service owns its MongoDB collections
- Auth store → Kafka bus: publish/consume · Auth service exchanges account and moderation events
- User API → User core: uses · Controllers invoke user-management use cases
- User core → User store: persist/event · User logic updates state and emits moderation/profile events
- User store → MongoDB: mongo · User service owns its MongoDB collections
- User store → Kafka bus: publish/consume · User service synchronizes state through Kafka
- Course API → Course core: uses · Controllers invoke course-domain use cases
- Course core → Course store: persist/event · Course logic stores aggregates and reacts to platform events
- Course store → MongoDB: mongo · Course service owns its MongoDB collections
- Course store → Kafka bus: consume · Course service listens for purchases and user/instructor updates
- Payment API → Payment core: uses · Controllers invoke payment and subscription use cases
- Payment core → Payment store: persist/event · Payment logic records sessions and emits purchase events
- Payment store → MongoDB: mongo · Payment service owns its MongoDB collections
- Payment store → Stripe: webhook/api · Payment service integrates with Stripe
- Payment store → Kafka bus: publish · Payment success events fan out to other services
- Chat API → Chat core: uses · Chat HTTP controllers invoke message/thread use cases
- Chat API → Socket layer: bootstrap · Chat service boots a realtime socket runtime
- Socket layer → Chat core: events · Realtime messages flow through chat use cases
- Chat core → Chat store: persist/event · Chat logic stores messages and unread counts
- Chat store → MongoDB: mongo · Chat service owns its MongoDB collections
- Chat store → Kafka bus: consume · Chat service consumes subscription and user lifecycle events
- Notification API → Mail worker: trigger · Notification surface delegates to mail delivery workflows
- Mail worker → SendGrid: email · Notification service sends mail through SendGrid
- Mail worker → Kafka bus: consume · Notification service reacts to forgot-password and instructor events
- Kafka bus → Auth store: events · Account and verification flows propagate through Kafka
- Kafka bus → User store: events · Moderation and user sync propagate through Kafka
- Kafka bus → Course store: events · Course access and instructor state stay synchronized via Kafka
- Kafka bus → Payment store: events · Purchase-success events originate from payment flows
- Kafka bus → Chat store: events · Chat subscription and user-created events propagate via Kafka
- Kafka bus → Mail worker: events · Notification service consumes asynchronous messaging events