# Turn 1 — Repo Bootstrap & Data Layer

## What's in this drop

Files delivered in Turn 1:

```
vihar-sewa/
├── package.json                       Workspace root + scripts
├── pnpm-workspace.yaml                pnpm workspace config
├── tsconfig.base.json                 Shared TS compiler options
├── .env.example                       All env vars (copy to .env)
├── .gitignore
├── .prettierrc.json
├── README.md                          Setup steps
│
├── packages/db/
│   ├── package.json
│   ├── tsconfig.json
│   ├── prisma/schema.prisma           Full Phase 1 data model
│   └── src/
│       ├── index.ts                   Singleton Prisma client + helpers
│       └── seed.ts                    South Mumbai pilot seed
│
├── packages/shared/
│   ├── package.json
│   ├── tsconfig.json
│   └── src/
│       ├── index.ts                   Barrel export
│       ├── constants.ts               LocationType, ViharStatus, etc.
│       └── schemas/                   Zod schemas
│           ├── auth.ts
│           ├── vihar.ts
│           ├── location.ts
│           ├── user.ts
│           └── allocation.ts
│
├── apps/web/package.json              Stub (filled in Turn 3)
├── apps/api/package.json              Stub (filled in Turn 2)
│
└── scripts/
    ├── init-db.sql                    Local MySQL provisioning
    └── preflight.ts                   Health check
```

## How to run it (laptop)

```bash
# 1. Unpack
cd ~/projects                          # or wherever you keep repos
unzip vihar-sewa-turn1.zip
cd vihar-sewa

# 2. Initialise git
git init
git add .
git commit -m "Turn 1: monorepo + data model"
git branch -M main
git remote add origin git@github.com:mindforgeerp/vihar-sewa.git
# git push -u origin main  (after the repo exists on GitHub)

# 3. Install deps
pnpm install

# 4. Set up local DB
mysql -u root -p < scripts/init-db.sql

# 5. Configure env
cp .env.example .env
# Generate JWT_SECRET:
openssl rand -hex 64
# Paste output as JWT_SECRET in .env

# 6. Generate Prisma client + run migration
pnpm db:generate
pnpm db:migrate    # name the migration "init"

# 7. Seed pilot data
pnpm db:seed

# 8. Verify
pnpm tsx scripts/preflight.ts
pnpm db:studio     # opens http://localhost:5555 - browse the seeded data
```

If `db:studio` shows the city, localities, samuday, and your captain user — Turn 1 is good.

## Things to verify before Turn 2

- [ ] `pnpm install` completes without errors
- [ ] `pnpm db:migrate` creates all 11 tables in `vihar_db`
- [ ] `pnpm db:seed` runs to "Seed complete" without errors
- [ ] You can log into `pnpm db:studio` and see captain1 in the `user` table

If any of these fail, paste the error in our chat and I'll debug before Turn 2.

## What Turn 2 will deliver

NestJS backend filled out:
- App bootstrap, config module, Prisma module
- Auth module (login, logout, /me, change password, JWT guard)
- City-scope guard (auto-filters all queries by req.user.cityId)
- Captain role guard
- All controllers + service stubs for the API spec in design doc Section 12
- DTO classes wrapping the zod schemas from packages/shared
- Centralised error filter, request logger
- Health check endpoint

Turn 2 will compile and run, but most endpoints will return "not implemented yet" — actual handler logic gets implemented in Claude Code on your laptop with task briefs I'll provide.
