|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | +- `src/`: Warp backend (config/resource/weather/web_app endpoints, processors, schedulers); tests live beside code in `*_test.rs` and `integration_test_*.rs`. |
| 5 | +- `web-app/`: static frontend served by the binary (`index.html`, `script.js`, `style.css`, `images/`, `fonts/`). |
| 6 | +- Root: Rust workspace files (`Cargo.toml`, `Cargo.lock`), container assets (`Containerfile`, `docker-compose.yaml`), app assets (`icon.png`, `CHANGELOG.md`); `target/` holds build output and stays untracked. |
| 7 | +- Runtime data paths are set by env vars (`RESOURCE_PATHS`, `DATA_FOLDER`); keep large media outside the repo. |
| 8 | + |
| 9 | +## Build, Test, and Development Commands |
| 10 | +- `cargo build` / `cargo run`: compile or start the backend locally (set `RESOURCE_PATHS=/path/to/pictures DATA_FOLDER=./data`). |
| 11 | +- `cargo test`: run unit + integration tests (async cases use `tokio`). |
| 12 | +- `cargo fmt` then `cargo clippy --all-targets -- -D warnings`: format and lint; keep CI free of warnings. |
| 13 | +- `docker build -t rouhim/this-week-in-past -f Containerfile .`: produce the scratch-based image from staged binaries. |
| 14 | +- `docker-compose up --build`: run locally against a bind-mounted photo directory via `/resources:ro`. |
| 15 | + |
| 16 | +## Coding Style & Naming Conventions |
| 17 | +- Rust 2021 with 4-space indent; rely on `cargo fmt` for spacing and import order. |
| 18 | +- Files/modules use `snake_case`; types/traits use `PascalCase`; constants use `SCREAMING_SNAKE_CASE`. |
| 19 | +- Group imports std → external → crate; prefer explicit `use crate::…` paths. |
| 20 | +- Keep functions small, return `Result<T, E>`, and add `log`/`env_logger` context for failures. |
| 21 | +- Frontend: vanilla JS/CSS in `web-app`; keep IDs/classes descriptive and consistent with existing names. |
| 22 | + |
| 23 | +## Testing Guidelines |
| 24 | +- Mirror the GIVEN/WHEN/THEN comment style shown in `resource_processor_test.rs`. |
| 25 | +- Place unit tests next to code with `#[cfg(test)]`; use `#[tokio::test]` for async integration-style tests in `integration_test_*`. |
| 26 | +- Use `assertor`/`pretty_assertions` helpers; avoid random data where determinism matters. |
| 27 | +- Add coverage when touching HTTP endpoints, resource processing, or new config/env branches. |
| 28 | + |
| 29 | +## Commit & Pull Request Guidelines |
| 30 | +- Follow Conventional Commits (`feat:`, `fix:`, `chore(deps):`, `chore(release): … [skip ci]` aligns with history). |
| 31 | +- One focused topic per commit; rebase before opening a PR. |
| 32 | +- PRs should state intent, commands/tests run, config/env changes, and include screenshots for UI updates. |
| 33 | +- Link related issues/discussions and flag breaking changes or data migrations explicitly. |
| 34 | + |
| 35 | +## Configuration & Security |
| 36 | +- Keep secrets local: `OPEN_WEATHER_MAP_API_KEY`, `BIGDATA_CLOUD_API_KEY`, `HOME_ASSISTANT_API_TOKEN` must not be committed. |
| 37 | +- Default mounts expect read-only `RESOURCE_PATHS` and writable `DATA_FOLDER`; verify permissions when running in Docker or on NAS shares. |
0 commit comments