# harishvinayagamoorthy/crm-mern architecture

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

- Interactive diagram: https://gitdiagram.com/harishvinayagamoorthy/crm-mern
- Repository: https://github.com/harishvinayagamoorthy/crm-mern

## Overview

##### Project type and purpose
- This is a full-stack MERN CRM application.
- Frontend: React.js (Vite), deployed via Netlify.
- Backend: Node.js + Express.js REST API (JWT-secured), MongoDB database.
- Purpose: Role-based CRM with Admin and User dashboards for managing users, tickets, and tasks.

##### File structure
- Top-level files:
- index.html, vite.config.js, netlify.toml → React build & deploy config
- .env → environment variables (API base URL, JWT secret)
- src/
- main.jsx, App.jsx → React app entry & root component
- components/ → reusable UI: Dashboard, spinners, context provider, hooks, utils (ApiService)
- pages/ → route pages: SignIn, Signup, Password reset, Admin & User task/ticket pages
- routes/AppRouters.jsx → React Router setup
- No server code present in this tree; presume backend lives in a separate repo or directory.

##### README for additional insights
- MERN stack: uses MongoDB, Express.js, React.js, Node.js.
- JWT for authentication, role-based access control.
- Admin vs. User features & CRUD operations.

##### Main components
a. Frontend SPA (React.js, Vite)
- Netlify CDN hosting
- React Router → AppRouters.jsx
- ContextProvider for global state (auth & theme)
- ApiService (utils/ApiService.jsx) for HTTP calls
- UI components: Dashboards, Charts, Forms
b. Backend REST API (Node.js + Express)
- Authentication routes (signin, signup, forgot/reset password)
- User/Ticket/Task CRUD controllers
- JWT middleware for route protection & role checks
c. Database (MongoDB)
- Collections: users, tickets, tasks
d. External services
- Email service for password reset
- Netlify (frontend CI/CD)

##### Relationships & interactions
- Browser → (HTTPS) → Netlify CDN → serves React SPA
- SPA → (HTTPS JSON) → Express API endpoints
- API → (MongoDB driver) → CRUD operations on DB
- Auth flow:
- User submits credentials → API issues JWT → SPA stores in Context/localStorage
- Subsequent API calls include JWT in Authorization header
- API middleware validates JWT & enforces Admin/User roles

