8.5 KiB
8.5 KiB
Repository Guidelines
Repository Overview
- Noteflow ships a Python backend (gRPC server + domain services) and a Tauri + React desktop client.
- The gRPC API is the shared contract between backend and client; schema lives in
src/noteflow/grpc/proto/noteflow.proto. - Backend code is layered: domain (pure models + ports), application (use-cases), infrastructure (IO implementations).
- The repo is split into backend package (
src/noteflow/) and frontend app (client/), with tests and docs alongside. - When you touch shared contracts (proto fields/enums, DTOs), update Python, Rust, and TypeScript counterparts together.
Quick Orientation (Start Here)
- Backend entry point:
python -m noteflow.grpc.server(service implementation insrc/noteflow/grpc/service.py). - Tauri/React client:
cd client && npm run dev(web), ornpm run tauri dev(desktop). - Tauri IPC bridge:
client/src/api/tauri-adapter.ts(TS) <->client/src-tauri/src/commands/(Rust). - Protobuf contract and generated stubs live in
src/noteflow/grpc/proto/.
Project Structure & Module Organization
src/noteflow/domain/defines entities, value objects, and port protocols; keep this layer pure and testable.src/noteflow/application/hosts use-case services (Meeting, Recovery, Export, Summarization, Trigger, Webhook, Calendar, Retention, NER).src/noteflow/infrastructure/provides concrete adapters (audio, ASR, persistence, security, summarization, triggers, calendar, ner, observability, webhooks, converters).src/noteflow/grpc/contains the server, client wrapper, modular mixins (streaming/, diarization/ as packages), and proto conversions.src/noteflow/cli/provides CLI tools for retention management and model commands.client/is the Tauri/Vite React client; UI inclient/src/, Rust shell inclient/src-tauri/, e2e tests inclient/e2e/.
Backend Architecture & Data Flow
- gRPC server entry point lives in
src/noteflow/grpc/server.py;NoteFlowServicerinsrc/noteflow/grpc/service.pycomposes feature mixins. - Proto <-> domain conversions and enum mappings are centralized in
src/noteflow/grpc/_mixins/converters.py. - Unit-of-work and repositories live under
src/noteflow/infrastructure/persistence/, with memory fallback when no DB is configured. - Streaming audio ingestion uses
src/noteflow/infrastructure/audio/and ASR/VAD components insrc/noteflow/infrastructure/asr/. - Encryption, key storage, and secure asset handling live in
src/noteflow/infrastructure/security/.
Client Architecture (Tauri + React)
- React components are in
client/src/components/, custom hooks inclient/src/hooks/, and shared types inclient/src/types/. - API layer lives in
client/src/api/with adapters (tauri-adapter.ts,mock-adapter.ts,cached-adapter.ts) and connection management. - React contexts are in
client/src/contexts/(e.g.,connection-context.tsxfor gRPC state). - Tauri command calls are in
client/src/api/tauri-adapter.ts; Rust command handlers live inclient/src-tauri/src/commands/. - Rust app entry points are
client/src-tauri/src/main.rsandclient/src-tauri/src/lib.rs; shared state lives inclient/src-tauri/src/state/. - Rust gRPC client is organized under
client/src-tauri/src/grpc/withclient/andtypes/subdirectories. - Client tests are colocated with UI code (Vitest) and end-to-end tests live in
client/e2e/(Playwright).
Contracts & Sync Points (High Risk of Breakage)
- Source-of-truth API schema:
src/noteflow/grpc/proto/noteflow.proto. - Python gRPC stubs are checked in under
src/noteflow/grpc/proto/; regenerate them when the proto changes. - Rust/Tauri gRPC types are generated at build time by
client/src-tauri/build.rs; keep Rust types aligned with proto changes. - Frontend enums/DTOs in
client/src/types/mirror proto enums and backend domain types; update together to avoid runtime mismatches. - When adding or renaming RPCs, update server mixins,
src/noteflow/grpc/client.py, Tauri command wrappers, andclient/src/api/tauri-adapter.ts.
Common Pitfalls & Change Checklist
Proto / API evolution
- Update
src/noteflow/grpc/proto/noteflow.protofirst; treat it as the schema source of truth. - Regenerate Python stubs under
src/noteflow/grpc/proto/and verify imports insrc/noteflow/grpc/. - Update gRPC server mixins in
src/noteflow/grpc/_mixins/and service wiring insrc/noteflow/grpc/service.py. - Update the Python client wrapper in
src/noteflow/grpc/client.py. - Update Tauri/Rust command handlers in
client/src-tauri/src/commands/and any Rust gRPC types. - Update TypeScript adapters in
client/src/api/tauri-adapter.tsand DTOs/enums inclient/src/types/andclient/src/api/types/. - Add or adjust tests in both backend and client to cover payload changes.
Database schema & migrations
- Update ORM models and add Alembic migrations under
src/noteflow/infrastructure/persistence/migrations/. - Review autogenerated migrations before applying; keep them deterministic and reversible.
- Update repository and UnitOfWork implementations when introducing new tables/relationships.
- Keep export/summarization converters in
src/noteflow/infrastructure/converters/aligned with schema changes.
Client sync points (Rust + TS)
- Tauri command signatures in
client/src-tauri/src/commands/must match TypeScript calls inclient/src/api/tauri-adapter.ts. - Rust gRPC types are generated by
client/src-tauri/build.rs; verify proto paths when moving files. - Frontend enums in
client/src/types/andclient/src/api/types/mirror proto enums; update both sides together.
Build, Test, and Development Commands
- Backend setup/run:
python -m pip install -e ".[dev]",python -m noteflow.grpc.server. - Backend checks:
pytest,pytest -m "not integration",ruff check .,ruff check --fix .,mypy src/noteflow. - Frontend dev/test:
cd client && npm run dev,npm run build,npm run test,npm run typecheck. - Frontend lint/format:
cd client && npm run lint,npm run lint:fix,npm run format,npm run format:check. - Rust checks:
cd client && npm run lint:rs(clippy),npm run format:rs(rustfmt); install tools viarustup component add rustfmt clippy. - Packaging:
python -m build.
Makefile, Hygiene Output, and Code Quality Standards
- The Makefile is the source of truth for repo-wide code quality checks; use targets there before adding ad-hoc commands.
- Linter/type-checker outputs are written to
./.hygeine/for review and troubleshooting. - Keep Makefile targets flexible: they accept optional file or directory arguments in addition to repo-wide defaults.
- Never modify linter configurations (e.g., Ruff/Biome/ESLint/Pyrefly/Clippy/Prettier configs) unless the user explicitly requests it.
- Linting and type checking must stay strict: no relaxing rules, no suppressing warnings, no removing checks.
Coding Style & Naming Conventions
- Python 3.12 with 4-space indentation and 100-character line length (Ruff).
- Naming:
snake_casefor modules/functions,PascalCasefor classes,UPPER_SNAKE_CASEfor constants. - Keep typing explicit and compatible with strict
mypy; generated*_pb2.pyfiles are excluded from lint. - Frontend formatting uses Prettier (single quotes, 100 char width); linting uses Biome.
- Rust formatting uses
rustfmt; linting usesclippyvia the client scripts.
Type Safety Rules (Strict)
Anyis forbidden in type annotations, including indirect use viatyping.Any.- Ignore-based suppression is forbidden (
# type: ignore,# pyright: ignore,# noqa: ANN, or similar). - Use precise types, casts, and guards instead of weakening types or silencing errors.
Testing Guidelines
- Pytest with asyncio auto mode; test files
test_*.py, functionstest_*. - Use markers:
@pytest.mark.slowfor model-loading tests and@pytest.mark.integrationfor external services. - Integration tests may require PostgreSQL via
NOTEFLOW_DATABASE_URL. - React unit tests use Vitest; e2e uses Playwright from
client/e2e/. - Keep proto/type changes covered with at least one backend test and one client-facing test.
Commit & Pull Request Guidelines
- Use Conventional Commits (e.g.,
feat:,fix:,chore:) and include a concise scope when helpful. - PRs should describe the change, link related issues/specs, note DB or proto changes, and include UI screenshots when any client UI changes.
Configuration & Security Notes
- Runtime settings come from
.envorNOTEFLOW_environment variables (seesrc/noteflow/config/settings.py). - Keep secrets and local credentials out of the repo; use
.envand local config instead.