This document captures how any DraftDream operational agent should run the stack so that local and remote workflows stay predictable and safe. Follow the instructions below regardless of which assistant picks up the work to guarantee a consistent experience.
This project has a graphify knowledge graph at graphify-out/.
Rules:
- Before answering architecture or codebase questions, read graphify-out/GRAPH_REPORT.md for god nodes and community structure
- If graphify-out/wiki/index.md exists, navigate it instead of reading raw files
- After modifying code files in this session, run:
GRAPHIFY_PY="$(head -1 "$(command -v graphify)" | tr -d '#!')" && "$GRAPHIFY_PY" -c "from graphify.watch import _rebuild_code; from pathlib import Path; _rebuild_code(Path('.'))"(fallback ifgraphifyis not on PATH:python3 -m pip install --user graphifyy)
Important
This file applies ONLY to the following perimeter:
- General questions about the service and project.
- Technical and Functional Architecture documentation in
/docs. - Tooling scripts in
/scripts. - Production server configuration in
/serv. - Root-level Docker configuration files.
Instructions in this file are NOT valid and MUST NOT be followed for sub-stacks like api/, frontoffice/, backoffice/, or showcase/ unless explicitly stated as a cross-stack rule.
- Primary focus: operate and troubleshoot FitDesk services (
nginx,api,frontoffice,backoffice,mobile,showcase,mongo,redis). - Own CI/CD hygiene from
devtostagingtoprod, including smoke checks after each run. - Act as a guardian for secrets: never echo, log, or commit credentials.
- Compose definitions:
docker-compose.yml,docker-compose.dev.yml. - Service sources:
api/,frontoffice/,backoffice/,mobile/,showcase/,nginx/. - Config:
.env(loaded automatically),.codex/config.toml,.codex/codex.agent.yml,.codex/codex.tasks.yml. - Prompts:
.codex/prompts/system.md,.codex/prompts/devops.md.
- Preferred commands live under
codex.tasks.yml. Run them withcodex tasks run <task>:build:docker compose build --parallelup-dev:docker compose --profile dev up -dlogs:docker compose logs -f --tail=200test:docker compose run --rm api npm run build(acts as a smoke build until dedicated tests exist)deploy:make -f Makefile.old deploy-prod(requires confirmation)fix-502: guided nginx upstream diagnostic sequence
- Shell default:
bash. Compose assumes Docker Engine available.
git statusmust be clean or only contain intentional changes.- Confirm
.envis present locally; never commit it. - Verify Docker daemon is running (
docker info).
docker compose psto ensure expected containers are healthy.docker compose logs --tail=100on impacted services.- Update run notes or ticket with outcome and confirmations.
- Deployment path:
codex tasks run deploy(invokesmake -f Makefile.old deploy-prod). Requires manual confirmation per.codex/config.toml. - Rollback (if deployment fails): run
make -f Makefile.old down-prod, reload previous images if needed, thenmake -f Makefile.old up-prod. - For targeted restarts, prefer
docker compose --profile prod restart <service>.
- Aggregate logs:
codex tasks run logs. - Health check endpoints:
http://localhost:3000/graphql(API), relevant front/back office ports. - For nginx issues, run
codex tasks run fix-502and inspect the emitted diagnostics before applying changes.
- Dry runs by default for infra changes; only switch to apply mode after explicit approval.
- Confirm commands in
.codex/config.toml(deploy,destroy,kubectl apply,docker push) before proceeding. - Redact sensitive values following
redactpatterns in config.
- Keep
.codexfiles ASCII to avoid encoding bugs. - Update
codex.tasks.ymlwhen workflows change. - Reflect new services or runbooks in both this document and
codex.agent.yml.
- Track everything: all files must be committed unless excluded by
.gitignore. Do not leave untracked files in the working tree — if a file exists and is not git-ignored, it must be staged and committed.
- Import structure:
- Use staircase-style formatting.
- Separate external libraries from internal modules.
- Comments:
- Write in English, clear and concise.
- Comment classes, functions, methods, and complex logic.
- Focus on readability and effectiveness.
- Dead code:
- Do not leave commented-out code in the repository. Remove unused code instead of commenting it.
- NestJS GraphQL Decorators:
- Mandatory: Always provide an explicit type in
@Field(() => Type, { ... })for any property that is nullable, optional (?), or has a complex type. This prevents "Bootstrap failed Undefined type error" during application startup.
- Mandatory: Always provide an explicit type in
- Soft-delete joins:
- Whenever a list/get endpoint or resolver joins, populates, or
$lookups a related entity that supports soft delete (hasdeletedAtor equivalent), the query must exclude parents whosedeletedAtis set before returning results. This rule applies across API, frontoffice, backoffice, showcase, scripts, and any shared data access. Results must never expose orphaned children of soft-deleted parents.
- Whenever a list/get endpoint or resolver joins, populates, or