4 KiB
4 KiB
MeshiTrack — Copilot Instructions
This is a nutrition management application built as a TypeScript monorepo.
Project Documentation
Before writing code, always consult the relevant documentation in the docs/ directory:
docs/PLAN.md— Project overview, tech stack, and phase roadmapdocs/architecture.md— Architecture Decision Records (ADRs)docs/cross-cutting.md— API versioning, pagination, error handling, security, observability
Phase Specifications
Each phase has a detailed spec with schemas, endpoints, and business logic:
docs/phases/phase-0-foundation.md— Monorepo setup, Docker, Keycloak, authdocs/phases/phase-1-product-library.md— Product CRUD, barcode lookup, LLM interfacedocs/phases/phase-2-recipes.md— Recipes, nutrition calculation, LLM importdocs/phases/phase-3-pantry.md— Pantry tracking, freshness, notificationsdocs/phases/phase-4-meal-planning.md— Meal plans, nutrition targets, suggestion enginedocs/phases/phase-5-grocery.md— Shopping lists, price tracking, store comparisondocs/phases/phase-6-llm.md— LLM provider implementations, NLP parsing
Coding Instructions (MUST READ)
The docs/instructions/ directory contains best practices and conventions that must be followed:
docs/instructions/conventions.md— Naming, formatting, linting, git conventionsdocs/instructions/fastify.md— Fastify plugin structure, Awilix DI, validation, hooks, repository patterndocs/instructions/nextjs.md— App Router, Server/Client Components, data fetching, formsdocs/instructions/mongodb.md— Schema design, indexing, queries, paginationdocs/instructions/typescript-zod.md— Type design, Zod schemas, shared package rulesdocs/instructions/turborepo.md— Monorepo workspace config, build pipelines, dependenciesdocs/instructions/docker.md— Compose services, Dockerfiles, env vars, health checksdocs/instructions/keycloak.md— Auth integration, JWT claims, guards, token refreshdocs/instructions/testing.md— Vitest unit/integration/E2E test patterns, coverage targets
Tool Usage Rules
- Always use
read_fileto read file contents — never use terminal commands likeGet-Content,cat,head, ortailto read files. These will be denied. - Always use
grep_searchorfile_searchto find files and patterns — never useSelect-String,grep,find, orrgin terminal commands. - Run scripts only via
npm run <script>— never usenpx, and never add flags like2>&1, pipes (|), orSelect-Objecttonpm runcommands. - Use
execution_subagentfor build/test/lint commands — it runsnpm run build,npm run test, andnpm run lintand returns relevant output without piping. - Every implementation task must end with:
npm run build,npm run test, andnpm run lintall passing.
Key Rules
- All domain types and Zod schemas live in
packages/shared— never duplicate types across packages. - Every data query must filter by
householdId— this is the multi-tenancy boundary. - Use Server Components by default in Next.js — only add
'use client'when interactivity is needed. - Use the repository pattern in Fastify — routes → services → repositories (Awilix DI).
- Use
.lean().exec()on all Mongoose read queries. - No
anytypes — useunknownand validate with Zod if the type is truly unknown. - Cursor-based pagination — never use
skip()for large collections. - ESM everywhere —
"type": "module",.jsextensions on imports,import typefor type-only imports. - Zod v4 — import from
'zod/v4', usez.enum()for enums,z.email()/z.url()as top-level. - No
.jsextensions on@/imports inpackages/web— Next.js resolves TypeScript files directly;.jsextensions on@/path-alias imports break Turbopack and webpack. Only use.jsextensions inpackages/apiandpackages/shared(Node ESM).