# tanishktewetia/pollpoint architecture

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

- Interactive diagram: https://gitdiagram.com/tanishktewetia/pollpoint
- Repository: https://github.com/tanishktewetia/pollpoint

## Overview

PollPoint is a survey-and-rewards web platform. Admins author surveys manually or import a brief for an AI-generated draft, review and approve a version, then push it to all or selected participants. Participants answer assigned questions, review and submit once, and receive a points receipt; history and balances reflect the ledger. Next.js handles the UI and server actions/routes, while Supabase Auth and PostgreSQL enforce access and transactional rules. The README documents these database guarantees; source excerpts and the index support the application-level links shown here.

Main entry points: [`src/app/api/admin/survey-imports/route.ts`](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/api/admin/survey-imports/route.ts) (Import endpoint), [`src/lib/supabase/server.ts`](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/supabase/server.ts) (Server Supabase client), [`src/components/survey/survey-runner.tsx`](https://github.com/tanishktewetia/pollpoint/blob/main/src/components/survey/survey-runner.tsx) (Survey runner), [`src/app/(user)/dashboard/page.tsx`](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/(user)/dashboard/page.tsx) (Participant dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and navigation"]
  node_auth_pages["Login and signup<br/>[page.tsx]"]
  node_auth_form["Auth form<br/>[auth-form.tsx]"]
  node_auth_actions["Auth actions<br/>[auth.ts]"]
  node_auth_confirm["Email confirmation<br/>[route.ts]"]
  node_guards["Access guards<br/>[guards.ts]"]
  node_landing["Landing page<br/>[landing-page.tsx]"]
end

subgraph group_participant["Participant experience"]
  node_dashboard["Participant dashboard<br/>[page.tsx]"]
  node_survey_runner["Survey runner<br/>[survey-runner.tsx]"]
  node_question_field["Question field<br/>[question-field.tsx]"]
  node_survey_actions["Survey submission<br/>[surveys.ts]"]
  node_history_page["History and points<br/>[page.tsx]"]
  node_history_data["History queries<br/>[history.ts]"]
end

subgraph group_admin["Survey administration"]
  node_admin_workspace["Admin workspace<br/>[page.tsx]"]
  node_survey_builder["Survey builder<br/>[survey-builder.tsx]"]
  node_admin_actions["Admin actions<br/>[admin.ts]"]
  node_admin_data["Admin queries<br/>[admin.ts]"]
  node_push_ui["Audience push<br/>[push-form.tsx]"]
  node_response_review["Response review<br/>[page.tsx]"]
end

subgraph group_imports["Document drafting"]
  node_import_route["Import endpoint<br/>[route.ts]"]
  node_upload["Brief upload<br/>[upload.ts]"]
  node_extract["Text extraction<br/>[extract.ts]"]
  node_gemini["Gemini drafting<br/>[gemini.ts]"]
end

subgraph group_platform["Data and validation"]
  node_authoring["Authoring validation<br/>[authoring.ts]"]
  node_survey_schema["Survey and answer schemas<br/>[schema.ts]"]
  node_supabase_client["Server Supabase client<br/>[server.ts]"]
  node_database_types["Database contracts<br/>[database.ts]"]
end

node_admin_actor(("Admin"))
node_participant_actor(("Participant"))
node_supabase[("Supabase Auth and PostgreSQL")]
node_gemini_service["Gemini API"]

node_participant_actor -->|"opens account pages"| node_auth_pages
node_auth_pages -->|"renders"| node_auth_form
node_auth_form -->|"submits credentials"| node_auth_actions
node_auth_actions -->|"creates session"| node_supabase_client
node_auth_confirm -->|"verifies email"| node_supabase_client
node_guards -->|"checks identity"| node_supabase_client
node_supabase_client -->|"uses Auth and database"| node_supabase
node_participant_actor -->|"opens dashboard"| node_dashboard
node_dashboard -->|"requires participant"| node_guards
node_dashboard -->|"loads assignments and balance"| node_supabase
node_participant_actor -->|"answers assignment"| node_survey_runner
node_survey_runner -->|"renders questions"| node_question_field
node_survey_runner -->|"submits answers"| node_survey_actions
node_survey_actions -->|"calls submit RPC"| node_supabase
node_survey_runner -->|"validates answers"| node_survey_schema
node_participant_actor -->|"views points history"| node_history_page
node_history_page -->|"loads history"| node_history_data
node_history_data -->|"reads ledger history"| node_supabase
node_admin_actor -->|"opens workspace"| node_admin_workspace
node_admin_workspace -->|"requires admin"| node_guards
node_admin_workspace -->|"lists surveys"| node_supabase
node_admin_actor -->|"authors and reviews"| node_survey_builder
node_survey_builder -->|"uses definition contract"| node_authoring
node_survey_builder -->|"saves edits"| node_admin_actions
node_admin_actions -->|"delegates queries"| node_admin_data
node_admin_actions -->|"approves survey"| node_supabase
node_admin_actor -->|"selects audience"| node_push_ui
node_push_ui -->|"pushes assignments"| node_supabase
node_admin_actor -->|"reviews responses"| node_response_review
node_response_review -->|"loads response review"| node_supabase
node_admin_actor -->|"uploads brief"| node_import_route
node_import_route -->|"reads file"| node_upload
node_import_route -->|"extracts text"| node_extract
node_import_route -->|"generates draft"| node_gemini
node_gemini -->|"requests generation"| node_gemini_service
node_import_route -->|"validates generated draft"| node_authoring
node_import_route -->|"records import draft"| node_supabase
node_authoring -->|"derives question rules"| node_survey_schema
node_supabase_client -->|"types client"| node_database_types

click node_auth_pages "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/(auth)/login/page.tsx"
click node_auth_form "https://github.com/tanishktewetia/pollpoint/blob/main/src/components/auth/auth-form.tsx"
click node_auth_actions "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/actions/auth.ts"
click node_auth_confirm "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/auth/confirm/route.ts"
click node_guards "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/auth/guards.ts"
click node_landing "https://github.com/tanishktewetia/pollpoint/blob/main/src/components/landing/landing-page.tsx"
click node_dashboard "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/(user)/dashboard/page.tsx"
click node_survey_runner "https://github.com/tanishktewetia/pollpoint/blob/main/src/components/survey/survey-runner.tsx"
click node_question_field "https://github.com/tanishktewetia/pollpoint/blob/main/src/components/survey/question-field.tsx"
click node_survey_actions "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/actions/surveys.ts"
click node_history_page "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/(user)/history/page.tsx"
click node_history_data "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/data/history.ts"
click node_admin_workspace "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/admin/page.tsx"
click node_survey_builder "https://github.com/tanishktewetia/pollpoint/blob/main/src/components/admin/survey-builder.tsx"
click node_admin_actions "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/actions/admin.ts"
click node_admin_data "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/data/admin.ts"
click node_push_ui "https://github.com/tanishktewetia/pollpoint/blob/main/src/components/admin/push-form.tsx"
click node_response_review "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/admin/surveys/%5BsurveyId%5D/responses/page.tsx"
click node_import_route "https://github.com/tanishktewetia/pollpoint/blob/main/src/app/api/admin/survey-imports/route.ts"
click node_upload "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/server/imports/upload.ts"
click node_extract "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/server/imports/extract.ts"
click node_gemini "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/server/imports/gemini.ts"
click node_authoring "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/survey/authoring.ts"
click node_survey_schema "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/survey/schema.ts"
click node_supabase_client "https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/supabase/server.ts"
click node_database_types "https://github.com/tanishktewetia/pollpoint/blob/main/src/types/database.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_auth_pages,node_auth_form,node_auth_actions,node_auth_confirm,node_guards,node_landing toneBlue
class node_dashboard,node_survey_runner,node_question_field,node_survey_actions,node_history_page,node_history_data,node_supabase toneAmber
class node_admin_workspace,node_survey_builder,node_admin_actions,node_admin_data,node_push_ui,node_response_review,node_gemini_service toneMint
class node_import_route,node_upload,node_extract,node_gemini toneRose
class node_authoring,node_survey_schema,node_supabase_client,node_database_types,node_admin_actor,node_participant_actor toneIndigo
```

## Components

### Identity and navigation

- [Login and signup](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Auth form](https://github.com/tanishktewetia/pollpoint/blob/main/src/components/auth/auth-form.tsx): `src/components/auth/auth-form.tsx`
- [Auth actions](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/actions/auth.ts): `src/app/actions/auth.ts`
- [Email confirmation](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/auth/confirm/route.ts): `src/app/auth/confirm/route.ts`
- [Access guards](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/auth/guards.ts): `src/lib/auth/guards.ts`
- [Landing page](https://github.com/tanishktewetia/pollpoint/blob/main/src/components/landing/landing-page.tsx): `src/components/landing/landing-page.tsx`

### Participant experience

- [Participant dashboard](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/(user)/dashboard/page.tsx): `src/app/(user)/dashboard/page.tsx`
- [Survey runner](https://github.com/tanishktewetia/pollpoint/blob/main/src/components/survey/survey-runner.tsx): `src/components/survey/survey-runner.tsx`
- [Question field](https://github.com/tanishktewetia/pollpoint/blob/main/src/components/survey/question-field.tsx): `src/components/survey/question-field.tsx`
- [Survey submission](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/actions/surveys.ts): `src/app/actions/surveys.ts`
- [History and points](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/(user)/history/page.tsx): `src/app/(user)/history/page.tsx`
- [History queries](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/data/history.ts): `src/lib/data/history.ts`

### Survey administration

- [Admin workspace](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/admin/page.tsx): `src/app/admin/page.tsx`
- [Survey builder](https://github.com/tanishktewetia/pollpoint/blob/main/src/components/admin/survey-builder.tsx): `src/components/admin/survey-builder.tsx`
- [Admin actions](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/actions/admin.ts): `src/app/actions/admin.ts`
- [Admin queries](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/data/admin.ts): `src/lib/data/admin.ts`
- [Audience push](https://github.com/tanishktewetia/pollpoint/blob/main/src/components/admin/push-form.tsx): `src/components/admin/push-form.tsx`
- [Response review](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/admin/surveys/%5BsurveyId%5D/responses/page.tsx): `src/app/admin/surveys/[surveyId]/responses/page.tsx`

### Document drafting

- [Import endpoint](https://github.com/tanishktewetia/pollpoint/blob/main/src/app/api/admin/survey-imports/route.ts): `src/app/api/admin/survey-imports/route.ts`
- [Brief upload](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/server/imports/upload.ts): `src/lib/server/imports/upload.ts`
- [Text extraction](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/server/imports/extract.ts): `src/lib/server/imports/extract.ts`
- [Gemini drafting](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/server/imports/gemini.ts): `src/lib/server/imports/gemini.ts`

### Data and validation

- [Authoring validation](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/survey/authoring.ts): `src/lib/survey/authoring.ts`
- [Survey and answer schemas](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/survey/schema.ts): `src/lib/survey/schema.ts`
- [Server Supabase client](https://github.com/tanishktewetia/pollpoint/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`
- [Database contracts](https://github.com/tanishktewetia/pollpoint/blob/main/src/types/database.ts): `src/types/database.ts`

### Other components

- **Admin**
- **Participant**
- **Supabase Auth and PostgreSQL**
- **Gemini API**

## Connections

- Participant → Login and signup: opens account pages
- Login and signup → Auth form: renders (evidence: `src/app/(auth)/login/page.tsx`)
- Auth form → Auth actions: submits credentials (evidence: `src/components/auth/auth-form.tsx`)
- Auth actions → Server Supabase client: creates session (evidence: `src/app/actions/auth.ts`)
- Email confirmation → Server Supabase client: verifies email (evidence: `src/app/auth/confirm/route.ts`)
- Access guards → Server Supabase client: checks identity (evidence: `src/lib/auth/guards.ts`)
- Server Supabase client → Supabase Auth and PostgreSQL: uses Auth and database (evidence: `README.md`)
- Participant → Participant dashboard: opens dashboard (evidence: `README.md`)
- Participant dashboard → Access guards: requires participant (evidence: `src/app/(user)/dashboard/page.tsx`)
- Participant dashboard → Supabase Auth and PostgreSQL: loads assignments and balance
- Participant → Survey runner: answers assignment (evidence: `README.md`)
- Survey runner → Question field: renders questions (evidence: `src/components/survey/survey-runner.tsx`)
- Survey runner → Survey submission: submits answers (evidence: `src/components/survey/survey-runner.tsx`)
- Survey submission → Supabase Auth and PostgreSQL: calls submit RPC (evidence: `README.md`)
- Survey runner → Survey and answer schemas: validates answers (evidence: `src/components/survey/survey-runner.tsx`)
- Participant → History and points: views points history (evidence: `README.md`)
- History and points → History queries: loads history (evidence: `src/app/(user)/history/page.tsx`)
- History queries → Supabase Auth and PostgreSQL: reads ledger history (evidence: `README.md`)
- Admin → Admin workspace: opens workspace (evidence: `README.md`)
- Admin workspace → Access guards: requires admin (evidence: `src/app/admin/page.tsx`)
- Admin workspace → Supabase Auth and PostgreSQL: lists surveys (evidence: `src/app/admin/page.tsx`)
- Admin → Survey builder: authors and reviews (evidence: `README.md`)
- Survey builder → Authoring validation: uses definition contract (evidence: `src/components/admin/survey-builder.tsx`)
- Survey builder → Admin actions: saves edits (evidence: `src/components/admin/survey-builder.tsx`)
- Admin actions → Admin queries: delegates queries (evidence: `src/app/actions/admin.ts`)
- Admin actions → Supabase Auth and PostgreSQL: approves survey (evidence: `README.md`)
- Admin → Audience push: selects audience (evidence: `README.md`)
- Audience push → Supabase Auth and PostgreSQL: pushes assignments (evidence: `README.md`)
- Admin → Response review: reviews responses (evidence: `README.md`)
- Response review → Supabase Auth and PostgreSQL: loads response review (evidence: `README.md`)
- Admin → Import endpoint: uploads brief (evidence: `README.md`)
- Import endpoint → Brief upload: reads file (evidence: `src/app/api/admin/survey-imports/route.ts`)
- Import endpoint → Text extraction: extracts text (evidence: `src/app/api/admin/survey-imports/route.ts`)
- Import endpoint → Gemini drafting: generates draft (evidence: `src/app/api/admin/survey-imports/route.ts`)
- Gemini drafting → Gemini API: requests generation (evidence: `README.md`)
- Import endpoint → Authoring validation: validates generated draft (evidence: `src/app/api/admin/survey-imports/route.ts`)
- Import endpoint → Supabase Auth and PostgreSQL: records import draft (evidence: `src/app/api/admin/survey-imports/route.ts`)
- Authoring validation → Survey and answer schemas: derives question rules (evidence: `src/lib/survey/authoring.ts`)
- Server Supabase client → Database contracts: types client (evidence: `src/lib/supabase/server.ts`)
