Contributing
Thank you for your interest in contributing to PolitikTok. This guide covers the development workflow from fork to merged pull request.
Getting Started
Fork the repository on GitHub.
Clone your fork locally:
bashgit clone https://github.com/YOUR_USERNAME/politiktok.git cd politiktokSet up the development environment following the Installation guide.
Create a branch for your work:
bashgit checkout -b feat/your-feature-name
Branch Naming
Use prefixed branch names that describe the type of change:
| Prefix | Use Case | Example |
|---|---|---|
feat/ | New features | feat/f03-spike-notifications |
fix/ | Bug fixes | fix/volunteer-churn-score |
refactor/ | Code refactoring | refactor/llm-client-retry |
docs/ | Documentation | docs/add-f07-fundraising |
test/ | Test additions | test/embedding-chunking |
chore/ | Tooling, CI, dependencies | chore/update-dioxus-073 |
Commit Messages
Follow the Conventional Commits specification:
<type>(<scope>): <description>
[optional body]
[optional footer(s)]Types
| Type | Description |
|---|---|
feat | A new feature |
fix | A bug fix |
docs | Documentation changes |
refactor | Code refactoring (no behavior change) |
test | Adding or updating tests |
chore | Tooling, CI, build system changes |
perf | Performance improvements |
Scope
Use the module name or infrastructure area:
feat(volunteer-matching): add skill-weighted scoring
fix(policy-chatbot): handle empty document content
refactor(llm): extract retry logic into helper
docs(architecture): add RAG pipeline diagramExamples
feat(sentiment-monitor): add spike detection with configurable threshold
Implements statistical anomaly detection for sentiment volume spikes.
A spike is flagged when the current window count exceeds the 7-day
historical average by a configurable number of standard deviations.
Closes #42Code Style
Rust Formatting
All code must pass cargo fmt --check. The project uses default rustfmt settings. Format your code before committing:
cargo fmtClippy Lints
The project enforces strict Clippy lints:
cargo clippy --features server --no-default-features -- -D warnings
cargo clippy --features web --no-default-features -- -D warningsThe workspace-level Clippy configuration denies unwrap_used and expect_used:
[workspace.lints.clippy]
unwrap_used = "deny"
expect_used = "deny"Use proper error handling (?, map_err, ok_or_else) instead of .unwrap() or .expect().
Pull Request Process
- Push your branch to your fork.
- Open a pull request against the
mainbranch. - Fill in the PR template with:
- A description of the changes
- Which module(s) are affected
- Testing steps
- Screenshots (for UI changes)
- CI must pass: format check, Clippy (server + web), and tests.
- Code review: At least one maintainer must approve.
- Squash and merge: PRs are squash-merged to keep the main branch history clean.
Adding a New Module
If you are adding a new feature module:
- Create a new directory under
src/modules/your_module/mod.rs. - Register the module in
src/modules/mod.rs. - Add models in
src/models/if needed. - Create page components in
src/pages/your_module/mod.rs. - Add routes to the
Routeenum insrc/app.rs. - Add the sidebar link in
src/components/sidebar.rs. - Write documentation in
docs/src/modules/your-module.md. - Add the entry to
docs/src/SUMMARY.md.
Development Tips
- Run
dx servefor hot-reloading during development. - Use
tracing::info!,tracing::warn!, etc. for logging (notprintln!). - Server functions should always authenticate the user via
require_user()orrequire_role(). - Database queries use raw SQL via
sqlx::query-- avoid building SQL strings dynamically. - LLM prompts should be defined as
const &strfor readability and reuse. - Keep server functions focused -- one operation per function, delegate complex logic to helper functions.