# coding-kro/votepulse architecture

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

- Interactive diagram: https://gitdiagram.com/coding-kro/votepulse
- Repository: https://github.com/coding-kro/votepulse

## Overview

LivePoll is a browser-based polling app: people browse polls or create one, open a poll to vote, and see updated results. The React pages make REST requests to the Express API; route handlers delegate poll operations to the Mongoose model, with MongoDB providing persistence. Voting also has a Socket.io path: the poll page joins a room and submits votes, while the server broadcasts updated poll state to that room. The README documents responsive and accessible UI behavior and local vote retention. The excerpts show the REST and socket paths, though the frontend socket configuration and some page behavior were not fully sampled.

Main entry points: [`backend/server.js`](https://github.com/coding-kro/votepulse/blob/main/backend/server.js) (HTTP and socket server), [`frontend/src/App.jsx`](https://github.com/coding-kro/votepulse/blob/main/frontend/src/App.jsx) (React app router), [`frontend/src/pages/PollPage.jsx`](https://github.com/coding-kro/votepulse/blob/main/frontend/src/pages/PollPage.jsx) (Vote and results), [`backend/src/app.js`](https://github.com/coding-kro/votepulse/blob/main/backend/src/app.js) (Express app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["React app router<br/>[App.jsx]"]
  node_navbar["Navigation bar<br/>[Navbar.jsx]"]
  node_home["Poll directory<br/>[HomePage.jsx]"]
  node_card["Poll preview card<br/>[PollCard.jsx]"]
  node_create["Poll creation<br/>[CreatePage.jsx]"]
  node_detail["Vote and results<br/>[PollPage.jsx]"]
end

subgraph group_api["REST API"]
  node_express["Express app<br/>[app.js]"]
  node_routes["Poll API routes<br/>[poll.routes.js]"]
  node_controller["Poll operations<br/>[poll.controller.js]"]
end

subgraph group_realtime["Live updates"]
  node_socketclient["Socket client<br/>[socket.js]"]
  node_server["HTTP and socket server<br/>[server.js]"]
end

subgraph group_persistence["Poll persistence"]
  node_model["Poll model<br/>[poll.model.js]"]
  node_dbconnect["Database connection<br/>[db.js]"]
end

node_person(("Poll participant"))
node_mongodb[("MongoDB")]

node_person -->|"uses"| node_app
node_app -->|"renders"| node_navbar
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_detail
node_app -->|"routes to"| node_create
node_home -->|"fetches polls"| node_express
node_home -->|"renders"| node_card
node_card -->|"opens poll"| node_detail
node_create -->|"creates poll"| node_express
node_detail -->|"fetches poll"| node_express
node_detail -->|"emits and listens"| node_socketclient
node_socketclient -->|"exchanges events"| node_server
node_detail -->|"joins and votes"| node_server
node_server -->|"reads and saves"| node_model
node_server -->|"broadcasts updates"| node_server
node_server -->|"serves app"| node_express
node_express -->|"mounts routes"| node_routes
node_routes -->|"dispatches"| node_controller
node_controller -->|"queries and saves"| node_model
node_server -->|"connects on startup"| node_dbconnect
node_dbconnect -->|"connects"| node_mongodb
node_model -.->|"persists poll data"| node_mongodb

click node_app "https://github.com/coding-kro/votepulse/blob/main/frontend/src/App.jsx"
click node_navbar "https://github.com/coding-kro/votepulse/blob/main/frontend/src/components/Navbar.jsx"
click node_home "https://github.com/coding-kro/votepulse/blob/main/frontend/src/pages/HomePage.jsx"
click node_card "https://github.com/coding-kro/votepulse/blob/main/frontend/src/components/PollCard.jsx"
click node_create "https://github.com/coding-kro/votepulse/blob/main/frontend/src/pages/CreatePage.jsx"
click node_detail "https://github.com/coding-kro/votepulse/blob/main/frontend/src/pages/PollPage.jsx"
click node_socketclient "https://github.com/coding-kro/votepulse/blob/main/frontend/src/socket.js"
click node_express "https://github.com/coding-kro/votepulse/blob/main/backend/src/app.js"
click node_routes "https://github.com/coding-kro/votepulse/blob/main/backend/src/routes/poll.routes.js"
click node_controller "https://github.com/coding-kro/votepulse/blob/main/backend/src/controllers/poll.controller.js"
click node_server "https://github.com/coding-kro/votepulse/blob/main/backend/server.js"
click node_model "https://github.com/coding-kro/votepulse/blob/main/backend/src/models/poll.model.js"
click node_dbconnect "https://github.com/coding-kro/votepulse/blob/main/backend/src/db/db.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_navbar,node_home,node_card,node_create,node_detail toneBlue
class node_express,node_routes,node_controller,node_mongodb toneAmber
class node_socketclient,node_server toneMint
class node_model,node_dbconnect toneRose
class node_person toneIndigo
```

## Components

### Web application

- [React app router](https://github.com/coding-kro/votepulse/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Navigation bar](https://github.com/coding-kro/votepulse/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Poll directory](https://github.com/coding-kro/votepulse/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Poll preview card](https://github.com/coding-kro/votepulse/blob/main/frontend/src/components/PollCard.jsx): `frontend/src/components/PollCard.jsx`
- [Poll creation](https://github.com/coding-kro/votepulse/blob/main/frontend/src/pages/CreatePage.jsx): `frontend/src/pages/CreatePage.jsx`
- [Vote and results](https://github.com/coding-kro/votepulse/blob/main/frontend/src/pages/PollPage.jsx): `frontend/src/pages/PollPage.jsx`

### REST API

- [Express app](https://github.com/coding-kro/votepulse/blob/main/backend/src/app.js): `backend/src/app.js`
- [Poll API routes](https://github.com/coding-kro/votepulse/blob/main/backend/src/routes/poll.routes.js): `backend/src/routes/poll.routes.js`
- [Poll operations](https://github.com/coding-kro/votepulse/blob/main/backend/src/controllers/poll.controller.js): `backend/src/controllers/poll.controller.js`

### Live updates

- [Socket client](https://github.com/coding-kro/votepulse/blob/main/frontend/src/socket.js): `frontend/src/socket.js`
- [HTTP and socket server](https://github.com/coding-kro/votepulse/blob/main/backend/server.js): `backend/server.js`

### Poll persistence

- [Poll model](https://github.com/coding-kro/votepulse/blob/main/backend/src/models/poll.model.js): `backend/src/models/poll.model.js`
- [Database connection](https://github.com/coding-kro/votepulse/blob/main/backend/src/db/db.js): `backend/src/db/db.js`

### Other components

- **Poll participant**
- **MongoDB**

## Connections

- Poll participant → React app router: uses (evidence: `frontend/src/App.jsx`)
- React app router → Navigation bar: renders (evidence: `frontend/src/App.jsx`)
- React app router → Poll directory: routes to (evidence: `frontend/src/App.jsx`)
- React app router → Vote and results: routes to (evidence: `frontend/src/App.jsx`)
- React app router → Poll creation: routes to (evidence: `frontend/src/App.jsx`)
- Poll directory → Express app: fetches polls (evidence: `frontend/src/pages/HomePage.jsx`)
- Poll directory → Poll preview card: renders (evidence: `frontend/src/pages/HomePage.jsx`)
- Poll preview card → Vote and results: opens poll (evidence: `frontend/src/components/PollCard.jsx`)
- Poll creation → Express app: creates poll (evidence: `frontend/src/pages/CreatePage.jsx`)
- Vote and results → Express app: fetches poll (evidence: `frontend/src/pages/PollPage.jsx`)
- Vote and results → Socket client: emits and listens (evidence: `frontend/src/pages/PollPage.jsx`)
- Socket client → HTTP and socket server: exchanges events (evidence: `README.md`)
- Vote and results → HTTP and socket server: joins and votes (evidence: `README.md`)
- HTTP and socket server → Poll model: reads and saves (evidence: `backend/server.js`)
- HTTP and socket server → HTTP and socket server: broadcasts updates (evidence: `backend/server.js`)
- HTTP and socket server → Express app: serves app (evidence: `backend/server.js`)
- Express app → Poll API routes: mounts routes (evidence: `backend/src/app.js`)
- Poll API routes → Poll operations: dispatches (evidence: `backend/src/routes/poll.routes.js`)
- Poll operations → Poll model: queries and saves (evidence: `backend/src/controllers/poll.controller.js`)
- HTTP and socket server → Database connection: connects on startup (evidence: `backend/server.js`)
- Database connection → MongoDB: connects (evidence: `backend/src/db/db.js`)
- Poll model → MongoDB: persists poll data
