# ganeshmohta/event_managment architecture

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

- Interactive diagram: https://gitdiagram.com/ganeshmohta/event_managment
- Repository: https://github.com/ganeshmohta/event_managment

## Overview

##### Project type and its purpose
- This is a full-stack web application
- Front-end: React SPA built with Vite, using Redux for client-side state
- Back-end: Node.js + Express.js REST API, MVC pattern (Controllers, Models), with authentication middleware
- Database: MongoDB (accessed via Mongoose schemas)
- External service: Payment gateway integration in paymentController

##### Break down the main components
A. Client (Browser) / UI Layer
- Vite dev server or build artifacts served from index.html + public folder
- React components under src/components and src/Pages
- Redux store and slices (src/Redux/store.js, eventsSlice.js)
- Validation components for Login/Register
B. API Layer (HTTP Server)
- Express app (Backened/index.js)
- Authentication middleware (Backened/middleware/auth.js)
- Route definitions (Backened/Routes/*.js)
C. Business-Logic Layer
- Controllers (Backened/Controller/*.js) implementing user, post, registration, payment logic
D. Data-Persistence Layer
- Mongoose models/schemas (Backened/Model/*.js)
- MongoDB instance
E. External Services
- Payment gateway (Stripe/PayPal or similar) invoked by paymentController

##### Interactions & data flow
1. User → React UI (clicks, form submits)
2. React components → Redux actions → async thunks or sagas → HTTP calls via fetch/axios
3. HTTP request → Express routes → auth middleware (if protected) → appropriate controller
4. Controller ↔ Mongoose model → MongoDB
5. Controller → external payment service (for payment routes) → returns confirmation → persists to DB
6. Controller → response → Express → JSON back to React
7. Redux receives response → updates store → UI re-renders

##### Architectural patterns & principles
- Front-end: Component-based architecture, unidirectional data flow (Redux)
- Back-end: MVC (Models, Views=API endpoints, Controllers)
- Separation of concerns: distinct folders for Controllers, Models, Routes, Middleware
- RESTful API design: one route file per resource (user, post, registration, payment)
- Secure endpoints via centralized auth middleware
- External service abstraction in controllers for payment

##### Final checklist
[ ] All four layers represented
[ ] Key components (Redux store, Express routes, Controllers, Schemas) shown
[ ] Middleware/auth path highlighted for protected routes
[ ] External payment integration clearly outside the DB boundary
[ ] Labels for ports/endpoints (e.g., :3000, /api/users)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)" 
        direction TB
        FEEntry["index.html / src/main.jsx\n(Vite + React)"]:::frontend
        App["src/App.jsx\n(React App)"]:::frontend
        CompDir["src/components\n(React Components)"]:::frontend
        PageComp["src/components/Pages\n(Page Components)"]:::frontend
        ValLogin["src/components/Validation/Login.jsx"]:::frontend
        ValReg["src/components/Validation/Register.jsx"]:::frontend
        Store["src/Redux/store.js\n(Redux Store)"]:::frontend
        EventsSlice["src/Redux/eventsSlice.js\n(Events Slice)"]:::frontend
    end

    %% API Server Layer
    subgraph "API Server (Express.js)" 
        direction TB
        Express["Backened/index.js\n(Express Server)"]:::backend
        AuthMW["Backened/middleware/auth.js\n(Auth Middleware)"]:::backend
        subgraph "Routes"
            direction TB
            UserRoutes["Backened/Routes/userRoutes.js"]:::backend
            RegRoutes["Backened/Routes/registrationRoutes.js"]:::backend
            PostRoutes["Backened/Routes/postRoutes.js"]:::backend
            PayRoutes["Backened/Routes/PaymentRoutes.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            UserCtrl["Backened/Controller/userController.js"]:::backend
            RegCtrl["Backened/Controller/registrationController.js"]:::backend
            PostCtrl["Backened/Controller/postController.js"]:::backend
            PayCtrl["Backened/Controller/paymentController.js"]:::backend
        end
    end

    %% Data Layer
    subgraph "Database (MongoDB)" 
        direction TB
        UserSchema["Backened/Model/userSchema.js"]:::data
        RegSchema["Backened/Model/registrationSchema.js"]:::data
        PostSchema["Backened/Model/postSchema.js"]:::data
        FeedbackSchema["Backened/Model/feedbackSchema.js"]:::data
        MongoDB["MongoDB Instance"]:::data
    end

    %% External Service
    subgraph "External Service"
        direction TB
        PaymentGateway["Payment Gateway\n(Stripe/PayPal)"]:::external
    end

    %% Client Interactions
    FEEntry --> App
    App --> CompDir
    App --> PageComp
    App --> ValLogin
    App --> ValReg
    App --> Store
    Store --> EventsSlice
    EventsSlice -->|dispatch asyncThunk /api/*| Express

    %% API Server Flow
    Express -->|use auth for protected| AuthMW
    Express --> UserRoutes
    Express --> RegRoutes
    Express --> PostRoutes
    Express --> PayRoutes

    UserRoutes --> UserCtrl
    RegRoutes --> RegCtrl
    PostRoutes --> PostCtrl
    PayRoutes --> PayCtrl

    %% Data Persistence
    UserCtrl -->|Mongoose Model| UserSchema
    RegCtrl -->|Mongoose Model| RegSchema
    PostCtrl -->|Mongoose Model| PostSchema
    PayCtrl -->|Mongoose Model| FeedbackSchema

    UserSchema --> MongoDB
    RegSchema --> MongoDB
    PostSchema --> MongoDB
    FeedbackSchema --> MongoDB

    %% External Calls
    PayCtrl -->|process payment| PaymentGateway
    PaymentGateway -->|confirmation| PayCtrl
    PayCtrl --> MongoDB

    %% Click Events
    click FEEntry "https://github.com/ganeshmohta/event_managment/blob/main/index.html"
    click FEEntry "https://github.com/ganeshmohta/event_managment/blob/main/src/main.jsx"
    click App "https://github.com/ganeshmohta/event_managment/blob/main/src/App.jsx"
    click CompDir "https://github.com/ganeshmohta/event_managment/tree/main/src/componenets"
    click PageComp "https://github.com/ganeshmohta/event_managment/tree/main/src/componenets/Pages"
    click ValLogin "https://github.com/ganeshmohta/event_managment/blob/main/src/componenets/Validation/Login.jsx"
    click ValReg "https://github.com/ganeshmohta/event_managment/blob/main/src/componenets/Validation/Register.jsx"
    click Store "https://github.com/ganeshmohta/event_managment/blob/main/src/Redux/store.js"
    click EventsSlice "https://github.com/ganeshmohta/event_managment/blob/main/src/Redux/eventsSlice.js"
    click Express "https://github.com/ganeshmohta/event_managment/blob/main/Backened/index.js"
    click AuthMW "https://github.com/ganeshmohta/event_managment/blob/main/Backened/middleware/auth.js"
    click UserRoutes "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Routes/userRoutes.js"
    click RegRoutes "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Routes/registrationRoutes.js"
    click PostRoutes "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Routes/postRoutes.js"
    click PayRoutes "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Routes/PaymentRoutes.js"
    click UserCtrl "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Controller/userController.js"
    click RegCtrl "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Controller/registrationController.js"
    click PostCtrl "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Controller/postController.js"
    click PayCtrl "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Controller/paymentController.js"
    click UserSchema "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Model/userSchema.js"
    click RegSchema "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Model/registrationSchema.js"
    click PostSchema "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Model/postSchema.js"
    click FeedbackSchema "https://github.com/ganeshmohta/event_managment/blob/main/Backened/Model/feedbackSchema.js"

    %% Styles
    classDef frontend fill:#ddeeff,stroke:#333,stroke-width:1px
    classDef backend fill:#ddffdd,stroke:#333,stroke-width:1px
    classDef data fill:#ffffcc,stroke:#333,stroke-width:1px
    classDef external fill:#eeccff,stroke:#333,stroke-width:1px
```