##### Architectural patterns & design principles
- SPA with client-side routing (React Router)
- Layered API: Controllers → Services → Data access (Repository or direct Mongoose)
- Context + custom hooks (useLogout) for state & side-effects
- Component hierarchy: common, utils, context, hooks, pages
- Responsive & modular CSS (module.css per component)

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Layer
    subgraph "User & CDN"
        Browser["User Browser"]:::external
        Netlify["Netlify CDN"]:::external
        Browser -->|"Requests SPA"| Netlify
    end

    %% Frontend Layer
    subgraph "Frontend (React SPA)"
        direction TB
        React["React SPA"]:::frontend
        React --> AppMain
        AppMain["App.jsx"]:::frontend
        AppMain --> Routers
        Routers["AppRouters.jsx"]:::frontend
        Routers --> ContextProv
        ContextProv["ContextProvider.jsx"]:::frontend
        ContextProv --> ApiSvc
        ApiSvc["ApiService.jsx"]:::frontend
        ApiSvc --> Spinner
        Spinner["Spiner.jsx"]:::frontend
        ApiSvc --> LogoutHook
        LogoutHook["useLogout.jsx"]:::frontend
    end

    Netlify -->|"Serves SPA"| React

    %% Dashboard Components
    subgraph "UI Components"
        direction TB
        AdminDash["Admin Dashboard"]:::frontend
        AdminDash --> TaskDash
        TaskDash["TaskDashboard.jsx"]:::frontend
        AdminDash --> TicketsDash
        TicketsDash["TicketsDashboard.jsx"]:::frontend
        TicketsDash --> TicketChart
        TicketChart["TicketAreaChart.jsx"]:::frontend
        AdminDash --> Progress
        Progress["CircleProgressBar.jsx"]:::frontend

        UserDash["User Dashboard"]:::frontend
        UserDash --> UserTaskDash
        UserTaskDash["UserTaskDashboard.jsx"]:::frontend
        UserDash --> UserTicketsDash
        UserTicketsDash["UserTicketsDashoard.jsx"]:::frontend

        Cards["Dashboard Cards"]:::frontend
    end

    AppMain --> AdminDash
    AppMain --> UserDash
    AppMain --> Cards

    %% Authentication Pages
    subgraph "Auth Pages"
        direction TB
        SignIn["SignIn.jsx"]:::frontend
        SignUp["Signup.jsx"]:::frontend
        Forgot["ForgotPassword.jsx"]:::frontend
        Reset["Resetpassword.jsx"]:::frontend
    end
    Routers --> SignIn
    Routers --> SignUp
    Routers --> Forgot
    Routers --> Reset

    %% Management Pages
    subgraph "Management Pages"
        direction TB
        UsersHome["Users Home (List)"]:::frontend
        UserDetails["Details.jsx"]:::frontend
        UserEdit["Edit.jsx"]:::frontend
        UserRegister["Register.jsx"]:::frontend
        TicketsList["Tickets.jsx"]:::frontend
        TicketsCreate["Create.jsx"]:::frontend
        TaskForm["TaskForm.jsx"]:::frontend
        TaskList["TaskList.jsx"]:::frontend
    end
    Routers --> UsersHome
    Routers --> TicketsList
    Routers --> TaskList

    %% User Task Pages
    subgraph "User Task Pages"
        direction TB
        UTaskList["TaskList.jsx"]:::frontend
        UTaskPage["TaskPage.jsx"]:::frontend
        UTaskSubmit["TaskSubmissionForm.jsx"]:::frontend
    end
    Routers --> UTaskList

    %% SDK and Config
    subgraph "Config & Static"
        direction TB
        ViteCfg["vite.config.js"]:::frontend
        NetlifyCfg["netlify.toml"]:::frontend
        Env[".env"]:::frontend
        HTML["index.html"]:::frontend
        CSS["src/index.css"]:::frontend
    end

    %% Frontend to Backend
    ApiSvc -->|“HTTPS JSON”| API["Express API"]:::backend

    %% Backend Layer
    subgraph "Backend (Node.js + Express)"
        direction TB
        API
        AuthRoutes["Auth Routes"]:::backend
        UserRoutes["User Routes"]:::backend
        TicketRoutes["Ticket Routes"]:::backend
        TaskRoutes["Task Routes"]:::backend
        JWT["JWT Middleware"]:::backend
    end
    API --> AuthRoutes
    API --> UserRoutes
    API --> TicketRoutes
    API --> TaskRoutes
    AuthRoutes --> JWT
    UserRoutes --> JWT
    TicketRoutes --> JWT
    TaskRoutes --> JWT

    %% Database Layer
    subgraph "Database (MongoDB)"
        direction TB
        Mongo["MongoDB"]:::db
        UsersCol["users Collection"]:::db
        TicketsCol["tickets Collection"]:::db
        TasksCol["tasks Collection"]:::db
    end
    AuthRoutes -->|CRUD| UsersCol
    UserRoutes -->|CRUD| UsersCol
    TicketRoutes -->|CRUD| TicketsCol
    TaskRoutes -->|CRUD| TasksCol
    API --> Mongo

    %% External Services
    Email["Email Service"]:::external
    AuthRoutes -->|“Send reset email”| Email

    %% Click Events
    click React "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/main.jsx"
    click AppMain "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/App.jsx"
    click Routers "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/routes/AppRouters.jsx"
    click ContextProv "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/context/ContextProvider.jsx"
    click ApiSvc "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/utils/ApiService.jsx"
    click LogoutHook "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/hooks/useLogout.jsx"
    click Spinner "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Spiner/Spiner.jsx"
    click AdminDash "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Dashboard/AdminDashboard/Dashboard.jsx"
    click TaskDash "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Dashboard/AdminDashboard/TaskDashboard.jsx"
    click TicketsDash "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Dashboard/AdminDashboard/TicketsDashboard.jsx"
    click TicketChart "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Dashboard/AdminDashboard/TicketAreaChart.jsx"
    click Progress "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Dashboard/AdminDashboard/CircleProgressBar.jsx"
    click UserDash "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Dashboard/UserDashbooard/UserDashboard.jsx"
    click UserTaskDash "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Dashboard/UserDashbooard/UserTaskDashboard.jsx"
    click UserTicketsDash "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/components/Dashboard/UserDashbooard/UserTicketsDashoard.jsx"
    click SignIn "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/signin/SignIn.jsx"
    click SignUp "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Signup/Signup.jsx"
    click Forgot "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Password/ForgotPassword.jsx"
    click Reset "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Password/Resetpassword.jsx"
    click UsersHome "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Users/Home.jsx"
    click UserDetails "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Users/Details.jsx"
    click UserEdit "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Users/Edit.jsx"
    click UserRegister "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Users/Register.jsx"
    click TicketsList "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Tickets/Tickets.jsx"
    click TicketsCreate "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/Tickets/Create.jsx"
    click TaskForm "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/TASK/TaskForm.jsx"
    click TaskList "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/TASK/TaskList.jsx"
    click UTaskList "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/User Task/TaskList.jsx"
    click UTaskPage "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/User Task/TaskPage.jsx"
    click UTaskSubmit "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/pages/User Task/TaskSubmissionForm.jsx"
    click ViteCfg "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/vite.config.js"
    click NetlifyCfg "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/netlify.toml"
    click Env "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/.env"
    click HTML "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/index.html"
    click CSS "https://github.com/harishvinayagamoorthy/crm-mern/blob/Frontend/src/index.css"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef db fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
