# Phase 1: Monorepo Scaffold + Tooling

**Status:** ✅ Complete
**Parent plan:** [PLAN.md](./PLAN.md)
**Domain:** fullstack

## Objective
Set up the Turborepo monorepo with all three packages, configure TypeScript, linting, testing, and development tooling. After this phase, `turbo dev` should start both client and server.

## Tasks

- [x] Task 1: Initialize Turborepo monorepo at project root with `turbo.json`
- [x] Task 2: Create `apps/client` — React 19 + TypeScript + Vite app with basic App component
- [x] Task 3: Create `apps/server` — Fastify + TypeScript server with health check endpoint (`GET /api/health`)
- [x] Task 4: Create `packages/shared` — TypeScript package for shared types, exported as ESM
- [x] Task 5: Configure root `package.json` with workspaces, scripts (`dev`, `build`, `test`, `lint`)
- [x] Task 6: Configure TypeScript — root `tsconfig.json` with project references, per-package `tsconfig.json`
- [x] Task 7: Configure ESLint + Prettier — root config with React plugin for client, Node plugin for server
- [x] Task 8: Configure Vitest — per-package test setup, root `turbo.json` pipeline for `test` task
- [x] Task 9: Set up Prisma in `apps/server` — initialize with SQLite provider, empty schema
- [x] Task 10: Configure Vite proxy — proxy `/api/*` requests from client dev server to Fastify server
- [x] Task 11: Verify `turbo dev` starts both client (port 5173) and server (port 3001) simultaneously
- [x] Task 12: Add `.gitignore` covering node_modules, dist, .env, prisma SQLite files

## Files to Modify/Create
- `package.json` — root workspace config
- `turbo.json` — Turborepo pipeline config
- `tsconfig.json` — root TypeScript config
- `eslint.config.js` — root ESLint flat config (ESLint 9 uses flat config, not `.eslintrc.cjs`)
- `.prettierrc` — Prettier config
- `.gitignore` — ignore patterns
- `apps/client/package.json` — React + Vite dependencies
- `apps/client/tsconfig.json` — client TypeScript config
- `apps/client/vite.config.ts` — Vite config with API proxy
- `apps/client/vitest.config.ts` — Vitest config for client
- `apps/client/index.html` — entry HTML
- `apps/client/src/main.tsx` — React entry point
- `apps/client/src/App.tsx` — root App component
- `apps/server/package.json` — Fastify dependencies
- `apps/server/tsconfig.json` — server TypeScript config
- `apps/server/vitest.config.ts` — Vitest config for server
- `apps/server/src/index.ts` — Fastify server entry with health endpoint
- `apps/server/prisma/schema.prisma` — initial Prisma schema (SQLite, empty models)
- `apps/server/.env` — DATABASE_URL for SQLite
- `packages/shared/package.json` — shared types package config
- `packages/shared/tsconfig.json` — shared TypeScript config
- `packages/shared/vitest.config.ts` — Vitest config for shared
- `packages/shared/src/index.ts` — barrel export

## Acceptance Criteria
- [x] `npm install` at root resolves all workspaces
- [x] `turbo dev` starts client on :5173 and server on :3001
- [x] `GET /api/health` returns `{ status: "ok" }` from Fastify
- [x] Client renders a basic "House Plan Maker" heading
- [x] TypeScript compiles without errors across all packages
- [x] ESLint and Prettier are configured and runnable
- [x] Vitest is configured and runs (even with 0 tests)

## Notes
- Using Node.js 22 (available on system)
- SQLite for development simplicity — PostgreSQL adapter can be swapped later
- Prisma schema starts empty — models added in Phase 2
- Vite proxy avoids CORS issues during development
- ESLint 9 flat config used instead of legacy `.eslintrc.cjs` (ESLint 9 default)

## Review Checklist
- [x] All tasks completed
- [x] Code follows project conventions
- [x] No unintended side effects
- [x] Build passes
- [x] Tests pass (new + existing)

## Handoff to Next Phase
Phase 1 scaffold is complete. The monorepo is fully operational with:
- Turborepo managing 3 packages (`@house-plan-maker/client`, `@house-plan-maker/server`, `@house-plan-maker/shared`)
- All commands work: `turbo dev`, `turbo build`, `turbo test`, `turbo lint`
- Server health endpoint returns `{ status: "ok", timestamp: "..." }`
- Client renders "House Plan Maker" heading
- Prisma initialized with SQLite, ready for models in Phase 2
- Shared package exports `HealthCheckResponse` type used by server

Phase 2 can proceed to add the data model (Prisma schema), API endpoints, and basic CRUD UI.
