Record the requirement to start from a clean worktree, preserve the running Docker state as production reference, commit and push every completed change, and deploy features and fixes live via Docker.
5.2 KiB
5.2 KiB
Repository Guidelines
Project Structure & Module Organization
src/holds the React client:App.jsbootstraps the main views (“Slots buchen”, Store-Watch) and composes feature-specific components (z. B.DashboardView,StoreWatchPage) plus hooks/utilities in neighboring folders.public/contains the static shell served during development; only add files that must be copied verbatim into the build output.server.jsis the Express backend that serves the built client, exposes the REST APIs used by the UI (e.g./api/stores,/api/store-watch/*,/api/user/preferences/*,/api/location/nearest-store) und persistiert Daten über die Stores inconfig/.config/stores generated runtime state (<profileId>-pickup-config.json, Admin-Settings, Preferences, Watcher etc.). Keep it writable but untracked so local credentials never leak.build/is created bynpm run buildand shipped by the Express server or Docker image; never edit files here manually.docker-compose.yml,Dockerfile, andrebuildContainer.shencapsulate deployment; update them when server ports, env vars, or base images change.
Build, Test, and Development Commands
npm install– restore dependencies inpackage.json.npm start– launch the CRA dev server on port 3000 with live reload.npm run build– emit the production bundle intobuild/; run beforenode server.jsor container builds.npm test– run React Testing Library suites in watch mode; append-- --watch=falsein CI.npm run check:foodsharing-api– verify the Foodsharing endpoints used by the app againsthttps://foodsharing.de/api/doc.node server.js– serve the prebuilt UI and REST API using values from.env(e.g.,PICKUP_TOPIC, credentials, ports).docker-compose up --build– rebuild and start the containerized service, syncing the bundled UI and server.
Required Close-Out Steps
- After changes to
server.js,services/,src/,Dockerfile,docker-compose.yml, or the Foodsharing API integration, always run this sequence completely: CI=true npm test -- --watch=falsenpm run buildnpm run check:foodsharing-apiwhen Foodsharing endpoints, payloads, or response mappings are affecteddocker compose up -d --buildcurl http://localhost:3005/api/healthand confirm the response contains"status":"ok"
Git & Deployment Workflow
- Before making any code, config, Docker, or documentation change, verify
git status --shortis clean. If it is not clean, stop and reconcile the current worktree first; the running Docker service on port 3005 is the relevant production reference when deciding which state to preserve. - If the running Docker service contains changes that are not committed, compare its
/appcontents against the worktree, commit the Docker-live state, and push it before starting a new feature or fix. - After every completed feature or fix, update
.commitmessage, stage it withgit add -f .commitmessage, create a conventional commit, and pushmain. - Features and fixes must go live in Docker after the commit: run
docker compose up -d --buildand verifycurl http://localhost:3005/api/healthreturns a JSON response containing"status":"ok". - Keep
config/, credentials, request logs, HAR captures, and other runtime state out of commits unless explicitly requested.
Coding Style & Naming Conventions
- Use 2-space indentation and Standard/Prettier-compatible formatting; rely on the CRA ESLint config (
react-app,react-app/jest) for feedback. - Favor functional React components with PascalCase filenames (
PickupConfigEditor.js) and camelCase props/state keys. - Keep config schema fields (e.g.,
desiredWeekday,onlyNotify) camelCase across client and API payloads. - Prefer descriptive folder-local CSS files rather than global selectors; co-locate assets next to their component whenever possible.
Testing Guidelines
- React Testing Library + Jest underpin
App.test.js; add<Component>.test.jsfiles alongside components to exercise rendering and validation. - Initialize helpers inside
setupTests.jsto keep suites lean. - Aim for meaningful edge cases (blank config, duplicate IDs, toggling
onlyNotify). Pull requests should demonstrate passingnpm testoutput or CI logs.
Commit & Pull Request Guidelines
- Follow conventional commits (e.g.,
feat: add notification panel,fix: debounce config saves) and keep subjects ≤72 characters. - After every change, refresh
.commitmessagewith the final commit text and ensure it is staged (e.g.,git add -f .commitmessage) so tooling can reuse it automatically. - Reference issues or API endpoints impacted inside the body, and describe user-visible changes plus verification steps.
- PRs must include: summary of API/UI changes, screenshots or JSON samples when modifying config shape, notes on new env vars, and confirmation that
npm testandnpm run buildsucceed.
Security & Configuration Tips
- Store secrets in
.env, not in version control; provide.env.exampleupdates when new variables (ports, credentials) are introduced. - The server writes to
config/pickup-config.json; ensure the directory exists and has the correct permissions before deploying or running containers.