How atharvapanegai/garuda-api works
Project Type and Purpose
• This is a backend service (Node.js + Express) for a real-time API health monitoring platform.
• It ingests API hit data, stores metrics, detects incidents, and sends alerts.
• It exposes REST endpoints for user/project management, API onboarding, reporting, and incident queries.
File Structure
• Top-level app.js/index.js: Bootstraps an Express server.
• config/: Configuration (DB connection, env variables).
• controllers/: Express route handlers implementing the MVC “C” layer.
• services/: Business logic, external integrations (Kafka, Redis, email).
• models/: Mongoose schemas for MongoDB collections.
• middlewares/: Authentication, prometheus-style promise wrappers, user guards.
• routes/: Route definitions mapping URLs → controllers.
• utils/: Shared utilities and error handling.
• templates/: Email templates for alerting.
README for Technical Stack & Patterns
• Node.js + Express as the core HTTP server.
• MongoDB for persistent storage of users, projects, API metrics, incidents.
• Redis for caching and quick counter lookups.
• Kafka (or RabbitMQ) as an event bus for pipelined metrics or alert streams.
• Email/SMS gateway for notifications.
• Follows a Layered / MVC pattern with a Service Layer and Event-Driven integrations.
Main Components
a. Clients
• Garuda UI (React dashboard)
• API Radar NPM Agents (deployed in user services to push metrics)
b. API Gateway / Load Balancer (optional; if deployed behind NGINX or AWS ALB)
c. Express Application
• Routes → Middlewares → Controllers → Services → Models
d. Service Integrations
• Kafka Broker (metrics queue)
• Redis Cache
• MongoDB Atlas (document store)
• Email Provider (SMTP or third-party API)
e. Caching Service (separate microservice in Garuda ecosystem)
f. External Clients (developers consuming the API)
Relationships & Data Flows
• The UI and external agents issue HTTPS requests to the Express App.
• Incoming requests pass through auth/session middlewares, then hit route controllers.
• Controllers invoke Services:
• Database Services (CRUD via Mongoose models)
• Cache Services (read/write to Redis)
• Messaging Services (produce events to Kafka)
• Alert Services (template emails → SMTP)
• Kafka consumers may feed back into the system for analytics or trigger incident detection workflows.
• On critical events, the Alert Service dispatches notification emails.
Architectural Patterns & Principles
• Layered Architecture (Presentation → Controller → Service → Data Access)
• MVC for request handling
• Service-oriented interactions with external systems
• Event-driven metrics pipeline (Kafka)
• Single Responsibility & Separation of Concerns
• Caching for performance (Redis)
• Asynchronous processing for long-running tasks (email, analytics)