|
| 1 | +# Claude Master Instructions — Personal Vault Project |
| 2 | + |
| 3 | +This file is Claude's primary reference document. Read this at the start of every session before doing anything. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Application: Personal Vault |
| 8 | + |
| 9 | +A multi-user, private data storage application. Users register, log in, and store their own private data that no other user can see. |
| 10 | + |
| 11 | +### What a user can do |
| 12 | +- Register with a username and password |
| 13 | +- Log in and receive a session token |
| 14 | +- Store **text notes** (title + body) |
| 15 | +- Store **passwords** (label + username + password value) |
| 16 | +- Store **important notes** (tagged, searchable) |
| 17 | +- View, edit, and delete only their own data |
| 18 | + |
| 19 | +### Real-world analogy |
| 20 | +Think of it as a personal, self-hosted combination of Bitwarden (password manager) and a private notebook. Bob logs in and sees only Bob's data. Alice logs in and sees only Alice's data. |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Version Strategy |
| 25 | + |
| 26 | +| Version | Scope | Phases | |
| 27 | +|---|---|---| |
| 28 | +| v1 | API only, SQLite, no authentication | Phase 1–2 | |
| 29 | +| v2 | Authentication added, multi-user, PostgreSQL | Phase 3–4 | |
| 30 | +| v3 | Minimal frontend, DevTools learning | Phase 3 | |
| 31 | +| v4 | Architecture refactor (service + repo layers) | Phase 5 | |
| 32 | +| v5 | Containerized, Dockerized | Phase 6 | |
| 33 | +| v6 | Nginx reverse proxy | Phase 7 | |
| 34 | +| v7 | Kong API gateway | Phase 8 | |
| 35 | +| v8 | Keycloak SSO replaces custom JWT | Phase 9 | |
| 36 | +| v9 | Kubernetes deployment | Phase 10 | |
| 37 | +| v10 | Helm charts | Phase 11 | |
| 38 | +| v11 | CI/CD pipeline | Phase 12 | |
| 39 | +| v12 | Monitoring and logging | Phase 13 | |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Tech Stack |
| 44 | + |
| 45 | +| Layer | Choice | Reason | |
| 46 | +|---|---|---| |
| 47 | +| Language | Python 3.11+ | User has prior Python knowledge | |
| 48 | +| API Framework | FastAPI | User knows basics; auto-docs at /docs; async | |
| 49 | +| Database (v1) | SQLite | Zero setup; perfect for learning | |
| 50 | +| Database (v2+) | PostgreSQL | Production-grade; migrate before Docker | |
| 51 | +| ORM | SQLAlchemy 2.x | Industry standard; works with both DBs | |
| 52 | +| Migrations | Alembic | Tracks schema changes like git does for code | |
| 53 | +| Auth | Custom JWT first, then Keycloak | Learn JWT internals before enterprise SSO | |
| 54 | +| Frontend | Plain HTML + vanilla JS (no framework) | Learn fundamentals before React | |
| 55 | +| Container | Docker + docker-compose | Learn containers before Kubernetes | |
| 56 | +| Reverse Proxy | Nginx | Industry standard reverse proxy | |
| 57 | +| API Gateway | Kong | Real-world API management layer | |
| 58 | +| Orchestration | Kubernetes | After Docker fundamentals are solid | |
| 59 | +| Package manager | pip + requirements.txt → Poetry | Start simple, evolve tooling | |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## Phase Roadmap |
| 64 | + |
| 65 | +``` |
| 66 | +Phase 1 → Project setup + first API endpoint + database connection |
| 67 | +Phase 2 → Full CRUD: notes, passwords, user model (no auth yet) |
| 68 | +Phase 3 → Minimal HTML frontend + Chrome DevTools introduction |
| 69 | +Phase 4 → CORS + JWT authentication + auth middleware |
| 70 | +Phase 5 → Service layer + Repository pattern (architecture refactor) |
| 71 | +Phase 6 → Docker + docker-compose |
| 72 | +Phase 7 → Nginx reverse proxy |
| 73 | +Phase 8 → Kong API gateway |
| 74 | +Phase 9 → Keycloak (replace custom JWT) |
| 75 | +Phase 10 → Kubernetes (pods, deployments, services) |
| 76 | +Phase 11 → Helm charts |
| 77 | +Phase 12 → GitHub Actions CI/CD |
| 78 | +Phase 13 → Prometheus + Grafana + structured logging |
| 79 | +``` |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Non-Negotiable Process Rules |
| 84 | + |
| 85 | +Claude MUST follow these rules in every session without exception. |
| 86 | + |
| 87 | +### Rule 1 — Docs structure |
| 88 | +Every `docs/NNN-*.md` file must have exactly two parts: |
| 89 | + |
| 90 | +**Part 1: What we are doing** — files being created/modified, implementation steps, what is NOT in scope for this step. |
| 91 | + |
| 92 | +**Part 2: Concepts / KT** — short explanation of every tool, pattern, or technology used in this step. Not a textbook. Just enough to understand why it exists and what role it plays. Written in plain language with short examples. |
| 93 | + |
| 94 | +### Rule 2 — Explain WHY first |
| 95 | +Before implementing, explain the business reason and technical reason. Not just "we are adding X" but "we are adding X because Y problem exists." |
| 96 | + |
| 97 | +### Rule 3 — One small step at a time |
| 98 | +Never implement an entire feature in one shot. Break it into the smallest logical steps. Example: adding auth = 6 separate steps, not 1. |
| 99 | + |
| 100 | +### Rule 4 — Teach during implementation |
| 101 | +When a concept appears in code, explain it inline. Do not dump theory upfront. JWT appears in code → explain JWT then. |
| 102 | + |
| 103 | +### Rule 5 — Never skip a phase |
| 104 | +Do not jump from Phase 1 to Phase 4. Every phase has a learning purpose. Respect the sequence. |
| 105 | + |
| 106 | +### Rule 6 — Real engineering practices always |
| 107 | +Even in v1 (SQLite, no auth), always use: |
| 108 | +- Proper folder structure |
| 109 | +- Environment variables (never hardcode secrets) |
| 110 | +- Consistent naming conventions |
| 111 | +- Meaningful error responses |
| 112 | +- Git commits after every logical step |
| 113 | + |
| 114 | +### Rule 7 — Frontend is last in each phase |
| 115 | +Only build frontend after the backend step in that phase is stable and manually tested via `/docs` (FastAPI's swagger UI). |
| 116 | + |
| 117 | +### Rule 8 — KT docs on demand |
| 118 | +If the user says "I don't understand" or "create KT document" — immediately create `docs/KT-topic-name.md` using the structure defined in goal.md. |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## Folder Structure (target for v1) |
| 123 | + |
| 124 | +``` |
| 125 | +development/ ← git repo root |
| 126 | +├── claude-instructions/ ← Claude's playbooks (this directory) |
| 127 | +├── docs/ ← all planning + KT documents |
| 128 | +├── goal.md ← learning goals and mentorship rules |
| 129 | +├── README.md |
| 130 | +├── .gitignore |
| 131 | +└── vault/ ← the actual application lives here |
| 132 | + ├── app/ |
| 133 | + │ ├── main.py ← FastAPI app entry point |
| 134 | + │ ├── config.py ← environment + settings |
| 135 | + │ ├── database.py ← DB engine + session setup |
| 136 | + │ ├── models/ ← SQLAlchemy ORM models |
| 137 | + │ ├── schemas/ ← Pydantic request/response schemas |
| 138 | + │ ├── routers/ ← FastAPI route handlers |
| 139 | + │ ├── services/ ← business logic (added in Phase 5) |
| 140 | + │ └── repositories/ ← DB access layer (added in Phase 5) |
| 141 | + ├── tests/ ← pytest tests |
| 142 | + ├── .env ← local environment variables (gitignored) |
| 143 | + ├── .env.example ← committed template of env vars |
| 144 | + └── requirements.txt |
| 145 | +``` |
| 146 | + |
| 147 | +**Rule:** All application code lives inside `vault/`. All docs, plans, and Claude instructions live at the repo root level. Never mix them. |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## Application Data Models (target) |
| 152 | + |
| 153 | +### User |
| 154 | +- id, username (unique), hashed_password, created_at |
| 155 | + |
| 156 | +### Note |
| 157 | +- id, user_id (FK), title, body, created_at, updated_at |
| 158 | + |
| 159 | +### Password Entry |
| 160 | +- id, user_id (FK), label, username, encrypted_value, created_at |
| 161 | + |
| 162 | +### Tag (future, Phase 2+) |
| 163 | +- id, name, user_id |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +## DevTools Learning Goals |
| 168 | + |
| 169 | +The user has never used browser developer tools. These concepts should be taught progressively during Phase 3: |
| 170 | +- Network tab: observe HTTP requests, status codes, headers, request/response bodies |
| 171 | +- Console tab: JavaScript errors, console.log debugging |
| 172 | +- Elements tab: inspect HTML structure |
| 173 | +- Application tab: view localStorage, cookies, tokens stored in browser |
| 174 | + |
| 175 | +Tie every DevTools lesson to something that just happened in the app (e.g., "open Network tab and watch what happens when you click Save"). |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## Cloud + Domain Goal |
| 180 | + |
| 181 | +After Phase 6 (Docker), the project will be deployed to a cloud provider (to be decided) with a free domain. This simulates a real production deployment. Claude should keep this in mind when making infrastructure decisions — avoid anything that only works locally. |
| 182 | + |
| 183 | +--- |
| 184 | + |
| 185 | +## Reference Files |
| 186 | + |
| 187 | +- `goal.md` — user's full learning goal and mentorship instructions |
| 188 | +- `claude-instructions/debugging-philosophy.md` — **READ THIS** for how to handle all errors and deliberate mistakes |
| 189 | +- `claude-instructions/phase-*/` — per-phase implementation playbooks |
| 190 | +- `docs/` — all feature planning docs and KT documents created during development |
0 commit comments