Architecture Overview
High-Level View
Section titled “High-Level View”The API repository is the backend service for Agora Tutoring. It exposes a GraphQL endpoint, processes business logic, connects to storage/services, and serves webhook endpoints.
Users / Frontend (Next.js) | v GraphQL API (Express + Apollo) | +--> MongoDB (core app data) +--> Redis (pub/sub, real-time support) +--> Firebase (auth-related services) +--> Stripe (billing webhooks) +--> SendGrid / Email services +--> Jira webhook integrationRuntime Entry Points
Section titled “Runtime Entry Points”index.js: starts the service, initializes database, binds to configured port.src/server.js: creates HTTP server, GraphQL endpoint, WebSocket subscriptions, and webhook routes.
Main Backend Layers
Section titled “Main Backend Layers”src/api/: GraphQL schema, modules, resolvers, directives, scalars, and loaders.src/database/: models, validators, plugins, and DB startup logic.src/helpers/+src/utilities/: reusable helper and utility logic.src/webhooks/: inbound handlers for external systems.
Why this structure works
Section titled “Why this structure works”- Domain modules keep GraphQL features grouped by business area.
- Loaders reduce repeated DB reads and improve resolver performance.
- Plugins centralize model-side behavior (e.g., related updates, hooks).
- Separate webhook handlers keep third-party logic isolated from core API paths.