Purpose: Define non-negotiable architectural constraints for the Folio codebase. These guardrails protect the system's integrity as it evolves.
| Layer | Technology | Version |
|---|---|---|
| Desktop Shell | Tauri 2.x | @tauri-apps/cli ^2.10.0 |
| Backend (Rust) | Rust 2021 Edition | Workspace: apps/tauri, apps/server, crates/* |
| Frontend | React + TypeScript | ^5.9.3 |
| Build Tool | Vite | — |
| Styling | Tailwind CSS | — |
| State Management | Zustand | — |
| Charts | Recharts | — |
| Database | SQLite (via Diesel 2.2) | Bundled |
| Package Manager | pnpm (monorepo) | Workspaces |
| Testing | Vitest + Playwright (E2E) | — |
| Linting | ESLint 9 + Prettier | — |
crates/
├── core/ # Domain models, business logic
├── market-data/ # Market data fetching & caching
├── connect/ # Bank connectivity adapters
├── storage-sqlite/ # Diesel-based SQLite storage layer
├── device-sync/ # Cross-device synchronization
└── ai/ # AI-powered features (categorization, insights)
apps/
├── tauri/ # Tauri desktop application (Rust + React)
└── server/ # Standalone server application
- No
unsafecode —unsafe_code = "forbid"in workspace lints. - Clippy warnings are errors —
all = "warn"in workspace lints. - Diesel for ORM — All database access goes through Diesel, never raw SQL except migrations.
- SQLite only — No external database dependencies. Data is local-first.
- Error handling — Use
thiserrorfor library errors,anyhowfor application errors. - Async runtime — Tokio is the only async runtime. No mixing with other runtimes.
- HTTP client —
reqwestwithrustls-tlsonly. No native TLS.
- TypeScript strict mode — No
anytypes. Use proper type definitions. - Component architecture — Feature-based organization under
apps/frontend/src/features/. - State management — Zustand for global state. No Redux, no Context for data state.
- Data fetching — TanStack Query (React Query) for server state. No manual fetch calls.
- Styling — Tailwind CSS utility classes only. No CSS modules, no styled-components.
- No direct DOM manipulation — Use React refs when absolutely necessary.
- IPC boundaries — Frontend communicates with Rust only through Tauri commands (
#[tauri::command]). - Capabilities model — Use Tauri v2 capabilities for permission scoping. No blanket permissions.
- No direct filesystem access from frontend — All file I/O goes through Rust commands.
- Secrets in Rust only — API keys, encryption keys, and credentials never touch the frontend.
- Local-first architecture — All user data stored locally in SQLite. No cloud storage of financial data.
- Encryption at rest — Sensitive data encrypted using
chacha20poly1305+x25519-dalek. - No analytics or tracking — No third-party analytics, crash reporting, or telemetry.
- Secret scanning — Pre-commit hooks scan for API keys, tokens, and credentials.
- Environment variables — All configuration via
.envfiles. Never commit.env.
- pnpm workspaces — All packages managed through
pnpm-workspace.yaml. - Internal crate paths — Rust crates referenced via
path = "crates/*"inCargo.toml. - Shared TypeScript config —
tsconfig.base.jsonextended by all packages. - Linting consistency — ESLint config shared via
eslint.base.config.js.
- Unit tests — Co-located with source files (
*.test.ts,*_test.rs). - E2E tests — Playwright for full application flows in
e2e/. - No test-only dependencies in production — Dev dependencies only in
devDependencies. - Coverage threshold — Maintain minimum 80% coverage on critical paths.
- Bundle size budget — Frontend bundle must not exceed 500KB gzipped.
- Database queries — All queries must use indexes. No N+1 queries.
- Market data caching — Market data cached locally, never fetched synchronously on UI thread.
- Lazy loading — Features loaded on demand. No eager loading of non-critical modules.
All significant architectural decisions must be recorded as ADRs in docs/adr/.
See ADR Template for format.
Architecture diagrams are maintained in docs/architecture/diagrams/ using Mermaid syntax.
See System Context Diagram for the C4 overview.
These guardrails are enforced through:
- CI checks — Linting, type-checking, and tests on every PR.
- Code review — Reviewers verify compliance with these guardrails.
- Pre-commit hooks — Secret scanning and formatting checks.
- ADR process — Any deviation requires an Architecture Decision Record.
Last updated: April 2026 | Version: 3.0.0