# bhargavshekhar/pollx architecture

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

- Interactive diagram: https://gitdiagram.com/bhargavshekhar/pollx
- Repository: https://github.com/bhargavshekhar/pollx

## Overview

PollX lets creators authenticate, define and manage polls, share public links, collect anonymous or authenticated single-choice responses, and inspect or publish results. The main workflow runs from the React routes through API services to Express controllers and poll services, which persist poll state and votes in PostgreSQL; Socket.io broadcasts vote counts to analytics viewers. The README documents these product capabilities and endpoint behavior. Some page-to-service wiring and socket client usage were not excerpted, so those relationships are omitted or marked unverified rather than inferred from names.

Main entry points: [`client/src/App.tsx`](https://github.com/bhargavshekhar/pollx/blob/main/client/src/App.tsx) (App routes), [`server/src/app/auth/auth.services.ts`](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.services.ts) (Auth operations), [`client/src/services/pollService.ts`](https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/pollService.ts) (Poll client), [`server/src/app/poll/poll.services.ts`](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.services.ts) (Poll operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_routes["App routes<br/>[App.tsx]"]
  node_auth_pages["Sign-in and signup<br/>[Login.tsx]"]
  node_dashboard["Poll dashboard<br/>[Dashbord.tsx]"]
  node_create_page["Poll creation<br/>[CreatePoll.tsx]"]
  node_analytics_page["Analytics view<br/>[Analytics.tsx]"]
  node_public_page["Public poll view<br/>[PublicPoll.tsx]"]
  node_poll_views["Voting and results<br/>[VoteView.tsx]"]
  node_api_client["HTTP client<br/>[api.ts]"]
  node_auth_client["Auth client<br/>[authService.ts]"]
  node_poll_client["Poll client<br/>[pollService.ts]"]
  node_token_store["Token storage<br/>[tokenStore.ts]"]
  node_socket_client["Live socket client<br/>[socket.ts]"]
end

subgraph group_auth["Authentication"]
  node_auth_routes["Auth endpoints<br/>[auth.routes.ts]"]
  node_auth_controller["Auth handlers"]
  node_auth_service["Auth operations<br/>[auth.services.ts]"]
  node_auth_models["Auth validation<br/>[auth.models.ts]"]
  node_token_utils["JWT utilities<br/>[token.ts]"]
  node_auth_middleware["Access guard<br/>[auth-middleware.ts]"]
end

subgraph group_poll["Poll management"]
  node_poll_routes["Poll endpoints<br/>[poll.routes.ts]"]
  node_poll_controller["Poll handlers"]
  node_poll_service["Poll operations<br/>[poll.services.ts]"]
  node_poll_models["Poll validation<br/>[poll.models.ts]"]
end

subgraph group_platform["Runtime and persistence"]
  node_express_app["Express app<br/>[index.ts]"]
  node_server["HTTP server<br/>[server.ts]"]
  node_socket_server["Socket.IO server<br/>[index.ts]"]
  node_database[("PostgreSQL")]
  node_schema["Poll and user schema<br/>[schema.ts]"]
  node_db_client["Drizzle database<br/>[index.ts]"]
end

node_visitor(("Visitor or creator"))

node_visitor -->|"opens app"| node_routes
node_routes -->|"routes to"| node_auth_pages
node_routes -->|"routes to"| node_dashboard
node_routes -->|"routes to"| node_create_page
node_routes -->|"routes to"| node_analytics_page
node_routes -->|"routes to"| node_public_page
node_auth_pages -.->|"uses"| node_auth_client
node_create_page -.->|"uses"| node_poll_client
node_dashboard -.->|"uses"| node_poll_client
node_analytics_page -.->|"uses"| node_poll_client
node_public_page -.->|"uses"| node_poll_client
node_public_page -.->|"renders"| node_poll_views
node_auth_client -->|"calls"| node_api_client
node_auth_client -->|"stores tokens"| node_token_store
node_poll_client -->|"calls"| node_api_client
node_api_client -.->|"HTTP requests"| node_auth_routes
node_api_client -.->|"HTTP requests"| node_poll_routes
node_server -->|"creates app"| node_express_app
node_server -->|"initializes"| node_socket_server
node_express_app -->|"mounts routes"| node_auth_routes
node_express_app -->|"mounts routes"| node_poll_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"uses DTOs"| node_auth_models
node_auth_service -->|"queries"| node_db_client
node_auth_service -->|"reads and writes"| node_schema
node_auth_controller -->|"validates with"| node_auth_models
node_auth_service -->|"creates and verifies"| node_token_utils
node_auth_middleware -->|"verifies token"| node_token_utils
node_poll_routes -->|"dispatches"| node_poll_controller
node_poll_routes -->|"guards routes"| node_auth_middleware
node_poll_controller -->|"calls"| node_poll_service
node_poll_controller -->|"validates with"| node_poll_models
node_poll_service -->|"queries"| node_db_client
node_poll_service -->|"reads and writes"| node_schema
node_poll_service -->|"broadcasts vote count"| node_socket_server
node_db_client -.->|"connects"| node_database
node_db_client -->|"configures queries"| node_schema
node_analytics_page -.->|"joins and listens"| node_socket_client
node_socket_client -.->|"receives events"| node_socket_server

click node_routes "https://github.com/bhargavshekhar/pollx/blob/main/client/src/App.tsx"
click node_auth_pages "https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/Login.tsx"
click node_dashboard "https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/Dashbord.tsx"
click node_create_page "https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/CreatePoll.tsx"
click node_analytics_page "https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/Analytics.tsx"
click node_public_page "https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/PublicPoll.tsx"
click node_poll_views "https://github.com/bhargavshekhar/pollx/blob/main/client/src/components/VoteView.tsx"
click node_api_client "https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/api.ts"
click node_auth_client "https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/authService.ts"
click node_poll_client "https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/pollService.ts"
click node_token_store "https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/tokenStore.ts"
click node_socket_client "https://github.com/bhargavshekhar/pollx/blob/main/client/src/lib/socket.ts"
click node_auth_routes "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.routes.ts"
click node_auth_controller "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.controllers.ts"
click node_auth_service "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.services.ts"
click node_auth_models "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.models.ts"
click node_token_utils "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/utils/token.ts"
click node_poll_routes "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.routes.ts"
click node_poll_controller "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.controllers.ts"
click node_poll_service "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.services.ts"
click node_poll_models "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.models.ts"
click node_auth_middleware "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/middleware/auth-middleware.ts"
click node_express_app "https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/index.ts"
click node_server "https://github.com/bhargavshekhar/pollx/blob/main/server/src/server.ts"
click node_socket_server "https://github.com/bhargavshekhar/pollx/blob/main/server/src/socket/index.ts"
click node_schema "https://github.com/bhargavshekhar/pollx/blob/main/server/src/db/schema.ts"
click node_db_client "https://github.com/bhargavshekhar/pollx/blob/main/server/src/db/index.ts"

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_routes,node_auth_pages,node_dashboard,node_create_page,node_analytics_page,node_public_page,node_poll_views,node_api_client,node_auth_client,node_poll_client,node_token_store,node_socket_client toneBlue
class node_auth_routes,node_auth_controller,node_auth_service,node_auth_models,node_token_utils,node_auth_middleware toneAmber
class node_poll_routes,node_poll_controller,node_poll_service,node_poll_models toneMint
class node_express_app,node_server,node_socket_server,node_database,node_schema,node_db_client toneRose
class node_visitor toneIndigo
```

## Components

### Web application

- [App routes](https://github.com/bhargavshekhar/pollx/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Sign-in and signup](https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/Login.tsx): `client/src/pages/Login.tsx`
- [Poll dashboard](https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/Dashbord.tsx): `client/src/pages/Dashbord.tsx`
- [Poll creation](https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/CreatePoll.tsx): `client/src/pages/CreatePoll.tsx`
- [Analytics view](https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/Analytics.tsx): `client/src/pages/Analytics.tsx`
- [Public poll view](https://github.com/bhargavshekhar/pollx/blob/main/client/src/pages/PublicPoll.tsx): `client/src/pages/PublicPoll.tsx`
- [Voting and results](https://github.com/bhargavshekhar/pollx/blob/main/client/src/components/VoteView.tsx): `client/src/components/VoteView.tsx`
- [HTTP client](https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/api.ts): `client/src/services/api.ts`
- [Auth client](https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/authService.ts): `client/src/services/authService.ts`
- [Poll client](https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/pollService.ts): `client/src/services/pollService.ts`
- [Token storage](https://github.com/bhargavshekhar/pollx/blob/main/client/src/services/tokenStore.ts): `client/src/services/tokenStore.ts`
- [Live socket client](https://github.com/bhargavshekhar/pollx/blob/main/client/src/lib/socket.ts): `client/src/lib/socket.ts`

### Authentication

- [Auth endpoints](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.routes.ts): `server/src/app/auth/auth.routes.ts`
- [Auth handlers](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.controllers.ts): `server/src/app/auth/auth.controllers.ts`
- [Auth operations](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.services.ts): `server/src/app/auth/auth.services.ts`
- [Auth validation](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/auth.models.ts): `server/src/app/auth/auth.models.ts`
- [JWT utilities](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/auth/utils/token.ts): `server/src/app/auth/utils/token.ts`
- [Access guard](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/middleware/auth-middleware.ts): `server/src/app/middleware/auth-middleware.ts`

### Poll management

- [Poll endpoints](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.routes.ts): `server/src/app/poll/poll.routes.ts`
- [Poll handlers](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.controllers.ts): `server/src/app/poll/poll.controllers.ts`
- [Poll operations](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.services.ts): `server/src/app/poll/poll.services.ts`
- [Poll validation](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/poll/poll.models.ts): `server/src/app/poll/poll.models.ts`

### Runtime and persistence

- [Express app](https://github.com/bhargavshekhar/pollx/blob/main/server/src/app/index.ts): `server/src/app/index.ts`
- [HTTP server](https://github.com/bhargavshekhar/pollx/blob/main/server/src/server.ts): `server/src/server.ts`
- [Socket.IO server](https://github.com/bhargavshekhar/pollx/blob/main/server/src/socket/index.ts): `server/src/socket/index.ts`
- **PostgreSQL**
- [Poll and user schema](https://github.com/bhargavshekhar/pollx/blob/main/server/src/db/schema.ts): `server/src/db/schema.ts`
- [Drizzle database](https://github.com/bhargavshekhar/pollx/blob/main/server/src/db/index.ts): `server/src/db/index.ts`

### Other components

- **Visitor or creator**

## Connections

- Visitor or creator → App routes: opens app (evidence: `client/src/App.tsx`)
- App routes → Sign-in and signup: routes to (evidence: `client/src/App.tsx`)
- App routes → Poll dashboard: routes to (evidence: `client/src/App.tsx`)
- App routes → Poll creation: routes to (evidence: `client/src/App.tsx`)
- App routes → Analytics view: routes to (evidence: `client/src/App.tsx`)
- App routes → Public poll view: routes to (evidence: `client/src/App.tsx`)
- Sign-in and signup → Auth client: uses
- Poll creation → Poll client: uses
- Poll dashboard → Poll client: uses
- Analytics view → Poll client: uses
- Public poll view → Poll client: uses
- Public poll view → Voting and results: renders
- Auth client → HTTP client: calls (evidence: `client/src/services/authService.ts`)
- Auth client → Token storage: stores tokens (evidence: `client/src/services/authService.ts`)
- Poll client → HTTP client: calls (evidence: `client/src/services/pollService.ts`)
- HTTP client → Auth endpoints: HTTP requests (evidence: `README.md`)
- HTTP client → Poll endpoints: HTTP requests (evidence: `README.md`)
- HTTP server → Express app: creates app (evidence: `server/src/server.ts`)
- HTTP server → Socket.IO server: initializes (evidence: `server/src/server.ts`)
- Express app → Auth endpoints: mounts routes (evidence: `server/src/app/index.ts`)
- Express app → Poll endpoints: mounts routes (evidence: `server/src/app/index.ts`)
- Auth endpoints → Auth handlers: dispatches (evidence: `server/src/app/auth/auth.routes.ts`)
- Auth handlers → Auth operations: calls (evidence: `server/src/app/auth/auth.controllers.ts`)
- Auth operations → Auth validation: uses DTOs (evidence: `server/src/app/auth/auth.services.ts`)
- Auth operations → Drizzle database: queries (evidence: `server/src/app/auth/auth.services.ts`)
- Auth operations → Poll and user schema: reads and writes (evidence: `server/src/app/auth/auth.services.ts`)
- Auth handlers → Auth validation: validates with (evidence: `server/src/app/auth/auth.controllers.ts`)
- Auth operations → JWT utilities: creates and verifies (evidence: `server/src/app/auth/auth.services.ts`)
- Access guard → JWT utilities: verifies token (evidence: `server/src/app/middleware/auth-middleware.ts`)
- Poll endpoints → Poll handlers: dispatches (evidence: `server/src/app/poll/poll.routes.ts`)
- Poll endpoints → Access guard: guards routes (evidence: `server/src/app/poll/poll.routes.ts`)
- Poll handlers → Poll operations: calls (evidence: `server/src/app/poll/poll.controllers.ts`)
- Poll handlers → Poll validation: validates with (evidence: `server/src/app/poll/poll.controllers.ts`)
- Poll operations → Drizzle database: queries (evidence: `server/src/app/poll/poll.services.ts`)
- Poll operations → Poll and user schema: reads and writes (evidence: `server/src/app/poll/poll.services.ts`)
- Poll operations → Socket.IO server: broadcasts vote count (evidence: `server/src/app/poll/poll.services.ts`)
- Drizzle database → PostgreSQL: connects
- Drizzle database → Poll and user schema: configures queries (evidence: `server/src/db/index.ts`)
- Analytics view → Live socket client: joins and listens (evidence: `README.md`)
- Live socket client → Socket.IO server: receives events (evidence: `README.md`)
