# nithinr8265/college_voting_system architecture

> Architecture diagram of the GitHub repository nithinr8265/college_voting_system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nithinr8265/college_voting_system
- Repository: https://github.com/nithinr8265/college_voting_system

## Overview

This is a Flask college-election platform. Its principal voter workflow runs from registration and approval through OTP login, face verification, ballot confirmation, vote storage, and scheduled result publication; administrators manage voters, candidates, election settings, and monitoring. `app.py` is the route and workflow orchestrator, with validation, face recognition, email, and Supabase operations delegated to helpers. The source excerpts support several helper calls and the webcam verification request; other feature relationships below rely on the README, not inspection of unsampled routes.

Main entry points: [`app.py`](https://github.com/nithinr8265/college_voting_system/blob/main/app.py) (Face verification), [`db.py`](https://github.com/nithinr8265/college_voting_system/blob/main/db.py) (Supabase operations), [`templates/ballot.html`](https://github.com/nithinr8265/college_voting_system/blob/main/templates/ballot.html) (Ballot and confirmation), [`mail_service.py`](https://github.com/nithinr8265/college_voting_system/blob/main/mail_service.py) (OTP email delivery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_voting["Voter workflow"]
  node_flask["Flask routes<br/>[app.py]"]
  node_registration["Registration and approval<br/>[app.py]"]
  node_authentication["OTP authentication<br/>[app.py]"]
  node_face_check["Face verification<br/>[app.py]"]
  node_ballot["Ballot and confirmation<br/>[ballot.html]"]
  node_vote_ui["Vote confirmation UI<br/>[vote.js]"]
  node_vote_submission["Vote submission<br/>[app.py]"]
  node_election_results["Results and analytics<br/>[app.py]"]
  node_webcam_ui["Webcam capture<br/>[webcam.js]"]
end

subgraph group_admin["Election administration"]
  node_admin_management["Voter and candidate management<br/>[app.py]"]
  node_election_controls["Election settings and scheduling<br/>[app.py]"]
  node_election_monitor["Election monitoring<br/>[monitor.html]"]
end

subgraph group_services["Application services"]
  node_face_engine["Face matching<br/>[face_service.py]"]
  node_otp_service["OTP email delivery<br/>[mail_service.py]"]
  node_input_validation["Server-side validation<br/>[validators.py]"]
  node_smtp["Gmail SMTP"]
end

subgraph group_data["Data and presentation"]
  node_database_access["Supabase operations<br/>[db.py]"]
  node_supabase[("Supabase PostgreSQL")]
end

node_student(("Student voter"))
node_administrator(("Administrator"))

node_student -->|"registers"| node_registration
node_registration -->|"continues to"| node_authentication
node_authentication -->|"sends OTP"| node_otp_service
node_otp_service -->|"sends email"| node_smtp
node_authentication -->|"verifies next"| node_face_check
node_student -->|"captures image"| node_webcam_ui
node_webcam_ui -->|"posts image"| node_face_check
node_face_check -->|"checks face"| node_face_engine
node_face_check -.->|"uses routes"| node_flask
node_face_check -->|"continues to"| node_ballot
node_student -->|"selects candidates"| node_ballot
node_ballot -->|"uses confirmation"| node_vote_ui
node_vote_ui -->|"submits ballot"| node_vote_submission
node_vote_submission -->|"feeds results"| node_election_results
node_flask -->|"reads and writes"| node_database_access
node_flask -->|"validates forms"| node_input_validation
node_database_access -->|"queries and updates"| node_supabase
node_administrator -->|"manages records"| node_admin_management
node_administrator -->|"configures election"| node_election_controls
node_administrator -->|"monitors election"| node_election_monitor
node_admin_management -->|"updates records"| node_database_access
node_election_controls -->|"stores settings"| node_database_access
node_election_results -->|"reads vote data"| node_database_access
node_flask -->|"uses service"| node_otp_service

click node_flask "https://github.com/nithinr8265/college_voting_system/blob/main/app.py"
click node_registration "https://github.com/nithinr8265/college_voting_system/blob/main/app.py"
click node_authentication "https://github.com/nithinr8265/college_voting_system/blob/main/app.py"
click node_face_check "https://github.com/nithinr8265/college_voting_system/blob/main/app.py"
click node_face_engine "https://github.com/nithinr8265/college_voting_system/blob/main/face_service.py"
click node_otp_service "https://github.com/nithinr8265/college_voting_system/blob/main/mail_service.py"
click node_ballot "https://github.com/nithinr8265/college_voting_system/blob/main/templates/ballot.html"
click node_vote_ui "https://github.com/nithinr8265/college_voting_system/blob/main/static/js/vote.js"
click node_vote_submission "https://github.com/nithinr8265/college_voting_system/blob/main/app.py"
click node_election_results "https://github.com/nithinr8265/college_voting_system/blob/main/app.py"
click node_admin_management "https://github.com/nithinr8265/college_voting_system/blob/main/app.py"
click node_election_controls "https://github.com/nithinr8265/college_voting_system/blob/main/app.py"
click node_election_monitor "https://github.com/nithinr8265/college_voting_system/blob/main/templates/admin/monitor.html"
click node_input_validation "https://github.com/nithinr8265/college_voting_system/blob/main/validators.py"
click node_database_access "https://github.com/nithinr8265/college_voting_system/blob/main/db.py"
click node_webcam_ui "https://github.com/nithinr8265/college_voting_system/blob/main/static/js/webcam.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_flask,node_registration,node_authentication,node_face_check,node_ballot,node_vote_ui,node_vote_submission,node_election_results,node_webcam_ui toneBlue
class node_admin_management,node_election_controls,node_election_monitor toneAmber
class node_face_engine,node_otp_service,node_input_validation,node_smtp toneMint
class node_database_access,node_supabase toneRose
class node_student,node_administrator toneIndigo
```

## Components

### Voter workflow

- [Flask routes](https://github.com/nithinr8265/college_voting_system/blob/main/app.py): `app.py`
- [Registration and approval](https://github.com/nithinr8265/college_voting_system/blob/main/app.py): `app.py`
- [OTP authentication](https://github.com/nithinr8265/college_voting_system/blob/main/app.py): `app.py`
- [Face verification](https://github.com/nithinr8265/college_voting_system/blob/main/app.py): `app.py`
- [Ballot and confirmation](https://github.com/nithinr8265/college_voting_system/blob/main/templates/ballot.html): `templates/ballot.html`
- [Vote confirmation UI](https://github.com/nithinr8265/college_voting_system/blob/main/static/js/vote.js): `static/js/vote.js`
- [Vote submission](https://github.com/nithinr8265/college_voting_system/blob/main/app.py): `app.py`
- [Results and analytics](https://github.com/nithinr8265/college_voting_system/blob/main/app.py): `app.py`
- [Webcam capture](https://github.com/nithinr8265/college_voting_system/blob/main/static/js/webcam.js): `static/js/webcam.js`

### Election administration

- [Voter and candidate management](https://github.com/nithinr8265/college_voting_system/blob/main/app.py): `app.py`
- [Election settings and scheduling](https://github.com/nithinr8265/college_voting_system/blob/main/app.py): `app.py`
- [Election monitoring](https://github.com/nithinr8265/college_voting_system/blob/main/templates/admin/monitor.html): `templates/admin/monitor.html`

### Application services

- [Face matching](https://github.com/nithinr8265/college_voting_system/blob/main/face_service.py): `face_service.py`
- [OTP email delivery](https://github.com/nithinr8265/college_voting_system/blob/main/mail_service.py): `mail_service.py`
- [Server-side validation](https://github.com/nithinr8265/college_voting_system/blob/main/validators.py): `validators.py`
- **Gmail SMTP**

### Data and presentation

- [Supabase operations](https://github.com/nithinr8265/college_voting_system/blob/main/db.py): `db.py`
- **Supabase PostgreSQL**

### Other components

- **Student voter**
- **Administrator**

## Connections

- Student voter → Registration and approval: registers (evidence: `README.md`)
- Registration and approval → OTP authentication: continues to (evidence: `README.md`)
- OTP authentication → OTP email delivery: sends OTP (evidence: `app.py`)
- OTP email delivery → Gmail SMTP: sends email (evidence: `mail_service.py`)
- OTP authentication → Face verification: verifies next (evidence: `README.md`)
- Student voter → Webcam capture: captures image (evidence: `static/js/webcam.js`)
- Webcam capture → Face verification: posts image (evidence: `static/js/webcam.js`)
- Face verification → Face matching: checks face (evidence: `app.py`)
- Face verification → Flask routes: uses routes (evidence: `app.py`)
- Face verification → Ballot and confirmation: continues to (evidence: `README.md`)
- Student voter → Ballot and confirmation: selects candidates (evidence: `README.md`)
- Ballot and confirmation → Vote confirmation UI: uses confirmation (evidence: `static/js/vote.js`)
- Vote confirmation UI → Vote submission: submits ballot (evidence: `README.md`)
- Vote submission → Results and analytics: feeds results (evidence: `README.md`)
- Flask routes → Supabase operations: reads and writes (evidence: `app.py`)
- Flask routes → Server-side validation: validates forms (evidence: `app.py`)
- Supabase operations → Supabase PostgreSQL: queries and updates (evidence: `db.py`)
- Administrator → Voter and candidate management: manages records (evidence: `README.md`)
- Administrator → Election settings and scheduling: configures election (evidence: `README.md`)
- Administrator → Election monitoring: monitors election (evidence: `README.md`)
- Voter and candidate management → Supabase operations: updates records (evidence: `app.py`)
- Election settings and scheduling → Supabase operations: stores settings (evidence: `app.py`)
- Results and analytics → Supabase operations: reads vote data (evidence: `README.md`)
- Flask routes → OTP email delivery: uses service (evidence: `app.py`)
