# krutikgadhiya/sgp-event-management architecture

> Architecture diagram of the GitHub repository krutikgadhiya/sgp-event-management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krutikgadhiya/sgp-event-management
- Repository: https://github.com/krutikgadhiya/sgp-event-management

## Overview

##### Project Type and Purpose
- This is a full-stack university event-management system (“sgp-event-management”) comprised of:
- A ReactJS single-page application (SPA) as the front end
- A Node.js + Express backend as a RESTful API
- MongoDB as the data store
- Cloudinary for image storage
- Google OAuth for authentication
- PDF-generation modules for pre/post event reports

##### File Structure
- Top-level folders:
- client/ — React app, components, Redux reducer, build artifacts
- server/ — Express server, routes, middleware, Mongoose models, PDF logic
- client/src/components contains all UI screens (Dashboard, CreateEvent, SignIn, charts, PDF previews).
- client/src/reducers holds Redux state logic (userReducer).
- server/routes defines REST endpoints: auth, postEvent, preEvent, chartDetails, createPdf, getCount, updateDelete.
- server/models defines Mongoose schemas: user, postEvent, preEvent.
- server/middleware/requireLogin enforces JWT/session protection.
- server/documents contains PDF-building logic (fullPDF.js).

##### README Insights
- Features: CRUD on events, PDF generation (pre + post), analytics dashboard with charts.
- Stack: ReactJS, NodeJS/Express, MongoDB, Cloudinary, Google sign-in.

##### Main Components & Interactions
a. User Browser (React SPA)
– Renders UI, manages state with Redux
– Hosts components: Login, Dashboard, Event forms, Charts, PDF preview
b. API Server (Node/Express)
– Exposes REST endpoints (/auth, /preEvent, /postEvent, /chartDetails, /createPdf, /getCount, /updateDelete)
– Contains middleware for auth (requireLogin) and controllers that use Mongoose models
– Contains PDF generator module
c. Database (MongoDB)
– Stores user records, preEvent, postEvent documents
d. Cloudinary
– Stores event images uploaded by users
e. External Auth (Google OAuth)
– Used during sign-in/sign-up
f. PDF Engine
– Combines preEvent + postEvent data into result.pdf (server/documents/fullPDF.js)

Data flows:
1. User → React UI → dispatch Redux action → HTTP request
2. React → Express route → requireLogin middleware → controller → Mongoose → MongoDB
3. Express may call Cloudinary SDK for uploads
4. PDF endpoints → server/documents → PDF library → result.pdf → served back
5. React fetches chart data → Express → MongoDB → sends metrics → ChartJS components render

##### Architectural Patterns & Principles
- Client-server separation
- RESTful API design
- MVC-style modeling: routes → controllers → models
- Redux for state management in the front end
- Middleware for cross-cutting concerns (auth)
- Single Responsibility: separate modules for PDF logic, auth, CRUD, analytics

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "React SPA"
        direction TB
        Index["index.js"]:::frontend
        App["App.js"]:::frontend
        Components["components"]:::frontend
        Reducer["userReducer.js"]:::frontend
    end

    %% Backend Layer
    subgraph "Express API Server"
        direction TB
        Server["server.js"]:::backend
        Conn["conn.js"]:::backend
        Middleware["requireLogin.js"]:::backend
        AuthRoute["auth.js"]:::backend
        PreRoute["preEvent.js"]:::backend
        PostRoute["postEvent.js"]:::backend
        ChartRoute["chartDetails.js"]:::backend
        PdfRoute["createPdf.js"]:::backend
        CountRoute["getCount.js"]:::backend
        UpdateRoute["updateDelete.js"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        Mongo["MongoDB"]:::datastore
        Cloudinary["Cloudinary"]:::datastore
    end

    %% External Services
    Google["Google OAuth"]:::external

    %% Utility Modules
    subgraph "Utilities"
        direction TB
        PdfModule["fullPDF.js"]:::util
        PdfIndex["index.js (docs)"]:::util
    end

    %% Connections
    Index -->|"renders"| App
    App -->|"uses UI components"| Components
    App -->|"dispatches Redux actions"| Reducer
    App -->|"HTTP requests (REST)"| Server

    Server -->|"establishes connection"| Conn
    Server -->|"enforces auth"| Middleware
    Server -->|"POST /auth/google"| AuthRoute
    Server -->|"POST /preEvent"| PreRoute
    Server -->|"POST /postEvent"| PostRoute
    Server -->|"GET /chartDetails"| ChartRoute
    Server -->|"POST /createPdf"| PdfRoute
    Server -->|"GET /getCount"| CountRoute
    Server -->|"PUT/DELETE /updateDelete"| UpdateRoute

    AuthRoute -->|"verifies tokens"| Google
    Server -->|"CRUD operations"| Mongo
    Server -->|"uploads/downloads"| Cloudinary

    PdfRoute -->|"invokes PDF generator"| PdfModule
    PdfModule -->|"exports utilities"| PdfIndex
    PdfRoute -->|"returns PDF"| App

    ChartRoute -->|"fetch metrics"| Mongo
    PreRoute -->|"manage preEvent docs"| Mongo
    PostRoute -->|"manage postEvent docs"| Mongo
    CountRoute -->|"count documents"| Mongo
    UpdateRoute -->|"modify documents"| Mongo

    %% Click Events
    click Index "https://github.com/krutikgadhiya/sgp-event-management/blob/main/client/src/index.js"
    click App "https://github.com/krutikgadhiya/sgp-event-management/blob/main/client/src/App.js"
    click Components "https://github.com/krutikgadhiya/sgp-event-management/tree/main/client/src/components"
    click Reducer "https://github.com/krutikgadhiya/sgp-event-management/blob/main/client/src/reducers/userReducer.js"
    click Server "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/server.js"
    click Conn "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/conn.js"
    click Middleware "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/middleware/requireLogin.js"
    click AuthRoute "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/routes/auth.js"
    click PreRoute "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/routes/preEvent.js"
    click PostRoute "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/routes/postEvent.js"
    click ChartRoute "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/routes/chartDetails.js"
    click PdfRoute "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/routes/createPdf.js"
    click CountRoute "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/routes/getCount.js"
    click UpdateRoute "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/routes/updateDelete.js"
    click PdfModule "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/documents/fullPDF.js"
    click PdfIndex "https://github.com/krutikgadhiya/sgp-event-management/blob/main/server/documents/index.js"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef backend fill:#c8e6c9,stroke:#388e3c,color:#1b5e20
    classDef datastore fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef external fill:#e1bee7,stroke:#8e24aa,color:#4a148c
    classDef util fill:#eeeeee,stroke:#9e9e9e,color:#424242
```
