# sapirshenkor/freedi-app architecture

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

- Interactive diagram: https://gitdiagram.com/sapirshenkor/freedi-app
- Repository: https://github.com/sapirshenkor/freedi-app

## Overview

Freedi is a deliberative-democracy platform for organizing questions, proposals, discussion, evaluation, and group decisions. Participants enter through the web app, authenticate, and use statement and mass-consensus flows; Firebase-backed state supports real-time collaboration, while serverless functions process voting, evaluations, results, and related events. The graph also preserves documented capabilities such as chat, consensus visualization, notifications, and AI assistance. Several connections are documented only at product level because their implementation files were not sampled.

Main entry points: [`src/routes/massConsensusRoutes.tsx`](https://github.com/sapirshenkor/freedi-app/blob/main/src/routes/massConsensusRoutes.tsx) (Consensus routes), [`functions/src/index.ts`](https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/index.ts) (Event functions), [`src/controllers/hooks/useAuthentication.ts`](https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/hooks/useAuthentication.ts) (Authentication), [`src/view/pages/statement/StatementMain.tsx`](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/statement/StatementMain.tsx) (Statement workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["App entry<br/>[main.tsx]"]
  node_routes["Public routes<br/>[publicRoutes.ts]"]
  node_consensus_routes["Consensus routes"]
end

subgraph group_deliberation["Deliberation workflows"]
  node_statement_work["Statement workspace<br/>[StatementMain.tsx]"]
  node_consensus_intro["Consensus introduction<br/>[Introduction.tsx]"]
  node_consensus_question["Question framing"]
  node_suggestions["Proposal evaluation"]
  node_my_suggestions["My proposals"]
  node_results["Results summary<br/>[ResultsSummary.tsx]"]
  node_chat["Integrated chat<br/>[Chat.tsx]"]
  node_visualization["Consensus visualization"]
  node_notifications["Notifications"]
end

subgraph group_platform["Data and identity"]
  node_auth["Authentication"]
  node_public_auth["Public sign-in"]
  node_firebase[("Firebase services<br/>[config.ts]")]
  node_redux["Client state<br/>[store.ts]"]
  node_statement_state["Statement state<br/>[statementsSlice.ts]"]
  node_live_statements["Live statements"]
end

subgraph group_backend["Serverless processing"]
  node_ai["AI assistance<br/>[ai-service.ts]"]
  node_functions["Event functions<br/>[index.ts]"]
  node_evaluation_fn["Evaluation processing<br/>[fn_evaluation.ts]"]
  node_vote_fn["Vote processing<br/>[fn_vote.ts]"]
  node_results_fn["Result processing<br/>[fn_results.ts]"]
  node_statement_fn["Statement processing<br/>[fn_statements.ts]"]
end

node_participant(("Participant"))
node_firestore[("Firestore")]

node_participant -->|"opens"| node_app
node_app -->|"renders routes"| node_routes
node_routes -.->|"routes consensus"| node_consensus_routes
node_participant -.->|"may sign in"| node_public_auth
node_app -->|"checks session"| node_auth
node_auth -->|"observes auth"| node_firebase
node_auth -->|"sets creator"| node_redux
node_auth -->|"writes user"| node_firestore
node_public_auth -->|"saves user"| node_firestore
node_consensus_routes -->|"routes to"| node_consensus_intro
node_consensus_routes -->|"routes to"| node_consensus_question
node_consensus_routes -->|"routes to"| node_suggestions
node_consensus_routes -->|"routes to"| node_my_suggestions
node_consensus_routes -->|"routes to"| node_results
node_statement_work -.->|"includes discussion"| node_chat
node_statement_work -.->|"shows agreement"| node_visualization
node_statement_work -.->|"notifies participants"| node_notifications
node_live_statements -->|"listens to"| node_firestore
node_live_statements -->|"dispatches updates"| node_statement_state
node_statement_state -.->|"updates state"| node_redux
node_participant -.->|"collaborates"| node_statement_work
node_participant -->|"starts deliberation"| node_consensus_intro
node_suggestions -.->|"uses assistance"| node_ai
node_firestore -->|"triggers events"| node_functions
node_functions -->|"dispatches evaluations"| node_evaluation_fn
node_functions -->|"dispatches votes"| node_vote_fn
node_functions -.->|"dispatches results"| node_results_fn
node_functions -.->|"dispatches statements"| node_statement_fn

click node_app "https://github.com/sapirshenkor/freedi-app/blob/main/src/main.tsx"
click node_routes "https://github.com/sapirshenkor/freedi-app/blob/main/src/routes/publicRoutes.ts"
click node_consensus_routes "https://github.com/sapirshenkor/freedi-app/blob/main/src/routes/massConsensusRoutes.tsx"
click node_auth "https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/hooks/useAuthentication.ts"
click node_public_auth "https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/auth/publicAuthHandler.ts"
click node_firebase "https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/db/config.ts"
click node_redux "https://github.com/sapirshenkor/freedi-app/blob/main/src/redux/store.ts"
click node_statement_state "https://github.com/sapirshenkor/freedi-app/blob/main/src/redux/statements/statementsSlice.ts"
click node_live_statements "https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/db/statements/listenToStatements.ts"
click node_statement_work "https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/statement/StatementMain.tsx"
click node_consensus_intro "https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/introduction/Introduction.tsx"
click node_consensus_question "https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/massConsesusQuestion/MassConsesusQuestion.tsx"
click node_suggestions "https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/randomSuggestions/RandomSuggestions.tsx"
click node_my_suggestions "https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/mySuggestions/MassConsensusMySuggestions.tsx"
click node_results "https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/resultsSummary/ResultsSummary.tsx"
click node_chat "https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/statement/components/chat/Chat.tsx"
click node_visualization "https://github.com/sapirshenkor/freedi-app/blob/main/src/view/components/maps/polarizationIndex/PolarizationIndex.tsx"
click node_notifications "https://github.com/sapirshenkor/freedi-app/blob/main/src/services/notificationService.ts"
click node_ai "https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/services/ai-service.ts"
click node_functions "https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/index.ts"
click node_evaluation_fn "https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/fn_evaluation.ts"
click node_vote_fn "https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/fn_vote.ts"
click node_results_fn "https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/fn_results.ts"
click node_statement_fn "https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/fn_statements.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_app,node_routes,node_consensus_routes toneBlue
class node_statement_work,node_consensus_intro,node_consensus_question,node_suggestions,node_my_suggestions,node_results,node_chat,node_visualization,node_notifications,node_firestore toneAmber
class node_auth,node_public_auth,node_firebase,node_redux,node_statement_state,node_live_statements toneMint
class node_ai,node_functions,node_evaluation_fn,node_vote_fn,node_results_fn,node_statement_fn toneRose
class node_participant toneIndigo
```

## Components

### Web application

- [App entry](https://github.com/sapirshenkor/freedi-app/blob/main/src/main.tsx): `src/main.tsx`
- [Public routes](https://github.com/sapirshenkor/freedi-app/blob/main/src/routes/publicRoutes.ts): `src/routes/publicRoutes.ts`
- [Consensus routes](https://github.com/sapirshenkor/freedi-app/blob/main/src/routes/massConsensusRoutes.tsx): `src/routes/massConsensusRoutes.tsx`

### Deliberation workflows

- [Statement workspace](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/statement/StatementMain.tsx): `src/view/pages/statement/StatementMain.tsx`
- [Consensus introduction](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/introduction/Introduction.tsx): `src/view/pages/massConsensus/introduction/Introduction.tsx`
- [Question framing](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/massConsesusQuestion/MassConsesusQuestion.tsx): `src/view/pages/massConsensus/massConsesusQuestion/MassConsesusQuestion.tsx`
- [Proposal evaluation](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/randomSuggestions/RandomSuggestions.tsx): `src/view/pages/massConsensus/randomSuggestions/RandomSuggestions.tsx`
- [My proposals](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/mySuggestions/MassConsensusMySuggestions.tsx): `src/view/pages/massConsensus/mySuggestions/MassConsensusMySuggestions.tsx`
- [Results summary](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/massConsensus/resultsSummary/ResultsSummary.tsx): `src/view/pages/massConsensus/resultsSummary/ResultsSummary.tsx`
- [Integrated chat](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/pages/statement/components/chat/Chat.tsx): `src/view/pages/statement/components/chat/Chat.tsx`
- [Consensus visualization](https://github.com/sapirshenkor/freedi-app/blob/main/src/view/components/maps/polarizationIndex/PolarizationIndex.tsx): `src/view/components/maps/polarizationIndex/PolarizationIndex.tsx`
- [Notifications](https://github.com/sapirshenkor/freedi-app/blob/main/src/services/notificationService.ts): `src/services/notificationService.ts`

### Data and identity

- [Authentication](https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/hooks/useAuthentication.ts): `src/controllers/hooks/useAuthentication.ts`
- [Public sign-in](https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/auth/publicAuthHandler.ts): `src/controllers/auth/publicAuthHandler.ts`
- [Firebase services](https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/db/config.ts): `src/controllers/db/config.ts`
- [Client state](https://github.com/sapirshenkor/freedi-app/blob/main/src/redux/store.ts): `src/redux/store.ts`
- [Statement state](https://github.com/sapirshenkor/freedi-app/blob/main/src/redux/statements/statementsSlice.ts): `src/redux/statements/statementsSlice.ts`
- [Live statements](https://github.com/sapirshenkor/freedi-app/blob/main/src/controllers/db/statements/listenToStatements.ts): `src/controllers/db/statements/listenToStatements.ts`

### Serverless processing

- [AI assistance](https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/services/ai-service.ts): `functions/src/services/ai-service.ts`
- [Event functions](https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/index.ts): `functions/src/index.ts`
- [Evaluation processing](https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/fn_evaluation.ts): `functions/src/fn_evaluation.ts`
- [Vote processing](https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/fn_vote.ts): `functions/src/fn_vote.ts`
- [Result processing](https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/fn_results.ts): `functions/src/fn_results.ts`
- [Statement processing](https://github.com/sapirshenkor/freedi-app/blob/main/functions/src/fn_statements.ts): `functions/src/fn_statements.ts`

### Other components

- **Participant**
- **Firestore**

## Connections

- Participant → App entry: opens (evidence: `src/main.tsx`)
- App entry → Public routes: renders routes (evidence: `src/main.tsx`)
- Public routes → Consensus routes: routes consensus
- Participant → Public sign-in: may sign in
- App entry → Authentication: checks session
- Authentication → Firebase services: observes auth (evidence: `src/controllers/hooks/useAuthentication.ts`)
- Authentication → Client state: sets creator (evidence: `src/controllers/hooks/useAuthentication.ts`)
- Authentication → Firestore: writes user (evidence: `src/controllers/hooks/useAuthentication.ts`)
- Public sign-in → Firestore: saves user (evidence: `src/controllers/auth/publicAuthHandler.ts`)
- Consensus routes → Consensus introduction: routes to (evidence: `src/routes/massConsensusRoutes.tsx`)
- Consensus routes → Question framing: routes to (evidence: `src/routes/massConsensusRoutes.tsx`)
- Consensus routes → Proposal evaluation: routes to (evidence: `src/routes/massConsensusRoutes.tsx`)
- Consensus routes → My proposals: routes to (evidence: `src/routes/massConsensusRoutes.tsx`)
- Consensus routes → Results summary: routes to (evidence: `src/routes/massConsensusRoutes.tsx`)
- Statement workspace → Integrated chat: includes discussion
- Statement workspace → Consensus visualization: shows agreement
- Statement workspace → Notifications: notifies participants
- Live statements → Firestore: listens to (evidence: `src/controllers/db/statements/listenToStatements.ts`)
- Live statements → Statement state: dispatches updates (evidence: `src/controllers/db/statements/listenToStatements.ts`)
- Statement state → Client state: updates state (evidence: `src/redux/store.ts`)
- Participant → Statement workspace: collaborates
- Participant → Consensus introduction: starts deliberation
- Proposal evaluation → AI assistance: uses assistance
- Firestore → Event functions: triggers events (evidence: `functions/src/index.ts`)
- Event functions → Evaluation processing: dispatches evaluations (evidence: `functions/src/index.ts`)
- Event functions → Vote processing: dispatches votes (evidence: `functions/src/index.ts`)
- Event functions → Result processing: dispatches results (evidence: `functions/src/index.ts`)
- Event functions → Statement processing: dispatches statements (evidence: `functions/src/index.ts`)
