1.8 KiB
1.8 KiB
Conventions and Coding Patterns
This document defines repository conventions to preserve existing architecture and behavior.
Module Boundaries
- Keep backend concerns separated by module:
- auth in
app/auth.py - configuration in
app/config.py - persistence in
app/db.py - RPC transport in
app/bitcoin_rpc.py - SSH control in
app/ssh_control.py - route composition in
app/main.py
- auth in
- Do not collapse these responsibilities into one file.
API and Error Patterns
- Protected routes must use
Depends(require_auth). - Domain errors should raise module-specific exceptions:
BitcoinRPCErrorSSHControlError
- Domain exceptions are converted to HTTP
502in centralized exception handlers. - Input validation should use Pydantic models and explicit HTTP errors for invalid state.
Persistence Patterns
- Access SQLite through
app/db.pyhelpers. - Keep node settings as a single upserted row with
id = 1. - Preserve metrics retention behavior:
- 30-day time window
- 20000 row cap
Frontend Patterns
- Keep frontend implementation in vanilla JavaScript plus Chart.js.
- Maintain centralized client
stateobject inapp/static/app.js. - Use existing API helpers (
api, error handling, auth transitions). - Keep responsive behavior aligned with current CSS breakpoints.
Security and Operational Patterns
- Require authentication for all state-changing and node-control APIs.
- Keep SSH command composition shell-safe using quoting.
- Treat background sampling as best-effort to avoid impacting request flow.
Documentation and Change Tracking
When behavior, contracts, or operations change:
- Update affected docs in
/doc. - Update
README.mdif repository landing information changes. - Record meaningful changes in
CHANGELOG.mdunder[Unreleased].
Reference index: doc/README.md.