# noob-master-cell/esn architecture

> Architecture diagram of the GitHub repository noob-master-cell/esn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/noob-master-cell/esn
- Repository: https://github.com/noob-master-cell/esn

## Overview

##### Project type and purpose
- This is a full-stack event management platform (“ESN Event Management Platform”).
- Frontend is a React/TypeScript single-page application (Vite + Apollo Client).
- Backend is a monolithic GraphQL API built with NestJS, Prisma (PostgreSQL), Redis, and Auth0 for authentication.
- Docker-based development and deployment with docker-compose for PostgreSQL, Redis, backend, and frontend containers.

##### File structure
- Top-level folders:
- backend – NestJS GraphQL server, Prisma schema & migrations, custom scripts, PM2/Ecosystem config, load-test definitions.
- frontend – React (TSX) app organized by pages, components, hooks, GraphQL queries, Vite config, Tailwind/CSS, Dockerfile.
- docs – markdown docs for API, DB, dev workflow, deployment, maintenance.
- docker-compose*.yml – defines multi-container development and prod stacks.
- scripts – shell scripts for deployment, health checks, docker builds.
- Patterns & configurations:
- NestJS modules by feature (auth, users, events, comments, feedback, etc.).
- GraphQL resolvers → services → Prisma ORM → PostgreSQL.
- Redis used for caching, rate-limiting (throttler), and pub/sub (realtime comments/feedback).
- Auth0 guard + role guard for RBAC.
- Cloudinary integration for image uploads.

##### README for additional insights
- Confirms GraphQL API, Redis caching, rate limiting, role-based access control, Auth0.
- Highlights Docker-based local dev and production deployment.
- Docs folder references architecture-relevant info (DATABASE.md, DEPLOYMENT.md).

##### Elements
- Clear rectangular blocks for each component (e.g., “React SPA”, “NestJS GraphQL Server”, “PostgreSQL”, “Redis”, “Auth0”, “Cloudinary”).
- Green = User-facing (Frontend)
- Blue = Application logic (Backend GraphQL)
- Orange = Data stores (DB, Cache)
- Gray = External services

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (User-facing)" 
        direction TB
        Browser["Browser"]:::frontend
        StaticServer["Static Server (NGINX/Vite)"]:::infra
        ReactSPA["React SPA"]:::frontend
        ApolloClient["Apollo Client"]:::frontend
        GraphQLTypes["GraphQL Queries & Types"]:::frontend
        PagesRouting["Pages & Routing"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend GraphQL API" 
        direction TB
        BackendApp["NestJS GraphQL Server"]:::backend
        subgraph "Feature Modules"
            direction TB
            AuthModule["Auth Module"]:::backend
            UsersModule["Users Module"]:::backend
            EventsModule["Events Module"]:::backend
            CommentsModule["Comments Module"]:::backend
            FeedbackModule["Feedback Module"]:::backend
            RegistrationsModule["Registrations Module"]:::backend
            CalendarModule["Calendar Module"]:::backend
            AdminModule["Admin Module"]:::backend
        end
        Guards["Auth0 & RBAC Guards"]:::backend
        PrismaModule["Prisma ORM Module"]:::backend
        RedisModule["Redis Caching & Pub/Sub"]:::backend
        CloudinaryModule["Cloudinary Integration"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores" 
        direction TB
        PostgreSQL["PostgreSQL"]:::datastore
        Redis["Redis"]:::datastore
    end

    %% External Services
    subgraph "External Services" 
        direction TB
        Auth0["Auth0"]:::external
        Cloudinary["Cloudinary"]:::external
    end

    %% Infrastructure
    subgraph "Infrastructure" 
        direction TB
        DockerCompose["Docker Compose"]:::infra
    end

    %% Relationships
    Browser -->|"HTTP(S) Request"| StaticServer
    StaticServer -->|"Serves SPA"| ReactSPA
    ReactSPA -->|"GraphQL Requests"| ApolloClient
    ApolloClient -->|"queries/mutations"| BackendApp

    BackendApp -->|"uses"| AuthModule
    BackendApp -->|"uses"| UsersModule
    BackendApp -->|"uses"| EventsModule
    BackendApp -->|"uses"| CommentsModule
    BackendApp -->|"uses"| FeedbackModule
    BackendApp -->|"uses"| RegistrationsModule
    BackendApp -->|"uses"| CalendarModule
    BackendApp -->|"uses"| AdminModule

    BackendApp -->|"guards via"| Guards
    BackendApp -->|"ORM calls"| PrismaModule
    BackendApp -->|"cache/pubsub"| RedisModule
    BackendApp -->|"uploads"| CloudinaryModule

    Guards -->|"OAuth2 token validation"| Auth0
    PrismaModule -->|"SQL via Prisma Client"| PostgreSQL
    RedisModule -->|"GET/SET, Pub/Sub"| Redis
    CloudinaryModule -->|"Image upload API"| Cloudinary

    %% Docker Compose
    DockerCompose -->|“container”| StaticServer
    DockerCompose -->|“container”| BackendApp
    DockerCompose -->|“container”| PostgreSQL
    DockerCompose -->|“container”| Redis

    %% Click Events
    click ReactSPA "https://github.com/noob-master-cell/esn/blob/main/frontend/src/main.tsx"
    click ApolloClient "https://github.com/noob-master-cell/esn/blob/main/frontend/src/lib/apollo.ts"
    click GraphQLTypes "https://github.com/noob-master-cell/esn/tree/main/frontend/src/graphql"
    click PagesRouting "https://github.com/noob-master-cell/esn/blob/main/frontend/src/routes.tsx"

    click BackendApp "https://github.com/noob-master-cell/esn/blob/main/backend/src/main.ts"
    click AuthModule "https://github.com/noob-master-cell/esn/tree/main/backend/src/auth"
    click UsersModule "https://github.com/noob-master-cell/esn/tree/main/backend/src/users"
    click EventsModule "https://github.com/noob-master-cell/esn/tree/main/backend/src/events"
    click CommentsModule "https://github.com/noob-master-cell/esn/tree/main/backend/src/comments"
    click FeedbackModule "https://github.com/noob-master-cell/esn/tree/main/backend/src/feedback"
    click RegistrationsModule "https://github.com/noob-master-cell/esn/tree/main/backend/src/registrations"
    click CalendarModule "https://github.com/noob-master-cell/esn/tree/main/backend/src/calendar"
    click AdminModule "https://github.com/noob-master-cell/esn/tree/main/backend/src/admin"

    click Guards "https://github.com/noob-master-cell/esn/blob/main/backend/src/auth/guards/auth0.guard.ts"
    click PrismaModule "https://github.com/noob-master-cell/esn/blob/main/backend/src/prisma/prisma.module.ts"
    click RedisModule "https://github.com/noob-master-cell/esn/blob/main/backend/src/common/pubsub.module.ts"
    click CloudinaryModule "https://github.com/noob-master-cell/esn/blob/main/backend/src/cloudinary/cloudinary.module.ts"
    click DockerCompose "https://github.com/noob-master-cell/esn/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#ccffcc,stroke:#006600,color:#000000;
    classDef backend  fill:#cce0ff,stroke:#004080,color:#000000;
    classDef datastore fill:#ffe0b3,stroke:#cc8400,color:#000000;
    classDef external fill:#e0e0e0,stroke:#808080,color:#000000;
    classDef infra    fill:#f2ccff,stroke:#800080,color:#000000;
```
