server/holds the Express app (routes, middleware, services, helpers); each layer keeps business logic out ofserver.js.client/is a Vite + React SPA; components live insrc/, assets inpublic/, and UI tests insrc/components/__tests__/.- Shared data such as migrations/seed scripts live in
db/, while runtime SQLite files land indata/(ignored by git). Persona prompts and UX notes live inprompts/anddiscussions/. - Keep new server-side tests near the code under
__tests__/folders to mirror the import path.
npm install && npm --prefix client installensures both backend and frontend dependencies are in sync.npm run devrebuilds the client and starts the production-style Express server; use when validating the integrated stack.npm startalone serves the already-built client fromclient/dist/. For hot reload, runnpm --prefix client run devalongsidenpm start.npm run lintlints backend CommonJS;npm run lint:clienttargets the React code;npm run lint:allruns both.npm testruns the Jest suite (services, middleware, route handlers with Supertest);npm run test:clienttriggers Vitest via the client package.
- JavaScript/JSX use 2-space indentation, semicolons, and ESLint configs defined in
eslint.config.js(root andclient/). Run the relevant lint command before committing. - Backend modules stay CommonJS (
module.exports), while frontend code is ES modules. Name files after their primary export (chatService.js,Composer.jsx). - Use camelCase for functions/variables, PascalCase for React components, and uppercase snake case for constants (e.g.,
OLLAMA_CHAT_URL). Keep HTTP handlers pure and delegate to services.
- Backend: Jest with Supertest. Place specs next to their subjects (
server/services/__tests__/chatService.test.js) and stub SQLite/Ollama via helpers. Prefer descriptivedescribeblocks likedescribe('createSession'). - Frontend: Vitest with Testing Library in
client/src/components/__tests__/. Render components with fake session data pulled fromprompts/when relevant, and assert ARIA labels rather than implementation details. - Aim to cover every new endpoint, reducer, or critical UI interaction. Use
npm --prefix client run test:watchfor iterative work and add regression tests for reported bugs.
- Follow the existing style—short, imperative subjects such as
Improve share modal layoutorMove db.js into db/. Include the scope if helpful (Add sessionService tests). - Every PR should describe: motivation, key changes, manual verification steps (
npm run dev, screenshot of UI states), and linked issues/discussions. Mention migrations or new env vars explicitly. - Keep commits small and logically grouped: tests with their implementation, refactors isolated from feature work, and never commit the
data/*.sqlitefiles or local.envsecrets.
- Required env vars (
PORT,OLLAMA_CHAT_URL,OLLAMA_MODEL) can be exported locally or stored in a.envignored file; document non-default values in the PR. data/chat.sqliteis recreated automatically—delete it when you need a clean slate, but never modify files insidedb/without adding matching migration notes. Always verify Ollama is running (ollama serve) before reporting backend issues.
- Always summarize the request and explain your plan before making code changes.
- Always summarize your changes after showing the diff.