# mateus-vonrandow/poll architecture

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

- Interactive diagram: https://gitdiagram.com/mateus-vonrandow/poll
- Repository: https://github.com/mateus-vonrandow/poll

## Overview

This is a small PHP website for creating and voting in a single active poll, with a results page. The main workflow is to create a poll and its options, make it active, accept a vote, and display the active poll or its results. Shared templates render the pages, while the library provides database access and cookie-based vote tracking. The README is empty; relationships below are limited to those visible in the supplied excerpts or SOURCE INDEX, so the results view’s internal behavior is not expanded.

Main entry points: [`template.php`](https://github.com/mateus-vonrandow/poll/blob/main/template.php) (Page renderer), [`lib.php`](https://github.com/mateus-vonrandow/poll/blob/main/lib.php) (Poll data and cookies), [`index.php`](https://github.com/mateus-vonrandow/poll/blob/main/index.php) (Home endpoint), [`resultados.php`](https://github.com/mateus-vonrandow/poll/blob/main/resultados.php) (Results endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web pages"]
  node_home_page["Home endpoint<br/>[index.php]"]
  node_create_page["Create endpoint<br/>[criar.php]"]
  node_results_page["Results endpoint<br/>[resultados.php]"]
  node_vote_endpoint["Vote endpoint<br/>[vote.php]"]
  node_create_view["Poll creation view<br/>[create.php]"]
end

subgraph group_presentation["Presentation"]
  node_template["Page renderer<br/>[template.php]"]
  node_header["Header<br/>[header.php]"]
  node_head["HTML head<br/>[head.php]"]
  node_footer["Footer<br/>[footer.php]"]
  node_widget["Poll widget<br/>[poll_widget.php]"]
  node_home_view["Home view<br/>[home.php]"]
  node_results_view["Results view<br/>[results.php]"]
end

subgraph group_runtime["Poll runtime"]
  node_poll_library["Poll data and cookies<br/>[lib.php]"]
end

subgraph group_storage["Persistence"]
  node_db_config["Database configuration<br/>[config.php]"]
  node_poll_db[("Poll database<br/>[schema.sql]")]
end

node_visitor(("Visitor"))

node_visitor -->|"opens"| node_home_page
node_visitor -->|"opens"| node_create_page
node_visitor -->|"opens"| node_results_page
node_home_page -->|"loads poll"| node_poll_library
node_home_page -->|"renders"| node_template
node_create_page -->|"renders"| node_template
node_results_page -->|"loads poll"| node_poll_library
node_results_page -->|"renders"| node_template
node_template -->|"includes"| node_header
node_template -->|"dispatches view"| node_home_view
node_template -->|"dispatches view"| node_create_view
node_template -->|"dispatches view"| node_results_view
node_template -->|"includes"| node_footer
node_header -->|"includes"| node_head
node_footer -->|"includes when enabled"| node_widget
node_widget -->|"submits vote"| node_vote_endpoint
node_vote_endpoint -->|"uses vote helpers"| node_poll_library
node_poll_library -->|"loads settings"| node_db_config
node_poll_library -->|"reads poll data"| node_poll_db
node_create_view -->|"creates poll records"| node_poll_db
node_vote_endpoint -->|"validates and updates vote"| node_poll_db

click node_home_page "https://github.com/mateus-vonrandow/poll/blob/main/index.php"
click node_create_page "https://github.com/mateus-vonrandow/poll/blob/main/criar.php"
click node_results_page "https://github.com/mateus-vonrandow/poll/blob/main/resultados.php"
click node_vote_endpoint "https://github.com/mateus-vonrandow/poll/blob/main/vote.php"
click node_template "https://github.com/mateus-vonrandow/poll/blob/main/template.php"
click node_header "https://github.com/mateus-vonrandow/poll/blob/main/partials/header.php"
click node_head "https://github.com/mateus-vonrandow/poll/blob/main/partials/head.php"
click node_footer "https://github.com/mateus-vonrandow/poll/blob/main/partials/footer.php"
click node_widget "https://github.com/mateus-vonrandow/poll/blob/main/partials/poll_widget.php"
click node_home_view "https://github.com/mateus-vonrandow/poll/blob/main/views/home.php"
click node_create_view "https://github.com/mateus-vonrandow/poll/blob/main/views/create.php"
click node_results_view "https://github.com/mateus-vonrandow/poll/blob/main/views/results.php"
click node_poll_library "https://github.com/mateus-vonrandow/poll/blob/main/lib.php"
click node_db_config "https://github.com/mateus-vonrandow/poll/blob/main/config.php"
click node_poll_db "https://github.com/mateus-vonrandow/poll/blob/main/schema.sql"

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_home_page,node_create_page,node_results_page,node_vote_endpoint,node_create_view toneBlue
class node_template,node_header,node_head,node_footer,node_widget,node_home_view,node_results_view toneAmber
class node_poll_library toneMint
class node_db_config,node_poll_db toneRose
class node_visitor toneIndigo
```

## Components

### Web pages

- [Home endpoint](https://github.com/mateus-vonrandow/poll/blob/main/index.php): `index.php`
- [Create endpoint](https://github.com/mateus-vonrandow/poll/blob/main/criar.php): `criar.php`
- [Results endpoint](https://github.com/mateus-vonrandow/poll/blob/main/resultados.php): `resultados.php`
- [Vote endpoint](https://github.com/mateus-vonrandow/poll/blob/main/vote.php): `vote.php`
- [Poll creation view](https://github.com/mateus-vonrandow/poll/blob/main/views/create.php): `views/create.php`

### Presentation

- [Page renderer](https://github.com/mateus-vonrandow/poll/blob/main/template.php): `template.php`
- [Header](https://github.com/mateus-vonrandow/poll/blob/main/partials/header.php): `partials/header.php`
- [HTML head](https://github.com/mateus-vonrandow/poll/blob/main/partials/head.php): `partials/head.php`
- [Footer](https://github.com/mateus-vonrandow/poll/blob/main/partials/footer.php): `partials/footer.php`
- [Poll widget](https://github.com/mateus-vonrandow/poll/blob/main/partials/poll_widget.php): `partials/poll_widget.php`
- [Home view](https://github.com/mateus-vonrandow/poll/blob/main/views/home.php): `views/home.php`
- [Results view](https://github.com/mateus-vonrandow/poll/blob/main/views/results.php): `views/results.php`

### Poll runtime

- [Poll data and cookies](https://github.com/mateus-vonrandow/poll/blob/main/lib.php): `lib.php`

### Persistence

- [Database configuration](https://github.com/mateus-vonrandow/poll/blob/main/config.php): `config.php`
- [Poll database](https://github.com/mateus-vonrandow/poll/blob/main/schema.sql): `schema.sql`

### Other components

- **Visitor**

## Connections

- Visitor → Home endpoint: opens
- Visitor → Create endpoint: opens
- Visitor → Results endpoint: opens
- Home endpoint → Poll data and cookies: loads poll (evidence: `index.php`)
- Home endpoint → Page renderer: renders (evidence: `index.php`)
- Create endpoint → Page renderer: renders (evidence: `criar.php`)
- Results endpoint → Poll data and cookies: loads poll (evidence: `resultados.php`)
- Results endpoint → Page renderer: renders (evidence: `resultados.php`)
- Page renderer → Header: includes (evidence: `template.php`)
- Page renderer → Home view: dispatches view (evidence: `template.php`)
- Page renderer → Poll creation view: dispatches view (evidence: `template.php`)
- Page renderer → Results view: dispatches view (evidence: `template.php`)
- Page renderer → Footer: includes (evidence: `template.php`)
- Header → HTML head: includes (evidence: `partials/header.php`)
- Footer → Poll widget: includes when enabled (evidence: `partials/footer.php`)
- Poll widget → Vote endpoint: submits vote (evidence: `partials/poll_widget.php`)
- Vote endpoint → Poll data and cookies: uses vote helpers (evidence: `vote.php`)
- Poll data and cookies → Database configuration: loads settings (evidence: `lib.php`)
- Poll data and cookies → Poll database: reads poll data (evidence: `lib.php`)
- Poll creation view → Poll database: creates poll records (evidence: `views/create.php`)
- Vote endpoint → Poll database: validates and updates vote (evidence: `vote.php`)
