# knowmefaiz/riverthink architecture

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

- Interactive diagram: https://gitdiagram.com/knowmefaiz/riverthink
- Repository: https://github.com/knowmefaiz/riverthink

## Overview

RiverThink is a local-first, server-rendered community platform where people register, publish Ambinote posts, create ideologies, and support them by voting. Those activities feed a four-stage weekly election that produces three Final Nine seats in each of three equal channels, with generation history available to users. The graph separates web entry points, community features, election rules, and shared infrastructure. Relationships are grounded in the README and source-index references; unsampled implementation details are represented only at their supported subsystem paths.

Main entry points: [`src/web/pages.rs`](https://github.com/knowmefaiz/riverthink/blob/main/src/web/pages.rs) (Page handlers), [`src/db.rs`](https://github.com/knowmefaiz/riverthink/blob/main/src/db.rs) (SQLite database), [`src/service/election.rs`](https://github.com/knowmefaiz/riverthink/blob/main/src/service/election.rs) (Election scheduler), [`src/service/auth.rs`](https://github.com/knowmefaiz/riverthink/blob/main/src/service/auth.rs) (Accounts and sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_http["HTTP router<br/>[mod.rs]"]
  node_pages["Page handlers<br/>[pages.rs]"]
  node_html["HTML rendering<br/>[html.rs]"]
  node_admin["Admin pages<br/>[admin.rs]"]
end

subgraph group_community["Community features"]
  node_identity["Accounts and sessions<br/>[auth.rs]"]
  node_ambinote["Ambinote posts<br/>[notes.rs]"]
  node_ideologies["Ideology creation and listings<br/>[ideology.rs]"]
  node_voting["Support voting<br/>[vote.rs]"]
  node_moderation["Reports and appeals<br/>[moderation.rs]"]
end

subgraph group_election["Election lifecycle"]
  node_scheduler["Election scheduler<br/>[election.rs]"]
  node_calendar["Election calendar<br/>[calendar.rs]"]
  node_capacity["Founding capacity<br/>[capacity.rs]"]
  node_channels["Equal channels<br/>[channel.rs]"]
  node_vote_rules["Vote rules<br/>[vote.rs]"]
  node_election_rules["Selection rules<br/>[election.rs]"]
end

subgraph group_platform["Shared platform"]
  node_database[("SQLite database<br/>[db.rs]")]
  node_config["Runtime configuration<br/>[config.rs]"]
  node_models["Shared user models<br/>[model.rs]"]
end

node_people(("Community members"))

node_people -->|"uses routes"| node_http
node_http -->|"routes requests"| node_pages
node_http -->|"routes admin"| node_admin
node_pages -->|"renders pages"| node_html
node_pages -->|"uses accounts"| node_identity
node_pages -->|"uses posts"| node_ambinote
node_pages -->|"uses ideologies"| node_ideologies
node_pages -->|"casts votes"| node_voting
node_pages -->|"shows elections"| node_scheduler
node_pages -->|"submits reports"| node_moderation
node_admin -->|"advances cycle"| node_scheduler
node_admin -->|"handles appeals"| node_moderation
node_pages -->|"uses user data"| node_models
node_identity -->|"reads and writes"| node_database
node_identity -->|"checks settings"| node_config
node_identity -->|"validates channel"| node_channels
node_identity -->|"returns users"| node_models
node_ambinote -->|"reads and writes"| node_database
node_ideologies -->|"reads and writes"| node_database
node_ideologies -->|"checks quota"| node_capacity
node_ideologies -->|"uses channel"| node_channels
node_ideologies -->|"reads settings"| node_config
node_voting -->|"reads and writes"| node_database
node_voting -->|"checks timing"| node_calendar
node_voting -->|"checks validity"| node_vote_rules
node_voting -->|"reads settings"| node_config
node_moderation -->|"reads and writes"| node_database
node_scheduler -->|"reads and writes"| node_database
node_scheduler -->|"computes stages"| node_calendar
node_scheduler -->|"selects candidates"| node_election_rules
node_scheduler -->|"processes channels"| node_channels
node_database -.->|"uses DB path"| node_config

click node_http "https://github.com/knowmefaiz/riverthink/blob/main/src/web/mod.rs"
click node_pages "https://github.com/knowmefaiz/riverthink/blob/main/src/web/pages.rs"
click node_html "https://github.com/knowmefaiz/riverthink/blob/main/src/web/html.rs"
click node_admin "https://github.com/knowmefaiz/riverthink/blob/main/src/web/admin.rs"
click node_identity "https://github.com/knowmefaiz/riverthink/blob/main/src/service/auth.rs"
click node_ambinote "https://github.com/knowmefaiz/riverthink/blob/main/src/service/notes.rs"
click node_ideologies "https://github.com/knowmefaiz/riverthink/blob/main/src/service/ideology.rs"
click node_voting "https://github.com/knowmefaiz/riverthink/blob/main/src/service/vote.rs"
click node_moderation "https://github.com/knowmefaiz/riverthink/blob/main/src/service/moderation.rs"
click node_scheduler "https://github.com/knowmefaiz/riverthink/blob/main/src/service/election.rs"
click node_calendar "https://github.com/knowmefaiz/riverthink/blob/main/src/domain/calendar.rs"
click node_capacity "https://github.com/knowmefaiz/riverthink/blob/main/src/domain/capacity.rs"
click node_channels "https://github.com/knowmefaiz/riverthink/blob/main/src/domain/channel.rs"
click node_vote_rules "https://github.com/knowmefaiz/riverthink/blob/main/src/domain/vote.rs"
click node_election_rules "https://github.com/knowmefaiz/riverthink/blob/main/src/domain/election.rs"
click node_database "https://github.com/knowmefaiz/riverthink/blob/main/src/db.rs"
click node_config "https://github.com/knowmefaiz/riverthink/blob/main/src/config.rs"
click node_models "https://github.com/knowmefaiz/riverthink/blob/main/src/model.rs"

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_http,node_pages,node_html,node_admin toneBlue
class node_identity,node_ambinote,node_ideologies,node_voting,node_moderation toneAmber
class node_scheduler,node_calendar,node_capacity,node_channels,node_vote_rules,node_election_rules toneMint
class node_database,node_config,node_models toneRose
class node_people toneIndigo
```

## Components

### Web experience

- [HTTP router](https://github.com/knowmefaiz/riverthink/blob/main/src/web/mod.rs): `src/web/mod.rs`
- [Page handlers](https://github.com/knowmefaiz/riverthink/blob/main/src/web/pages.rs): `src/web/pages.rs`
- [HTML rendering](https://github.com/knowmefaiz/riverthink/blob/main/src/web/html.rs): `src/web/html.rs`
- [Admin pages](https://github.com/knowmefaiz/riverthink/blob/main/src/web/admin.rs): `src/web/admin.rs`

### Community features

- [Accounts and sessions](https://github.com/knowmefaiz/riverthink/blob/main/src/service/auth.rs): `src/service/auth.rs`
- [Ambinote posts](https://github.com/knowmefaiz/riverthink/blob/main/src/service/notes.rs): `src/service/notes.rs`
- [Ideology creation and listings](https://github.com/knowmefaiz/riverthink/blob/main/src/service/ideology.rs): `src/service/ideology.rs`
- [Support voting](https://github.com/knowmefaiz/riverthink/blob/main/src/service/vote.rs): `src/service/vote.rs`
- [Reports and appeals](https://github.com/knowmefaiz/riverthink/blob/main/src/service/moderation.rs): `src/service/moderation.rs`

### Election lifecycle

- [Election scheduler](https://github.com/knowmefaiz/riverthink/blob/main/src/service/election.rs): `src/service/election.rs`
- [Election calendar](https://github.com/knowmefaiz/riverthink/blob/main/src/domain/calendar.rs): `src/domain/calendar.rs`
- [Founding capacity](https://github.com/knowmefaiz/riverthink/blob/main/src/domain/capacity.rs): `src/domain/capacity.rs`
- [Equal channels](https://github.com/knowmefaiz/riverthink/blob/main/src/domain/channel.rs): `src/domain/channel.rs`
- [Vote rules](https://github.com/knowmefaiz/riverthink/blob/main/src/domain/vote.rs): `src/domain/vote.rs`
- [Selection rules](https://github.com/knowmefaiz/riverthink/blob/main/src/domain/election.rs): `src/domain/election.rs`

### Shared platform

- [SQLite database](https://github.com/knowmefaiz/riverthink/blob/main/src/db.rs): `src/db.rs`
- [Runtime configuration](https://github.com/knowmefaiz/riverthink/blob/main/src/config.rs): `src/config.rs`
- [Shared user models](https://github.com/knowmefaiz/riverthink/blob/main/src/model.rs): `src/model.rs`

### Other components

- **Community members**

## Connections

- Community members → HTTP router: uses routes (evidence: `README.md`)
- HTTP router → Page handlers: routes requests (evidence: `src/web/mod.rs`)
- HTTP router → Admin pages: routes admin (evidence: `src/web/mod.rs`)
- Page handlers → HTML rendering: renders pages (evidence: `src/web/pages.rs`)
- Page handlers → Accounts and sessions: uses accounts (evidence: `src/web/pages.rs`)
- Page handlers → Ambinote posts: uses posts (evidence: `src/web/pages.rs`)
- Page handlers → Ideology creation and listings: uses ideologies (evidence: `src/web/pages.rs`)
- Page handlers → Support voting: casts votes (evidence: `src/web/pages.rs`)
- Page handlers → Election scheduler: shows elections (evidence: `src/web/pages.rs`)
- Page handlers → Reports and appeals: submits reports (evidence: `src/web/pages.rs`)
- Admin pages → Election scheduler: advances cycle (evidence: `src/web/admin.rs`)
- Admin pages → Reports and appeals: handles appeals (evidence: `src/web/admin.rs`)
- Page handlers → Shared user models: uses user data (evidence: `src/web/pages.rs`)
- Accounts and sessions → SQLite database: reads and writes (evidence: `src/service/auth.rs`)
- Accounts and sessions → Runtime configuration: checks settings (evidence: `src/service/auth.rs`)
- Accounts and sessions → Equal channels: validates channel (evidence: `src/service/auth.rs`)
- Accounts and sessions → Shared user models: returns users (evidence: `src/service/auth.rs`)
- Ambinote posts → SQLite database: reads and writes (evidence: `src/service/notes.rs`)
- Ideology creation and listings → SQLite database: reads and writes (evidence: `src/service/ideology.rs`)
- Ideology creation and listings → Founding capacity: checks quota (evidence: `src/service/ideology.rs`)
- Ideology creation and listings → Equal channels: uses channel (evidence: `src/service/ideology.rs`)
- Ideology creation and listings → Runtime configuration: reads settings (evidence: `src/service/ideology.rs`)
- Support voting → SQLite database: reads and writes (evidence: `src/service/vote.rs`)
- Support voting → Election calendar: checks timing (evidence: `src/service/vote.rs`)
- Support voting → Vote rules: checks validity (evidence: `src/service/vote.rs`)
- Support voting → Runtime configuration: reads settings (evidence: `src/service/vote.rs`)
- Reports and appeals → SQLite database: reads and writes (evidence: `src/service/moderation.rs`)
- Election scheduler → SQLite database: reads and writes (evidence: `src/service/election.rs`)
- Election scheduler → Election calendar: computes stages (evidence: `src/service/election.rs`)
- Election scheduler → Selection rules: selects candidates (evidence: `src/service/election.rs`)
- Election scheduler → Equal channels: processes channels (evidence: `src/service/election.rs`)
- SQLite database → Runtime configuration: uses DB path
