# huseyinkaraman/jobberapp architecture

> Architecture diagram of the GitHub repository huseyinkaraman/jobberapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/huseyinkaraman/jobberapp
- Repository: https://github.com/huseyinkaraman/jobberapp

## Overview

##### Project Type and Purpose
- This is a backend-only, microservices-based Node.js/TypeScript system.
- It provides API routing (gateway), user authentication/authorization (auth-service), and email/notification handling (notification-service).
- Shared code (09-jobber-shared) is used across services.
- Infrastructure is containerized (Docker) and managed via docker-compose.

##### Core Components
a. API Gateway Service (1-gateway-service)
- Exposes REST endpoints for auth, current user info, and health checks.
- Routes client requests to underlying services or shared APIs.
- Integrates with Elasticsearch for search/logging.
b. Auth Service (3-auth-service)
- Manages user signup, signin, password reset, email verification.
- Uses a persistent database (configured in src/config/database.ts).
- Publishes events to RabbitMQ (src/queues/auth.producer.ts).
- Indexes/auth data in Elasticsearch.
- Stores media to Cloudinary.
c. Notification Service (2-notification-service)
- Connects to RabbitMQ queue (src/queues/connection.ts) to consume auth and order events.
- Renders email templates (EJS) for different scenarios (password reset, order updates, OTPs).
- Sends emails via a mail transport (src/queues/service/mail.transport.ts).
- Can be extended to SMS or push notifications.
d. Shared Library (09-jobber-shared)
- Common types, interfaces, DTOs across services.
e. Infrastructure
- RabbitMQ message broker
- Elasticsearch cluster
- Relational database (Auth Service)
- Cloudinary (media hosting)
- SMTP/Email provider
- Kibana (logging UI)
- Docker + docker-compose defines multi-container topology

##### Interactions & Data Flows
- Client → API Gateway → Auth Service (via internal HTTP)
- Auth Service writes to its DB & Elasticsearch → publishes “user.created”/“password.reset” events to RabbitMQ
- Notification Service consumes events → loads appropriate EJS templates → invokes SMTP/email provider → sends emails
- API Gateway logs or queries Elasticsearch for analytics/monitoring
- Kibana reads from Elasticsearch for logs/visualization

##### Architectural Patterns & Principles
- Microservices: independently deployable services by business capability
- API Gateway pattern: single ingress point for routing, auth, rate-limiting
- Event-driven Messaging: RabbitMQ decouples producer (auth) from consumer (notification)
- Shared library for DRY code
- Infrastructure as Code: Dockerfiles + docker-compose.yml for consistent environments

g. Off to the side, show Kibana connected to Elasticsearch.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client"]:::external
    subgraph "API Layer"
        APIGW["API Gateway"]:::gateway
    end
    subgraph "Application Layer"
        Auth["Auth Service"]:::auth
        Notif["Notification Service"]:::notif
    end
    subgraph "Messaging Layer"
        Rabbit["RabbitMQ"]:::infra
    end
    subgraph "Data Layer"
        AuthDB["Auth DB (SQL)"]:::infra
        ES["Elasticsearch"]:::infra
    end
    subgraph "External Services"
        Cloudinary["Cloudinary"]:::external
        SMTP["SMTP/Email Provider"]:::external
        Kibana["Kibana"]:::external
    end
    Shared["Shared Library"]:::shared

    Client -->|"HTTP request"| APIGW
    APIGW -->|"Auth API call"| Auth
    APIGW -->|"Query logs"| ES
    Auth -->|"Read/Write"| AuthDB
    Auth -->|"Read/Write"| ES
    Auth -->|"Publish user.* events"| Rabbit
    Rabbit -->|"Consume user.* events"| Notif
    Auth -->|"Upload media"| Cloudinary
    Notif -->|"Send emails"| SMTP
    Kibana -->|"Visualize logs"| ES

    Shared -.-> APIGW
    Shared -.-> Auth
    Shared -.-> Notif

    click APIGW "https://github.com/huseyinkaraman/jobberapp/blob/main/server/1-gateway-service/src/server.ts"
    click Auth "https://github.com/huseyinkaraman/jobberapp/blob/main/server/3-auth-service/src/server.ts"
    click Notif "https://github.com/huseyinkaraman/jobberapp/blob/main/server/2-notification-service/src/server.ts"
    click Shared "https://github.com/huseyinkaraman/jobberapp/tree/main/server/09-jobber-shared"
    click Kibana "https://github.com/huseyinkaraman/jobberapp/blob/main/kibana.yml"

    classDef gateway fill:#add8e6,stroke:#333,stroke-width:1px
    classDef auth fill:#90ee90,stroke:#333,stroke-width:1px
    classDef notif fill:#ffa500,stroke:#333,stroke-width:1px
    classDef infra fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef external fill:#f0e68c,stroke:#333,stroke-width:1px
    classDef shared fill:#f5f5f5,stroke:#333,stroke-width:1px
```
