# naveencreation/realtime-polling-app architecture

> Architecture diagram of the GitHub repository naveencreation/realtime-polling-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/naveencreation/realtime-polling-app
- Repository: https://github.com/naveencreation/realtime-polling-app

## Overview

Signal Poll is a web polling product for authenticated creators and anonymous voters. Creators sign up or log in, create and manage polls, then share them; visitors load a poll and cast a deduplicated vote. The backend validates poll state, records live tallies and voter identity in Redis, and broadcasts updates over SSE; poll and account records, plus vote audit records, use MongoDB. The graph follows the documented route wiring and sampled handlers/services; some frontend page-to-API calls and unsampled poll-handler details are not shown.

Main entry points: [`frontend/src/App.tsx`](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/App.tsx) (Route application), [`backend/cmd/main.go`](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/cmd/main.go) (HTTP router), [`frontend/src/lib/api.ts`](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/lib/api.ts) (API client), [`backend/internal/poll/handler.go`](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/poll/handler.go) (Poll lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Route application<br/>[App.tsx]"]
  node_authpage["Sign-in pages<br/>[AuthPage.tsx]"]
  node_dashboard["Poll dashboard<br/>[DashboardPage.tsx]"]
  node_create["Poll creation<br/>[CreatePage.tsx]"]
  node_pollpage["Poll view<br/>[PollPage.tsx]"]
  node_pollhook["Live poll state<br/>[usePoll.ts]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["HTTP application"]
  node_router["HTTP router<br/>[main.go]"]
end

subgraph group_domain["Poll and identity"]
  node_auth_handler["Auth endpoints<br/>[handler.go]"]
  node_auth_service["Auth service<br/>[service.go]"]
  node_auth_repo["User repository<br/>[repository.go]"]
  node_poll_handler["Poll lifecycle<br/>[handler.go]"]
  node_poll_repo["Poll repository<br/>[repository.go]"]
  node_vote_handler["Vote processing<br/>[handler.go]"]
  node_vote_service["Live vote service<br/>[service.go]"]
  node_stream_handler["SSE stream<br/>[handler.go]"]
end

subgraph group_state["Persistence and events"]
  node_mongo[("MongoDB")]
  node_redis[("Redis")]
end

node_creator(("Poll creator"))
node_voter(("Poll voter"))

node_creator -->|"uses"| node_app
node_voter -->|"uses"| node_app
node_app -->|"routes"| node_authpage
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_create
node_app -->|"routes"| node_pollpage
node_authpage -->|"requests"| node_api_client
node_dashboard -->|"requests"| node_api_client
node_create -->|"requests"| node_api_client
node_pollpage -->|"uses"| node_pollhook
node_pollhook -->|"loads poll"| node_api_client
node_pollhook -->|"opens SSE"| node_stream_handler
node_api_client -->|"HTTP requests"| node_router
node_router -->|"dispatches auth"| node_auth_handler
node_router -->|"dispatches polls"| node_poll_handler
node_router -->|"dispatches votes"| node_vote_handler
node_router -->|"dispatches SSE"| node_stream_handler
node_auth_handler -->|"hashes tokens"| node_auth_service
node_auth_handler -->|"reads writes users"| node_auth_repo
node_auth_repo -->|"persists users"| node_mongo
node_poll_handler -->|"manages polls"| node_poll_repo
node_poll_handler -->|"reads tallies"| node_vote_service
node_poll_handler -->|"writes vote audits"| node_mongo
node_poll_repo -->|"persists polls"| node_mongo
node_vote_handler -->|"checks poll"| node_poll_repo
node_vote_handler -->|"registers vote"| node_vote_service
node_vote_handler -->|"writes audit"| node_mongo
node_vote_service -->|"tallies dedup publishes"| node_redis
node_stream_handler -->|"checks poll"| node_poll_repo
node_stream_handler -->|"subscribes updates"| node_redis

click node_app "https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/App.tsx"
click node_authpage "https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/pages/AuthPage.tsx"
click node_dashboard "https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/pages/DashboardPage.tsx"
click node_create "https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/pages/CreatePage.tsx"
click node_pollpage "https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/pages/PollPage.tsx"
click node_pollhook "https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/lib/usePoll.ts"
click node_api_client "https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/lib/api.ts"
click node_router "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/cmd/main.go"
click node_auth_handler "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/auth/handler.go"
click node_auth_service "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/auth/service.go"
click node_auth_repo "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/auth/repository.go"
click node_poll_handler "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/poll/handler.go"
click node_poll_repo "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/poll/repository.go"
click node_vote_handler "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/vote/handler.go"
click node_vote_service "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/vote/service.go"
click node_stream_handler "https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/realtime/handler.go"

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_authpage,node_dashboard,node_create,node_pollpage,node_pollhook,node_api_client toneBlue
class node_router toneAmber
class node_auth_handler,node_auth_service,node_auth_repo,node_poll_handler,node_poll_repo,node_vote_handler,node_vote_service,node_stream_handler toneMint
class node_mongo,node_redis toneRose
class node_creator,node_voter toneIndigo
```

## Components

### Web application

- [Route application](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Sign-in pages](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/pages/AuthPage.tsx): `frontend/src/pages/AuthPage.tsx`
- [Poll dashboard](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/pages/DashboardPage.tsx): `frontend/src/pages/DashboardPage.tsx`
- [Poll creation](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/pages/CreatePage.tsx): `frontend/src/pages/CreatePage.tsx`
- [Poll view](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/pages/PollPage.tsx): `frontend/src/pages/PollPage.tsx`
- [Live poll state](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/lib/usePoll.ts): `frontend/src/lib/usePoll.ts`
- [API client](https://github.com/naveencreation/realtime-polling-app/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### HTTP application

- [HTTP router](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/cmd/main.go): `backend/cmd/main.go`

### Poll and identity

- [Auth endpoints](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/auth/handler.go): `backend/internal/auth/handler.go`
- [Auth service](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/auth/service.go): `backend/internal/auth/service.go`
- [User repository](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/auth/repository.go): `backend/internal/auth/repository.go`
- [Poll lifecycle](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/poll/handler.go): `backend/internal/poll/handler.go`
- [Poll repository](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/poll/repository.go): `backend/internal/poll/repository.go`
- [Vote processing](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/vote/handler.go): `backend/internal/vote/handler.go`
- [Live vote service](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/vote/service.go): `backend/internal/vote/service.go`
- [SSE stream](https://github.com/naveencreation/realtime-polling-app/blob/main/backend/internal/realtime/handler.go): `backend/internal/realtime/handler.go`

### Persistence and events

- **MongoDB**
- **Redis**

### Other components

- **Poll creator**
- **Poll voter**

## Connections

- Poll creator → Route application: uses
- Poll voter → Route application: uses
- Route application → Sign-in pages: routes
- Route application → Poll dashboard: routes
- Route application → Poll creation: routes
- Route application → Poll view: routes
- Sign-in pages → API client: requests
- Poll dashboard → API client: requests
- Poll creation → API client: requests
- Poll view → Live poll state: uses
- Live poll state → API client: loads poll
- Live poll state → SSE stream: opens SSE
- API client → HTTP router: HTTP requests
- HTTP router → Auth endpoints: dispatches auth
- HTTP router → Poll lifecycle: dispatches polls
- HTTP router → Vote processing: dispatches votes
- HTTP router → SSE stream: dispatches SSE
- Auth endpoints → Auth service: hashes tokens
- Auth endpoints → User repository: reads writes users
- User repository → MongoDB: persists users
- Poll lifecycle → Poll repository: manages polls
- Poll lifecycle → Live vote service: reads tallies
- Poll lifecycle → MongoDB: writes vote audits
- Poll repository → MongoDB: persists polls
- Vote processing → Poll repository: checks poll
- Vote processing → Live vote service: registers vote
- Vote processing → MongoDB: writes audit
- Live vote service → Redis: tallies dedup publishes
- SSE stream → Poll repository: checks poll
- SSE stream → Redis: subscribes updates
