Skip to content

Project Structure

This page describes the directory layout of the PolitikTok repository and explains the purpose of each major directory and file.

Top-Level Layout

politiktok/
├── assets/                   # Static assets (CSS, images)
│   └── main.css              # Custom CSS beyond Tailwind/DaisyUI
├── bin/
│   └── main.rs               # Application entry point
├── docs/                     # mdBook documentation (this site)
│   ├── book.toml
│   └── src/
├── migrations/               # SQLx database migrations
│   └── *.sql
├── src/
│   ├── app.rs                # Root component, Route enum, layouts
│   ├── lib.rs                # Crate root, module declarations
│   ├── components/           # Reusable UI components
│   ├── infrastructure/       # Server-side infrastructure
│   ├── models/               # Shared data structures
│   ├── modules/              # 26 feature modules (server functions)
│   └── pages/                # Route-mapped page components
├── .env.example              # Example environment variables
├── .github/workflows/        # CI/CD pipelines
├── Cargo.toml                # Rust dependencies and features
├── Dioxus.toml               # Dioxus CLI configuration
└── docker-compose.yml        # Infrastructure services

bin/main.rs

The entry point that dispatches to either the web (WASM) or server runtime based on the active feature flag:

  • #[cfg(feature = "web")] -- launches Dioxus web with hydration enabled
  • #[cfg(feature = "server")] -- calls server_start() to boot the Axum server

src/lib.rs

Declares the five top-level modules and re-exports public items:

rust
mod app;
mod components;
pub mod infrastructure;
mod models;
mod modules;
mod pages;

src/app.rs

Contains three critical pieces:

  1. App component -- root element that loads Tailwind CSS, DaisyUI, and the custom stylesheet, then renders the Router.
  2. Route enum -- the full routing table with 40+ routes mapped to page components. Uses Dioxus #[derive(Routable)].
  3. Layout components -- AppShell (authenticated sidebar layout) and AdminShell (admin sub-navigation).

src/components/

Reusable UI building blocks shared across pages:

ComponentFilePurpose
Sidebarsidebar.rsNavigation sidebar with module links
Headerheader.rsPage header with breadcrumbs
Cardcard.rsContent card container
Modalmodal.rsDialog overlay
DataTabledata_table.rsSortable, filterable data table
LoadingSpinnerloading.rsLoading state indicator
StreamingTextstreaming_text.rsProgressive text display for LLM output
Chartchart.rsData visualization
Paginationpagination.rsPage navigation for lists
Badgebadge.rsStatus and tag badges
Toasttoast.rsNotification toasts
AlertBanneralert_banner.rsPersistent alert messages
FormFieldsform_fields.rsForm input components
Feedbackfeedback.rsUser feedback elements

src/infrastructure/

Server-side foundation code:

FilePurpose
mod.rsModule declarations and re-exports
config.rsEnvironment variable loading (AppConfig, KeycloakConfig, LlmConfig, EmbeddingConfig, VectorStoreConfig)
db.rsPostgreSQL connection pool and migration runner
state.rsServerState (Arc-wrapped) and UserSessionState
auth.rsKeycloak OIDC flow (login, callback, logout), PKCE helpers, session extraction
auth_check.rsAuthentication verification utilities
llm.rsLlmClient with retry, streaming, and usage logging
embedding.rsEmbeddingClient, text chunking, content hashing
vector_store.rsVectorStoreClient for Qdrant operations
error.rsApplication error types
server_start.rsAxum server bootstrap and middleware configuration
middleware/mod.rsMiddleware module
middleware/auth.rsAuth enforcement middleware
middleware/audit_log.rsRequest audit logging middleware

src/models/

Shared data structures serializable with serde:

FileTypes
user.rsUser
roles.rsRole enum (Admin, Staff, Volunteer, ReadOnly)
volunteer.rsVolunteer, VolunteerSummary, VolunteerMatch, Assignment, Task, TaskSummary
task.rsAdditional task-related types
donor.rsDonor and donation records
voter.rsVoter profiles
document.rsDocument, ChatMessage, ChatSession
social_post.rsSocialPost, SentimentSummary, SentimentSpike
candidate.rsCandidate, Opponent, Contradiction

src/modules/

Each of the 26 feature modules lives in its own subdirectory with a mod.rs file containing all server functions for that feature:

modules/
├── volunteer_matching/mod.rs     # F01
├── policy_chatbot/mod.rs         # F02
├── sentiment_monitor/mod.rs      # F03
├── campaign_copy/mod.rs          # F04
├── opposition_research/mod.rs    # F05
├── canvassing/mod.rs             # F06
├── fundraising/mod.rs            # F07
├── accountability/mod.rs         # F08
├── empathy_simulator/mod.rs      # F09
├── narrative_contagion/mod.rs    # F10
├── coalition_detector/mod.rs     # F11
├── candidate_briefing/mod.rs     # F12
├── call_intelligence/mod.rs      # F13
├── coaching/mod.rs               # F14
├── multilingual/mod.rs           # F15
├── question_anticipation/mod.rs  # F16
├── local_issues/mod.rs           # F17
├── policy_diff/mod.rs            # F18
├── faction_mapper/mod.rs         # F19
├── regulatory_monitor/mod.rs     # F20
├── media_monitor/mod.rs          # F21
├── disinfo_warning/mod.rs        # F22
├── compliance_reporting/mod.rs   # F23
├── meeting_summarizer/mod.rs     # F24
├── knowledge_base/mod.rs         # F25
└── admin/mod.rs                  # F26

src/pages/

Page components that correspond to routes in app.rs:

pages/
├── landing.rs            # Public landing page (/)
├── login.rs              # Login page (/login)
├── not_found.rs          # 404 page
├── dashboard/mod.rs      # Main dashboard (/dashboard)
├── admin/mod.rs          # Admin panel pages (/admin/*)
├── volunteers/mod.rs     # F01 pages
├── policy_chatbot/mod.rs # F02 pages
├── sentiment/mod.rs      # F03 pages
├── ...                   # One directory per module
└── knowledge_base/mod.rs # F25 pages

migrations/

SQL migration files run in order by sqlx::migrate!(). Each file creates or alters tables needed by the modules. Tables include: volunteers, tasks, assignments, donors, donations, social_posts, sentiment_spikes, documents, chat_sessions, chat_messages, commitments, evidence, llm_usage_log, and more.

Configuration Files

FilePurpose
Cargo.tomlRust dependencies, feature flags (server, web), workspace lint configuration
Dioxus.tomlDioxus CLI settings: app name, asset directory, watcher paths
docker-compose.ymlInfrastructure service definitions
.env.exampleTemplate for environment variables
.github/workflows/ci.ymlCI pipeline (fmt, clippy, audit, test)
.github/workflows/docs.ymlDocumentation deployment to GitHub Pages