# sarvaiyaprashant2242005/voloconnect architecture

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

- Interactive diagram: https://gitdiagram.com/sarvaiyaprashant2242005/voloconnect
- Repository: https://github.com/sarvaiyaprashant2242005/voloconnect

## Overview

##### Project Type & Purpose
- VoloConnect is a full-stack web application.
- Purpose: Match volunteers and organizations via a React frontend and a Node/Express backend with PostgreSQL persistence, plus email notifications.

##### File Structure
- client/
‑ React + Vite project
‑ src/components (UI), src/services (API calls), src/context (Auth state)
- server/
‑ Express app (app.js + index.js)
‑ config/ (DB setup, init scripts)
‑ controllers/ (business logic)
‑ routes/ (REST endpoints)
‑ middleware/auth.js (JWT guard)
‑ utils/emailService.js (SMTP integration)
‑ db/ (migrations, seed, logs)

##### README Insights
- Runs on localhost:3001 (client) & 5000 (server).
- Key features: Smart matching, real-time updates, profile management, org dashboard, impact tracking.

##### Main Components
a. Frontend (React/Vite)
- UI components (Landing, Auth, Dashboard, Events)
- AuthContext for JWT/session
- API layer (eventService.js)
b. Backend (Node.js/Express)
- Routes → Controllers → Database
- Auth middleware (JWT)
- EmailService (SMTP/SendGrid)
c. Persistence
- PostgreSQL database (schemas: users, events, volunteers, logs)
d. External Services
- Email provider
- (Optionally) push/notification service or third-party auth if used

##### Relationships & Data Flows
- User browser → HTTP(S) → React client
- React client → REST API calls → Express routes
- Express middleware → Controller logic → Queries to PostgreSQL
- Controller → Calls emailService → External SMTP
- DB migrations & seeds initialize schemas
- AuthContext intercepts API calls, stores JWT from login

##### Architectural Patterns & Principles
- Frontend: Component-based UI, Context API for global state, Service layer for decoupled API calls
- Backend: MVC-inspired (Routes → Controllers → Models/DB), layered config for DB and initialization, middleware for cross-cutting concerns
- Clear separation of concerns (UI vs. business logic vs. data layer)

