# piyolo/votingaccnew architecture

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

- Interactive diagram: https://gitdiagram.com/piyolo/votingaccnew
- Repository: https://github.com/piyolo/votingaccnew

## Overview

School Voting System is a self-hosted PHP platform for student-government elections. Students register or sign in, view elections, prepare and submit a ballot, and view results subject to election visibility rules; administrators configure election days and manage elections and student records. The graph also includes the built-in guided code tour. The excerpts establish shared helper and database dependencies, but do not show the student ballot or admin-dashboard request wiring, so those links are omitted rather than inferred.

Main entry points: [`includes/functions.php`](https://github.com/piyolo/votingaccnew/blob/main/includes/functions.php) (Shared application logic), [`config/db.php`](https://github.com/piyolo/votingaccnew/blob/main/config/db.php) (PDO database), [`guide/config.php`](https://github.com/piyolo/votingaccnew/blob/main/guide/config.php) (Tour configuration), [`student/register.php`](https://github.com/piyolo/votingaccnew/blob/main/student/register.php) (Registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_student["Student voting"]
  node_landing["Public landing<br/>[landingpage.php]"]
  node_student_auth["Student accounts<br/>[login.php]"]
  node_registration["Registration<br/>[register.php]"]
  node_student_dashboard["Student dashboard<br/>[dashboard.php]"]
  node_draft["Ballot drafts<br/>[draft.php]"]
  node_vote["Vote submission<br/>[vote.php]"]
  node_results["Election results<br/>[results.php]"]
end

subgraph group_admin["Election administration"]
  node_admin_login["Admin login<br/>[login.php]"]
  node_admin_dashboard["Admin dashboard<br/>[dashboard.php]"]
  node_elections_api["Election management<br/>[elections.php]"]
  node_settings_api["Election settings<br/>[settings.php]"]
  node_students_api["Student records admin<br/>[students.php]"]
  node_admins_api["Admin accounts<br/>[admins.php]"]
  node_logs_api["Admin logs<br/>[logs.php]"]
  node_school_year_api["School-year data"]
end

subgraph group_shared["Shared services"]
  node_draft_helpers["Election-day drafts"]
  node_student_records["Student record logic"]
  node_functions["Shared application logic<br/>[functions.php]"]
  node_database[("PDO database<br/>[db.php]")]
end

subgraph group_guide["Guided code tour"]
  node_guide_app["Tour interface<br/>[index.php]"]
  node_guide_config["Tour configuration<br/>[config.php]"]
  node_guide_annotations["Tour chapters<br/>[annotations.php]"]
  node_guide_system["System reference<br/>[system.php]"]
  node_guide_source["Live source reader<br/>[source.php]"]
  node_guide_snippet["Snippet endpoint<br/>[snippet.php]"]
  node_guide_validate["Reference validation<br/>[validate.php]"]
end

node_student_actor(("Student"))
node_admin_actor(("Administrator"))
node_guide_user(("Local guide visitor"))

node_student_actor -->|"visits"| node_landing
node_student_actor -->|"signs in"| node_student_auth
node_student_actor -->|"registers"| node_registration
node_student_actor -->|"uses"| node_student_dashboard
node_student_actor -->|"submits ballot"| node_vote
node_student_actor -->|"views results"| node_results
node_admin_actor -->|"signs in"| node_admin_login
node_admin_actor -->|"manages elections"| node_admin_dashboard
node_admin_login -->|"uses helpers"| node_functions
node_admin_login -->|"connects"| node_database
node_admin_dashboard -->|"uses helpers"| node_functions
node_admin_dashboard -->|"connects"| node_database
node_elections_api -->|"uses helpers"| node_functions
node_elections_api -->|"uses draft logic"| node_draft_helpers
node_elections_api -->|"connects"| node_database
node_settings_api -->|"uses helpers"| node_functions
node_settings_api -->|"connects"| node_database
node_students_api -->|"uses helpers"| node_functions
node_students_api -->|"uses record logic"| node_student_records
node_students_api -->|"connects"| node_database
node_admins_api -->|"uses helpers"| node_functions
node_admins_api -->|"connects"| node_database
node_student_dashboard -->|"uses helpers"| node_functions
node_student_dashboard -->|"connects"| node_database
node_registration -->|"uses helpers"| node_functions
node_registration -->|"uses record logic"| node_student_records
node_registration -->|"connects"| node_database
node_student_auth -->|"uses helpers"| node_functions
node_student_auth -->|"connects"| node_database
node_results -->|"uses helpers"| node_functions
node_results -->|"connects"| node_database
node_guide_user -->|"opens tour"| node_guide_app
node_guide_app -->|"loads configuration"| node_guide_config
node_guide_config -->|"loads chapters"| node_guide_annotations
node_guide_config -->|"loads reference"| node_guide_system
node_guide_snippet -->|"uses configuration"| node_guide_config
node_guide_snippet -->|"reads source"| node_guide_source
node_guide_validate -->|"uses configuration"| node_guide_config
node_guide_validate -->|"validates source"| node_guide_source

click node_landing "https://github.com/piyolo/votingaccnew/blob/main/public/landingpage.php"
click node_student_auth "https://github.com/piyolo/votingaccnew/blob/main/student/login.php"
click node_registration "https://github.com/piyolo/votingaccnew/blob/main/student/register.php"
click node_student_dashboard "https://github.com/piyolo/votingaccnew/blob/main/student/dashboard.php"
click node_draft "https://github.com/piyolo/votingaccnew/blob/main/student/draft.php"
click node_vote "https://github.com/piyolo/votingaccnew/blob/main/student/vote.php"
click node_results "https://github.com/piyolo/votingaccnew/blob/main/public/results.php"
click node_admin_login "https://github.com/piyolo/votingaccnew/blob/main/admin/login.php"
click node_admin_dashboard "https://github.com/piyolo/votingaccnew/blob/main/admin/dashboard.php"
click node_elections_api "https://github.com/piyolo/votingaccnew/blob/main/admin/api/elections.php"
click node_settings_api "https://github.com/piyolo/votingaccnew/blob/main/admin/api/settings.php"
click node_students_api "https://github.com/piyolo/votingaccnew/blob/main/admin/api/students.php"
click node_admins_api "https://github.com/piyolo/votingaccnew/blob/main/admin/api/admins.php"
click node_logs_api "https://github.com/piyolo/votingaccnew/blob/main/admin/api/logs.php"
click node_school_year_api "https://github.com/piyolo/votingaccnew/blob/main/admin/api/next-school-year.php"
click node_draft_helpers "https://github.com/piyolo/votingaccnew/blob/main/includes/election_day_drafts.php"
click node_student_records "https://github.com/piyolo/votingaccnew/blob/main/includes/student_records.php"
click node_functions "https://github.com/piyolo/votingaccnew/blob/main/includes/functions.php"
click node_database "https://github.com/piyolo/votingaccnew/blob/main/config/db.php"
click node_guide_app "https://github.com/piyolo/votingaccnew/blob/main/guide/index.php"
click node_guide_config "https://github.com/piyolo/votingaccnew/blob/main/guide/config.php"
click node_guide_annotations "https://github.com/piyolo/votingaccnew/blob/main/guide/data/annotations.php"
click node_guide_system "https://github.com/piyolo/votingaccnew/blob/main/guide/data/system.php"
click node_guide_source "https://github.com/piyolo/votingaccnew/blob/main/guide/lib/source.php"
click node_guide_snippet "https://github.com/piyolo/votingaccnew/blob/main/guide/api/snippet.php"
click node_guide_validate "https://github.com/piyolo/votingaccnew/blob/main/guide/api/validate.php"

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_landing,node_student_auth,node_registration,node_student_dashboard,node_draft,node_vote,node_results toneBlue
class node_admin_login,node_admin_dashboard,node_elections_api,node_settings_api,node_students_api,node_admins_api,node_logs_api,node_school_year_api toneAmber
class node_draft_helpers,node_student_records,node_functions,node_database toneMint
class node_guide_app,node_guide_config,node_guide_annotations,node_guide_system,node_guide_source,node_guide_snippet,node_guide_validate toneRose
class node_student_actor,node_admin_actor,node_guide_user toneIndigo
```

## Components

### Student voting

- [Public landing](https://github.com/piyolo/votingaccnew/blob/main/public/landingpage.php): `public/landingpage.php`
- [Student accounts](https://github.com/piyolo/votingaccnew/blob/main/student/login.php): `student/login.php`
- [Registration](https://github.com/piyolo/votingaccnew/blob/main/student/register.php): `student/register.php`
- [Student dashboard](https://github.com/piyolo/votingaccnew/blob/main/student/dashboard.php): `student/dashboard.php`
- [Ballot drafts](https://github.com/piyolo/votingaccnew/blob/main/student/draft.php): `student/draft.php`
- [Vote submission](https://github.com/piyolo/votingaccnew/blob/main/student/vote.php): `student/vote.php`
- [Election results](https://github.com/piyolo/votingaccnew/blob/main/public/results.php): `public/results.php`

### Election administration

- [Admin login](https://github.com/piyolo/votingaccnew/blob/main/admin/login.php): `admin/login.php`
- [Admin dashboard](https://github.com/piyolo/votingaccnew/blob/main/admin/dashboard.php): `admin/dashboard.php`
- [Election management](https://github.com/piyolo/votingaccnew/blob/main/admin/api/elections.php): `admin/api/elections.php`
- [Election settings](https://github.com/piyolo/votingaccnew/blob/main/admin/api/settings.php): `admin/api/settings.php`
- [Student records admin](https://github.com/piyolo/votingaccnew/blob/main/admin/api/students.php): `admin/api/students.php`
- [Admin accounts](https://github.com/piyolo/votingaccnew/blob/main/admin/api/admins.php): `admin/api/admins.php`
- [Admin logs](https://github.com/piyolo/votingaccnew/blob/main/admin/api/logs.php): `admin/api/logs.php`
- [School-year data](https://github.com/piyolo/votingaccnew/blob/main/admin/api/next-school-year.php): `admin/api/next-school-year.php`

### Shared services

- [Election-day drafts](https://github.com/piyolo/votingaccnew/blob/main/includes/election_day_drafts.php): `includes/election_day_drafts.php`
- [Student record logic](https://github.com/piyolo/votingaccnew/blob/main/includes/student_records.php): `includes/student_records.php`
- [Shared application logic](https://github.com/piyolo/votingaccnew/blob/main/includes/functions.php): `includes/functions.php`
- [PDO database](https://github.com/piyolo/votingaccnew/blob/main/config/db.php): `config/db.php`

### Guided code tour

- [Tour interface](https://github.com/piyolo/votingaccnew/blob/main/guide/index.php): `guide/index.php`
- [Tour configuration](https://github.com/piyolo/votingaccnew/blob/main/guide/config.php): `guide/config.php`
- [Tour chapters](https://github.com/piyolo/votingaccnew/blob/main/guide/data/annotations.php): `guide/data/annotations.php`
- [System reference](https://github.com/piyolo/votingaccnew/blob/main/guide/data/system.php): `guide/data/system.php`
- [Live source reader](https://github.com/piyolo/votingaccnew/blob/main/guide/lib/source.php): `guide/lib/source.php`
- [Snippet endpoint](https://github.com/piyolo/votingaccnew/blob/main/guide/api/snippet.php): `guide/api/snippet.php`
- [Reference validation](https://github.com/piyolo/votingaccnew/blob/main/guide/api/validate.php): `guide/api/validate.php`

### Other components

- **Student**
- **Administrator**
- **Local guide visitor**

## Connections

- Student → Public landing: visits (evidence: `README.md`)
- Student → Student accounts: signs in (evidence: `README.md`)
- Student → Registration: registers (evidence: `README.md`)
- Student → Student dashboard: uses (evidence: `README.md`)
- Student → Vote submission: submits ballot (evidence: `README.md`)
- Student → Election results: views results (evidence: `README.md`)
- Administrator → Admin login: signs in (evidence: `README.md`)
- Administrator → Admin dashboard: manages elections (evidence: `README.md`)
- Admin login → Shared application logic: uses helpers (evidence: `admin/login.php`)
- Admin login → PDO database: connects (evidence: `admin/login.php`)
- Admin dashboard → Shared application logic: uses helpers (evidence: `admin/dashboard.php`)
- Admin dashboard → PDO database: connects (evidence: `admin/dashboard.php`)
- Election management → Shared application logic: uses helpers (evidence: `admin/api/elections.php`)
- Election management → Election-day drafts: uses draft logic (evidence: `admin/api/elections.php`)
- Election management → PDO database: connects (evidence: `admin/api/elections.php`)
- Election settings → Shared application logic: uses helpers (evidence: `admin/api/settings.php`)
- Election settings → PDO database: connects (evidence: `admin/api/settings.php`)
- Student records admin → Shared application logic: uses helpers (evidence: `admin/api/students.php`)
- Student records admin → Student record logic: uses record logic (evidence: `admin/api/students.php`)
- Student records admin → PDO database: connects (evidence: `admin/api/students.php`)
- Admin accounts → Shared application logic: uses helpers (evidence: `admin/api/admins.php`)
- Admin accounts → PDO database: connects (evidence: `admin/api/admins.php`)
- Student dashboard → Shared application logic: uses helpers (evidence: `student/dashboard.php`)
- Student dashboard → PDO database: connects (evidence: `student/dashboard.php`)
- Registration → Shared application logic: uses helpers (evidence: `student/register.php`)
- Registration → Student record logic: uses record logic (evidence: `student/register.php`)
- Registration → PDO database: connects (evidence: `student/register.php`)
- Student accounts → Shared application logic: uses helpers (evidence: `student/login.php`)
- Student accounts → PDO database: connects (evidence: `student/login.php`)
- Election results → Shared application logic: uses helpers (evidence: `public/results.php`)
- Election results → PDO database: connects (evidence: `public/results.php`)
- Local guide visitor → Tour interface: opens tour (evidence: `README.md`)
- Tour interface → Tour configuration: loads configuration (evidence: `guide/index.php`)
- Tour configuration → Tour chapters: loads chapters (evidence: `guide/config.php`)
- Tour configuration → System reference: loads reference (evidence: `guide/config.php`)
- Snippet endpoint → Tour configuration: uses configuration (evidence: `guide/api/snippet.php`)
- Snippet endpoint → Live source reader: reads source (evidence: `guide/api/snippet.php`)
- Reference validation → Tour configuration: uses configuration (evidence: `guide/api/validate.php`)
- Reference validation → Live source reader: validates source (evidence: `guide/api/validate.php`)
