3.0 KiB
3.0 KiB
Copilot/AI Agent Instructions for Letterbox
Project Overview
- Letterbox is a Rust monorepo for a mail/newsreader system with a web frontend and a Rocket/GraphQL backend.
- Major crates:
server(backend, Rocket+async-graphql),web(Seed-based WASM frontend),notmuch(mail integration),shared(common types),procmail2notmuch(migration/utility). - Data flows: Email/news data is indexed and queried via the backend, exposed to the frontend via GraphQL. SQLx/Postgres is used for persistence. Notmuch and custom SQL are both used for mail storage/search.
Key Workflows
- Development: Use
dev.shto launch a tmux session with live-reloading for both frontend (trunk serve) and backend (cargo watch ... run). - Build/Release: Use
just patch|minor|majorfor versioned releases (runs SQLx prepare, bumps versions, pushes).Makefile'sreleasetarget does similar steps. - Frontend: In
web/, usecargo make serveandcargo make watchfor local dev. Seeweb/README.mdfor Seed-specific details. - Backend: In
server/, run withcargo runor via the tmux/dev.sh workflow. SQL migrations are inserver/migrations/.
Project Conventions & Patterns
- GraphQL: All API boundaries are defined in
server/src/graphql.rs. Use theQuery,Mutation, andSubscriptionroots. Types are defined withasync-graphqlderive macros. - HTML Sanitization: See
server/src/lib.rsfor custom HTML/CSS sanitization and transformation logic (e.g.,Transformertrait,sanitize_html). - Tag/Query Parsing: The
Querystruct inserver/src/lib.rsparses user queries into filters for notmuch/newsreader/tantivy. - Shared Types: Use the
sharedcrate for types and helpers shared between frontend and backend. - Custom SQL: Raw SQL queries are in
server/sql/. Use these for complex queries not handled by SQLx macros. - Feature Flags: The
tantivyfeature enables full-text search via Tantivy. Check for#[cfg(feature = "tantivy")]in backend code.
Integration Points
- Notmuch: Integrated via the
notmuchcrate for mail indexing/search. - Postgres: Used for newsreader and other persistent data (see
server/migrations/). - GraphQL: All client-server communication is via GraphQL endpoints defined in the backend.
- Seed/Trunk: Frontend is built with Seed (Rust/WASM) and served via Trunk.
Examples
- To add a new GraphQL query, update
server/src/graphql.rsand expose it in theQueryRoot. - To add a new frontend page, add a module in
web/src/and register it in the Seed app's router. - To run the full dev environment:
./dev.sh(requires tmux, trunk, cargo-watch, etc.).
References
- See
web/README.mdfor frontend/Seed workflow details. - See
JustfileandMakefilefor release/versioning automation. - See
server/src/lib.rsandserver/src/graphql.rsfor backend architecture and conventions. - See
server/sql/for custom SQL queries.
If any conventions or workflows are unclear, please ask for clarification or check the referenced files for examples.