# sivamani52/college-voting-system architecture

> Architecture diagram of the GitHub repository sivamani52/college-voting-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sivamani52/college-voting-system
- Repository: https://github.com/sivamani52/college-voting-system

## Overview

This is a college election platform for super-admins, scoped departmental admins, and student voters. The workflow is election setup and voter eligibility, candidate/position management, student ballot submission, then results review; administration also covers academic structure and student accounts. The graph separates the React role-based experience, HTTP routing and authorization, election-domain controllers, and MySQL persistence. Source excerpts show key voting, eligibility, scope, and routing behavior; other major screens and subsystems are represented from the source index, so some frontend-to-API relationships remain unverified.

Main entry points: [`backend/server.js`](https://github.com/sivamani52/college-voting-system/blob/main/backend/server.js) (HTTP server), [`backend/models`](https://github.com/sivamani52/college-voting-system/tree/main/backend/models) (Domain models), [`frontend/src/App.jsx`](https://github.com/sivamani52/college-voting-system/blob/main/frontend/src/App.jsx) (Role routes), [`backend/routes/authRoutes.js`](https://github.com/sivamani52/college-voting-system/blob/main/backend/routes/authRoutes.js) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Role-based web client"]
  node_app["Role routes<br/>[App.jsx]"]
  node_login["Sign in<br/>[Login.jsx]"]
  node_student_ui["Student voting"]
  node_admin_ui["Admin console"]
  node_super_ui["Super-admin console"]
  node_services["API services"]
end

subgraph group_api["API and access control"]
  node_api_server["HTTP server<br/>[server.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth_ctrl["Authentication<br/>[authController.js]"]
  node_guard["Token and role guards"]
  node_scope["Assignment scope"]
end

subgraph group_election["Election operations"]
  node_election_ctrl["Election management"]
  node_eligibility_ctrl["Voter eligibility"]
  node_candidate_ctrl["Candidate management"]
  node_vote_ctrl["Ballot and vote<br/>[voteController.js]"]
  node_result_ctrl["Election results"]
end

subgraph group_admin["Academic administration"]
  node_student_ctrl["Student accounts"]
  node_academic_ctrl["Academic structure"]
  node_admin_ctrl["Admin accounts<br/>[adminController.js]"]
end

subgraph group_storage["Persistence and messaging"]
  node_models["Domain models"]
  node_db[("MySQL pool<br/>[db.js]")]
  node_email["Email delivery<br/>[emailService.js]"]
end

node_visitor(("User"))

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_student_ui
node_app -->|"routes to"| node_admin_ui
node_app -->|"routes to"| node_super_ui
node_student_ui -.->|"requests data"| node_services
node_admin_ui -.->|"requests data"| node_services
node_super_ui -.->|"requests data"| node_services
node_services -.->|"calls API"| node_api_server
node_api_server -->|"mounts"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_ctrl
node_login -.->|"authenticates"| node_auth_routes
node_api_server -.->|"mounts election routes"| node_election_ctrl
node_api_server -.->|"mounts eligibility routes"| node_eligibility_ctrl
node_api_server -.->|"mounts candidate routes"| node_candidate_ctrl
node_api_server -.->|"mounts vote routes"| node_vote_ctrl
node_api_server -.->|"mounts result routes"| node_result_ctrl
node_api_server -.->|"mounts student routes"| node_student_ctrl
node_api_server -.->|"mounts academic routes"| node_academic_ctrl
node_api_server -.->|"mounts admin routes"| node_admin_ctrl
node_auth_routes -->|"uses authentication"| node_guard
node_eligibility_ctrl -->|"checks admin scope"| node_guard
node_election_ctrl -->|"checks assignment"| node_scope
node_candidate_ctrl -->|"checks assignment"| node_scope
node_vote_ctrl -->|"checks voter scope"| node_scope
node_election_ctrl -->|"reads and updates elections"| node_models
node_eligibility_ctrl -->|"manages eligibility"| node_models
node_candidate_ctrl -->|"manages candidates"| node_models
node_vote_ctrl -->|"records votes"| node_models
node_student_ctrl -->|"manages students"| node_models
node_academic_ctrl -->|"manages structure"| node_models
node_auth_ctrl -->|"reads accounts"| node_models
node_auth_ctrl -->|"sends messages"| node_email
node_models -->|"queries"| node_db
node_scope -->|"loads assignment"| node_db

click node_app "https://github.com/sivamani52/college-voting-system/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/sivamani52/college-voting-system/blob/main/frontend/src/pages/auth/Login.jsx"
click node_student_ui "https://github.com/sivamani52/college-voting-system/tree/main/frontend/src/pages/student"
click node_admin_ui "https://github.com/sivamani52/college-voting-system/tree/main/frontend/src/pages/admin"
click node_super_ui "https://github.com/sivamani52/college-voting-system/tree/main/frontend/src/pages/superadmin"
click node_services "https://github.com/sivamani52/college-voting-system/tree/main/frontend/src/services"
click node_api_server "https://github.com/sivamani52/college-voting-system/blob/main/backend/server.js"
click node_auth_routes "https://github.com/sivamani52/college-voting-system/blob/main/backend/routes/authRoutes.js"
click node_auth_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/authController.js"
click node_guard "https://github.com/sivamani52/college-voting-system/tree/main/backend/middleware"
click node_election_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/electionController.js"
click node_eligibility_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/eligibleVoterController.js"
click node_candidate_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/candidateController.js"
click node_vote_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/voteController.js"
click node_result_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/resultController.js"
click node_student_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/studentController.js"
click node_academic_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/academicStructureController.js"
click node_admin_ctrl "https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/adminController.js"
click node_scope "https://github.com/sivamani52/college-voting-system/blob/main/backend/middleware/adminScopeMiddleware.js"
click node_models "https://github.com/sivamani52/college-voting-system/tree/main/backend/models"
click node_db "https://github.com/sivamani52/college-voting-system/blob/main/backend/config/db.js"
click node_email "https://github.com/sivamani52/college-voting-system/blob/main/backend/services/emailService.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_login,node_student_ui,node_admin_ui,node_super_ui,node_services,node_visitor toneBlue
class node_api_server,node_auth_routes,node_auth_ctrl,node_guard,node_scope toneAmber
class node_election_ctrl,node_eligibility_ctrl,node_candidate_ctrl,node_vote_ctrl,node_result_ctrl toneMint
class node_student_ctrl,node_academic_ctrl,node_admin_ctrl toneRose
class node_models,node_db,node_email toneIndigo
```

## Components

### Role-based web client

- [Role routes](https://github.com/sivamani52/college-voting-system/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign in](https://github.com/sivamani52/college-voting-system/blob/main/frontend/src/pages/auth/Login.jsx): `frontend/src/pages/auth/Login.jsx`
- [Student voting](https://github.com/sivamani52/college-voting-system/tree/main/frontend/src/pages/student): `frontend/src/pages/student`
- [Admin console](https://github.com/sivamani52/college-voting-system/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`
- [Super-admin console](https://github.com/sivamani52/college-voting-system/tree/main/frontend/src/pages/superadmin): `frontend/src/pages/superadmin`
- [API services](https://github.com/sivamani52/college-voting-system/tree/main/frontend/src/services): `frontend/src/services`

### API and access control

- [HTTP server](https://github.com/sivamani52/college-voting-system/blob/main/backend/server.js): `backend/server.js`
- [Auth routes](https://github.com/sivamani52/college-voting-system/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Authentication](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Token and role guards](https://github.com/sivamani52/college-voting-system/tree/main/backend/middleware): `backend/middleware`
- [Assignment scope](https://github.com/sivamani52/college-voting-system/blob/main/backend/middleware/adminScopeMiddleware.js): `backend/middleware/adminScopeMiddleware.js`

### Election operations

- [Election management](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/electionController.js): `backend/controllers/electionController.js`
- [Voter eligibility](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/eligibleVoterController.js): `backend/controllers/eligibleVoterController.js`
- [Candidate management](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/candidateController.js): `backend/controllers/candidateController.js`
- [Ballot and vote](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/voteController.js): `backend/controllers/voteController.js`
- [Election results](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/resultController.js): `backend/controllers/resultController.js`

### Academic administration

- [Student accounts](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/studentController.js): `backend/controllers/studentController.js`
- [Academic structure](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/academicStructureController.js): `backend/controllers/academicStructureController.js`
- [Admin accounts](https://github.com/sivamani52/college-voting-system/blob/main/backend/controllers/adminController.js): `backend/controllers/adminController.js`

### Persistence and messaging

- [Domain models](https://github.com/sivamani52/college-voting-system/tree/main/backend/models): `backend/models`
- [MySQL pool](https://github.com/sivamani52/college-voting-system/blob/main/backend/config/db.js): `backend/config/db.js`
- [Email delivery](https://github.com/sivamani52/college-voting-system/blob/main/backend/services/emailService.js): `backend/services/emailService.js`

### Other components

- **User**

## Connections

- User → Role routes: uses (evidence: `frontend/src/App.jsx`)
- Role routes → Sign in: routes to (evidence: `frontend/src/App.jsx`)
- Role routes → Student voting: routes to (evidence: `frontend/src/App.jsx`)
- Role routes → Admin console: routes to (evidence: `frontend/src/App.jsx`)
- Role routes → Super-admin console: routes to (evidence: `frontend/src/App.jsx`)
- Student voting → API services: requests data
- Admin console → API services: requests data
- Super-admin console → API services: requests data
- API services → HTTP server: calls API
- HTTP server → Auth routes: mounts (evidence: `backend/server.js`)
- Auth routes → Authentication: dispatches (evidence: `backend/routes/authRoutes.js`)
- Sign in → Auth routes: authenticates
- HTTP server → Election management: mounts election routes
- HTTP server → Voter eligibility: mounts eligibility routes
- HTTP server → Candidate management: mounts candidate routes
- HTTP server → Ballot and vote: mounts vote routes
- HTTP server → Election results: mounts result routes
- HTTP server → Student accounts: mounts student routes
- HTTP server → Academic structure: mounts academic routes
- HTTP server → Admin accounts: mounts admin routes
- Auth routes → Token and role guards: uses authentication (evidence: `backend/routes/authRoutes.js`)
- Voter eligibility → Token and role guards: checks admin scope (evidence: `backend/controllers/eligibleVoterController.js`)
- Election management → Assignment scope: checks assignment (evidence: `backend/controllers/electionController.js`)
- Candidate management → Assignment scope: checks assignment (evidence: `backend/controllers/candidateController.js`)
- Ballot and vote → Assignment scope: checks voter scope (evidence: `backend/controllers/voteController.js`)
- Election management → Domain models: reads and updates elections (evidence: `backend/controllers/electionController.js`)
- Voter eligibility → Domain models: manages eligibility (evidence: `backend/controllers/eligibleVoterController.js`)
- Candidate management → Domain models: manages candidates (evidence: `backend/controllers/candidateController.js`)
- Ballot and vote → Domain models: records votes (evidence: `backend/controllers/voteController.js`)
- Student accounts → Domain models: manages students (evidence: `backend/controllers/studentController.js`)
- Academic structure → Domain models: manages structure (evidence: `backend/controllers/academicStructureController.js`)
- Authentication → Domain models: reads accounts (evidence: `backend/controllers/authController.js`)
- Authentication → Email delivery: sends messages (evidence: `backend/controllers/authController.js`)
- Domain models → MySQL pool: queries (evidence: `backend/models/electionModel.js`)
- Assignment scope → MySQL pool: loads assignment (evidence: `backend/middleware/adminScopeMiddleware.js`)