##### Technologies & Frameworks
- Frontend: React, Vite, JSX, CSS Modules
- Backend: Node.js, Express, JWT, Knex/pg or raw SQL migrations
- Database: PostgreSQL
- Utilities: nodemailer or similar (emailService.js)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User["User Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend (React/Vite)" 
        style Frontend fill:#E0F7FA,stroke:#0288D1,stroke-width:2px
        subgraph "UI Components"
            style UIComponents fill:#B3E5FC,stroke:#0277BD
            LandingPage["LandingPage.jsx"] 
            AuthComp["Auth.jsx"]
            LoginForm["LoginForm.jsx"]
            RegisterForm["RegisterForm.jsx"]
            DashboardComp["dashboard.jsx"]
            CreateEvent["CreateEvent.jsx"]
            EventsComp["Events.jsx"]
            EventDetail["EventDetail.jsx"]
            EventDetailPreview["EventDetailPreview.jsx"]
            EventEdit["EventEdit.jsx"]
            VolunteerSignup["VolunteerSignup.jsx"]
            VolunteerManagement["VolunteerManagement.jsx"]
            VolunteerHistory["VolunteerHistory.jsx"]
            ExportVolunteers["ExportVolunteers.jsx"]
        end
        AuthCtx["AuthContext.jsx"]:::frontend
        APIConfig["api.js"]:::frontend
        EventService["eventService.js"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Node/Express)" 
        style Backend fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px
        EntryIndex["index.js"]
        AppJS["app.js"]
        subgraph "Config"
            style Config fill:#C8E6C9,stroke:#1B5E20
            DBConfig["database.js"]
            InitDb["initDb.js"]
            SchemaSQL["schema.sql"]
        end
        subgraph "Routes"
            style Routes fill:#DCEDC8,stroke:#558B2F
            RouteAuth["auth.js"]
            RouteEvents["events.js"]
            RouteEventMgmt["event_management.js"]
            RouteVolunteers["volunteers.js"]
            RouteVolunteerMgmt["volunteer_management.js"]
            RouteDashboard["dashboard.js"]
            RouteEmail["email.js"]
            RouteQueries["queries.js"]
        end
        subgraph "Controllers"
            style Controllers fill:#A5D6A7,stroke:#388E3C
            AuthController["authController.js"]
        end
        subgraph "Middleware"
            style Middleware fill:#AED581,stroke:#689F38
            AuthMiddleware["auth.js"]
        end
        subgraph "Utils"
            style Utils fill:#C5E1A5,stroke:#558B2F
            EmailService["emailService.js"]
        end
    end

    %% Database
    subgraph "PostgreSQL Database"
        style DB fill:#FFE0B2,stroke:#EF6C00,stroke-width:2px
        DB["PostgreSQL"]
        subgraph "Migrations"
            style Migrations fill:#FFE0B2,stroke:#E65100
            Mig1["events.sql"]
            Mig2["event_volunteers.sql"]
            Mig3["volunteer_events.sql"]
            Mig4["update_events_table.sql"]
        end
        subgraph "Logs & Import"
            style Logs fill:#FFCC80,stroke:#E65100
            CommLogs["communication_logs.sql"]
            ImportScript["importCommunicationLogs.js"]
        end
    end

    %% External Service
    EmailProvider["External Email Service"]:::external

    %% Connections
    User -->|"browse"| LandingPage
    LandingPage -->|"uses"| AuthCtx
    AuthCtx -->|"wraps API calls"| EventService
    EventService -->|"calls REST"| EntryIndex
    EntryIndex -->|"loads"| AppJS
    AppJS -->|"initializes"| DBConfig
    AppJS -->|"runs migrations"| InitDb
    AppJS -->|"sets schema"| SchemaSQL
    AppJS -->|"registers routes"| RouteAuth
    RouteAuth -->|"calls"| AuthController
    AuthController -->|"uses"| AuthMiddleware
    AppJS -->|"registers"| RouteEvents
    AppJS -->|"registers"| RouteEventMgmt
    AppJS -->|"registers"| RouteVolunteers
    AppJS -->|"registers"| RouteVolunteerMgmt
    AppJS -->|"registers"| RouteDashboard
    AppJS -->|"registers"| RouteEmail
    AppJS -->|"registers"| RouteQueries
    AuthMiddleware -->|"guards"| RouteAuth
    RouteEmail -->|"uses"| EmailService
    AuthController -->|"queries"| DB
    RouteEvents -->|"queries"| DB
    RouteEventMgmt -->|"queries"| DB
    RouteVolunteers -->|"queries"| DB
    RouteVolunteerMgmt -->|"queries"| DB
    RouteDashboard -->|"queries"| DB
    DB -->|"migrations apply"| Mig1
    DB -->|"migrations apply"| Mig2
    DB -->|"migrations apply"| Mig3
    DB -->|"migrations apply"| Mig4
    DB -->|"stores logs"| CommLogs
    DB -->|"import logs"| ImportScript
    EmailService -->|"SMTP/API"| EmailProvider

    %% Click Events - Frontend
    click LandingPage "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/LandingPage.jsx"
    click AuthComp "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/auth/Auth.jsx"
    click LoginForm "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/auth/LoginForm.jsx"
    click RegisterForm "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/auth/RegisterForm.jsx"
    click DashboardComp "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/dashboard/dashboard.jsx"
    click CreateEvent "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/dashboard/CreateEvent.jsx"
    click EventsComp "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/Events.jsx"
    click EventDetail "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/events/EventDetail.jsx"
    click EventDetailPreview "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/events/EventDetailPreview.jsx"
    click EventEdit "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/events/EventEdit.jsx"
    click VolunteerSignup "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/volunteer/VolunteerSignup.jsx"
    click VolunteerManagement "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/volunteer/VolunteerManagement.jsx"
    click VolunteerHistory "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/volunteer/VolunteerHistory.jsx"
    click ExportVolunteers "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/components/volunteer/ExportVolunteers.jsx"
    click AuthCtx "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/context/AuthContext.jsx"
    click APIConfig "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/config/api.js"
    click EventService "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/client/src/services/eventService.js"

    %% Click Events - Backend
    click EntryIndex "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/index.js"
    click AppJS "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/app.js"
    click DBConfig "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/config/database.js"
    click InitDb "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/config/initDb.js"
    click SchemaSQL "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/config/schema.sql"
    click AuthController "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/controllers/authController.js"
    click RouteAuth "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/routes/auth.js"
    click RouteEvents "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/routes/events.js"
    click RouteEventMgmt "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/routes/event_management.js"
    click RouteVolunteers "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/routes/volunteers.js"
    click RouteVolunteerMgmt "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/routes/volunteer_management.js"
    click RouteDashboard "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/routes/dashboard.js"
    click RouteEmail "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/routes/email.js"
    click RouteQueries "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/routes/queries.js"
    click AuthMiddleware "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/middleware/auth.js"
    click EmailService "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/utils/emailService.js"
    click Mig1 "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/db/migrations/events.sql"
    click Mig2 "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/db/migrations/event_volunteers.sql"
    click Mig3 "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/db/migrations/volunteer_events.sql"
    click Mig4 "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/db/migrations/update_events_table.sql"
    click CommLogs "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/db/communication_logs.sql"
    click ImportScript "https://github.com/sarvaiyaprashant2242005/voloconnect/blob/main/server/db/importCommunicationLogs.js"

    %% Styles
    classDef frontend fill:#E1F5FE,stroke:#0288D1
    classDef backend fill:#E8F5E9,stroke:#2E7D32
    classDef database fill:#FFE0B2,stroke:#EF6C00
    classDef external fill:#CFD8DC,stroke:#455A64,stroke-width:2px
```
