Investor-grade monorepo scaffold with SOC2 controls, GDPR compliance, and production-ready CI/CD.
# 1. Install dependencies
npm install
# 2. Start databases
npm run db:up
# 3. Copy environment files
cp apps/api/.env.example apps/api/.env
cp apps/web/.env.example apps/web/.env.local
# 4. Update secrets in apps/api/.env (see SECURITY.md for key generation)
# 5. Run migrations + seed
npm run prisma:migrate -w apps/api
npm run prisma:seed -w apps/api
# 6. Start all services (web + api + worker)
npm run previewWeb: http://localhost:3000
API: http://localhost:4000/health
Before pushing code, always verify:
# Quick verification (typecheck + tests + secrets scan)
npm run verify:quick
# Full verification (includes builds)
npm run verify- Install dependencies:
npm install - Start databases:
npm run db:up - Configure envs:
cp apps/api/.env.example apps/api/.envcp apps/web/.env.example apps/web/.env.local
- Update
apps/api/.env:- Set
JWT_SECRETto a dev value. - Ensure
ENGINE_ENTRYPOINTpoints topackages/engine/engine_cli.py. - Ensure
WEEKLY_ENGINE_ENTRYPOINTpoints topackages/engine/weekly_cli.py. - Set
WEB_ORIGINtohttp://localhost:3000.
- Set
- Run migrations + seed:
npm run prisma:migrate -w apps/apinpm run prisma:seed -w apps/api
- Run API + web:
npm run dev
Web: http://localhost:3000
API: http://localhost:4000/health
- Register at
/registeror use the seeded user fromDEV_USER_EMAIL/DEV_USER_PASSWORD. - Complete
/onboardingonce to unlock/checkin,/today,/history,/weekly,/settings.
- Open
/weeklyand generate a review for the current week window. - Use "Download weekly PDF" to export the stored weekly report.
- Run the worker in a separate terminal:
npm run worker -w apps/api. - The scheduler stub lives in
apps/api/src/scheduler.tsand is meant to be called by an external cron in production.
- Web: 3000
- API: 4000
- Postgres: 5432
- Redis: 6379
apps/web- Next.js (App Router) + Tailwind + TypeScriptapps/api- Node.js + Express + TypeScriptpackages/engine- Python decision engine CLI (stdin/stdout JSON)packages/shared- Shared TS schemas/types (Zod)docs- Architecture and product documentationdocker-compose.yml- Local Postgres + Redis
apps/api/.envdrives the API, Prisma, engine execution, and auth.apps/web/.env.localdefinesNEXT_PUBLIC_API_URLfor API calls.ENGINE_PYTHON_PATH,ENGINE_ENTRYPOINT, andWEEKLY_ENGINE_ENTRYPOINTmust point to the Python engine CLIs.- PDF export uses Puppeteer; ensure Chromium can download on install.
- Auth uses an HttpOnly cookie; no tokens are stored in localStorage.
- Engine tests:
npm run test:engine(requirespytestinstalled) - API smoke test:
npm run test:api - Web smoke test (expects API + web running):
npm run test:web
- Prisma migrate fails: ensure Postgres is running (
npm run db:up) andDATABASE_URLis correct. - API returns 401: ensure you are logged in and
WEB_ORIGINmatches the web URL. - Onboarding required: complete
/onboardingbefore submitting check-ins. - Engine errors: check
ENGINE_PYTHON_PATHandENGINE_ENTRYPOINTinapps/api/.env. - Weekly engine errors: check
WEEKLY_ENGINE_ENTRYPOINTinapps/api/.env. - PDF export fails: ensure Puppeteer finished installing Chromium.
- Web smoke test fails: confirm
npm run dev, migrations/seed, and that cookies are set (CORS). - Shared package import errors: run
npm run build -w packages/sharedto regeneratepackages/shared/dist.
- No secrets are committed; use local
.envfiles only. - Run
npm run verify:secretsbefore every commit to scan for leaked secrets. - See docs/SECURITY.md for secret management, key rotation, and security policies.
- SOC2 controls documented in docs/soc2-pack/
- GDPR compliance with data export and deletion APIs
GitHub Actions workflow runs on every push/PR:
- Secrets scanning
- TypeScript type checking
- Full test suite (API + Engine + Web)
- Production builds
See docs/GITHUB_PUSH.md for GitHub setup and branch protection.
Development:
npm run dev- Start web + api (without worker)npm run preview- Start web + api + worker (full stack)npm run db:up- Start Postgres + Redisnpm run db:down- Stop databasesnpm run db:reset- Reset database with migrations + seed
Verification:
npm run verify:quick- Typecheck + tests + secrets scan (fast)npm run verify- Full verification including buildsnpm run verify:secrets- Scan for accidentally committed secretsnpm run verify:typecheck- TypeScript type checkingnpm run verify:test- Run all testsnpm run verify:build- Build all packages
Testing:
npm run test:engine- Python engine testsnpm run test:api- API testsnpm run test:web- Web smoke testsnpm run test- All tests
Building:
npm run build- Build all packagesnpm run build:api- Build API onlynpm run build:web- Build web onlynpm run build:shared- Build shared package only
- No secrets are committed; use local
.envfiles only. - Postgres and Redis are bound to
127.0.0.1for local access. - Replace dev credentials for any shared or production environment.