Skip to content

Commit 92b61ec

Browse files
committed
release: v0.0.1 initial production phase
1 parent 9f142ec commit 92b61ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4790
-0
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
coverage/
7+
8+
# TypeScript
9+
*.tsbuildinfo
10+
11+
# Env
12+
.env
13+
.env.*
14+
!.env.example
15+
16+
# Logs
17+
npm-debug.log*
18+
yarn-debug.log*
19+
yarn-error.log*
20+
pnpm-debug.log*
21+
22+
# OS/editor
23+
.DS_Store
24+
Thumbs.db
25+
.vscode/
26+
.idea/
27+
28+
# Cursor/Codex temp exports
29+
*.tmp

AI/ARCHITECTURE.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# ARCHITECTURE.md
2+
**Agent:** Claude (Planner)
3+
**Date:** 2026-03-24
4+
5+
---
6+
7+
## 1. System Layers
8+
9+
```
10+
┌─────────────────────────────────────────────────────────────┐
11+
│ CLIENTS │
12+
│ React Frontend │ SDK (embeddable) │ External API │
13+
└────────────────────┴──────────────────────┴─────────────────┘
14+
15+
┌────────▼────────┐
16+
│ API LAYER │
17+
│ Fastify + Zod │
18+
│ JWT Middleware │
19+
│ /v1/* routes │
20+
└────────┬────────┘
21+
22+
┌────────────────┼────────────────┐
23+
│ │ │
24+
┌────────▼──────┐ ┌───────▼──────┐ ┌──────▼──────┐
25+
│ CORE ENGINE │ │ AUTH MODULE │ │ PROJECT DB │
26+
│ (pure TS) │ │ JWT+bcrypt │ │ Prisma ORM │
27+
│ No deps │ └──────────────┘ └─────────────┘
28+
└────────┬──────┘
29+
30+
┌────────▼──────┐
31+
│ CONFIG LAYER │
32+
│ JSON → DB │
33+
│ Overridable │
34+
└───────────────┘
35+
36+
┌────────▼──────┐
37+
│ PostgreSQL │
38+
└───────────────┘
39+
```
40+
41+
## 2. Module Boundaries
42+
43+
```
44+
measurtent/
45+
├── packages/
46+
│ ├── engine/ # Pure TS — ZERO framework deps
47+
│ ├── config/ # JSON loader + DB config resolver
48+
│ ├── api/ # Fastify server
49+
│ ├── sdk/ # Browser/Node embeddable bundle
50+
│ └── shared/ # Zod schemas, types, constants
51+
├── apps/
52+
│ └── web/ # React frontend
53+
├── prisma/ # Schema + migrations
54+
└── AI/ # Agent coordination files
55+
```
56+
57+
## 3. Data Flow — Calculation
58+
59+
```
60+
Client Request
61+
→ POST /v1/calculate { guestCount, seatingStyle, tentType, addOns }
62+
→ Zod validation (shared/schemas)
63+
→ Config loaded (JSON or DB by tenantId)
64+
→ engine.calculate(inputs, config) → CalculationResult
65+
→ Response { requiredSqFt, recommendedTentSize, tables, chairs, geometry }
66+
```
67+
68+
## 4. Data Flow — Auth
69+
70+
```
71+
POST /v1/auth/register → hash password → create User → return JWT pair
72+
POST /v1/auth/login → verify password → return JWT pair
73+
POST /v1/auth/refresh → verify refresh token → return new access token
74+
```
75+
76+
## 5. Data Flow — Projects
77+
78+
```
79+
POST /v1/projects → create Project + CalculationSnapshot (userId, tenantId)
80+
GET /v1/projects → list user's projects (paginated)
81+
GET /v1/projects/:id → get project + snapshots
82+
PUT /v1/projects/:id → update project
83+
DELETE /v1/projects/:id → soft delete
84+
GET /v1/projects/:id/export?format=json|csv → export
85+
```
86+
87+
## 6. Multi-Tenant Design
88+
89+
- Every user-owned record carries `tenantId`
90+
- `tenantId` defaults to the user's own ID (self-serve SaaS)
91+
- Config rules can be overridden per tenant
92+
- API keys (future) will carry `tenantId` claim in JWT
93+
94+
## 7. External Integration — badshuffle
95+
96+
- The API is designed to be mounted as a sub-router
97+
- No global state, no framework lock-in
98+
- Engine can be imported as a pure function
99+
- badshuffle can import `@measurtent/engine` and `@measurtent/sdk` directly
100+
- Auth tokens are standard JWT — compatible with existing auth middleware
101+
- Integration point: `POST /v1/calculate` can be proxied or embedded
102+
103+
## 8. Config Schema (JSON baseline)
104+
105+
```json
106+
{
107+
"seatingStyles": {
108+
"banquet": { "sqftPerPerson": 12, "tableShape": "rectangular", "seatsPerTable": 8 },
109+
"reception": { "sqftPerPerson": 8, "tableShape": "cocktail", "seatsPerTable": 0 },
110+
"theater": { "sqftPerPerson": 6, "tableShape": "none", "seatsPerTable": 0 },
111+
"classroom": { "sqftPerPerson": 10, "tableShape": "rectangular", "seatsPerTable": 3 }
112+
},
113+
"tentTypes": {
114+
"pole": { "widthIncrements": [20, 30, 40, 60, 80], "lengthIncrement": 10, "bufferFactor": 1.1 },
115+
"frame": { "widthIncrements": [10, 15, 20, 30, 40], "lengthIncrement": 5, "bufferFactor": 1.05 },
116+
"clearspan": { "widthIncrements": [30, 40, 50, 60, 100], "lengthIncrement": 10, "bufferFactor": 1.0 }
117+
},
118+
"addOns": {
119+
"stage": { "sqft": 200 },
120+
"danceFloor": { "sqft": 400 },
121+
"bar": { "sqft": 100 },
122+
"catering": { "sqft": 300 },
123+
"buffet": { "sqft": 150 }
124+
},
125+
"chairSqft": 2.5,
126+
"aisleBuffer": 0.15
127+
}
128+
```

AI/CURRENT_FOCUS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# CURRENT_FOCUS.md
2+
**Agent:** Claude (Planner)
3+
**Date:** 2026-03-24
4+
5+
---
6+
7+
## Active Work
8+
9+
**Phase:** 1 — Architecture + Initial Planning
10+
11+
**Current Agent:** Claude → handing off to Codex
12+
13+
## What's Being Done Right Now
14+
15+
- [x] System architecture designed
16+
- [x] Risk analysis completed
17+
- [x] Database schema defined (Prisma-level)
18+
- [x] API contract defined (no code)
19+
- [x] Implementation plan phased
20+
- [x] TODO.md populated with Phase 1 tasks
21+
- [ ] Core engine implementation (→ Codex)
22+
- [ ] API skeleton implementation (→ Codex)
23+
24+
## Immediate Next Step
25+
26+
Codex must implement:
27+
1. `packages/engine/` — pure TypeScript calculation engine
28+
2. `packages/api/` — Fastify skeleton with /v1/calculate endpoint
29+
3. Zod schemas shared between engine and API
30+
4. Config loader (JSON-based, DB-ready interface)

AI/HANDOFF.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# HANDOFF.md
2+
**From:** Codex (Distributed Implementation Team)
3+
**To:** Next Agent (Cursor)
4+
**Date:** 2026-03-24
5+
6+
---
7+
8+
## Summary of Work Completed (Phase 1)
9+
10+
Phase 1 TASK-001 through TASK-005 are implemented and integrated:
11+
12+
- Monorepo scaffold with pnpm workspace and strict TypeScript base config
13+
- Shared Zod schemas + domain types for calculation/auth/project models
14+
- Config package with JSON defaults, provider interface, JSON provider, DB-ready provider stub, and `loadConfig(tenantId?)`
15+
- Pure TypeScript engine with config-driven tent calculations
16+
- Fastify API with plugin setup, `/health`, Swagger, and `POST /v1/calculate`
17+
18+
Validation completed:
19+
20+
- `pnpm -r typecheck` passes
21+
- API injection tests pass for:
22+
- `GET /health` => 200 `{ "status": "ok" }`
23+
- `POST /v1/calculate` valid payload => 200 with `CalculationResult`
24+
- `POST /v1/calculate` invalid payload => 400 with Zod issues
25+
26+
---
27+
28+
## Files Created/Updated Per Agent
29+
30+
### Codex-1 (TASK-001: Monorepo scaffold)
31+
- `package.json`
32+
- `pnpm-workspace.yaml`
33+
- `tsconfig.base.json`
34+
- `packages/shared/package.json`
35+
- `packages/shared/tsconfig.json`
36+
- `packages/engine/package.json`
37+
- `packages/engine/tsconfig.json`
38+
- `packages/config/package.json`
39+
- `packages/config/tsconfig.json`
40+
- `packages/api/package.json`
41+
- `packages/api/tsconfig.json`
42+
- `packages/sdk/package.json`
43+
- `packages/sdk/tsconfig.json`
44+
- `apps/web/package.json`
45+
- `apps/web/tsconfig.json`
46+
- scaffold dirs under `packages/*/src` and `apps/web/src`
47+
48+
### Codex-2 (TASK-002: Shared schemas)
49+
- `packages/shared/src/schemas/calculation.ts`
50+
- `packages/shared/src/schemas/auth.ts`
51+
- `packages/shared/src/schemas/project.ts`
52+
- `packages/shared/src/types/index.ts`
53+
- `packages/shared/src/index.ts`
54+
55+
### Codex-3 (TASK-003: Config system)
56+
- `packages/config/src/defaults.json`
57+
- `packages/config/src/types.ts`
58+
- `packages/config/src/loader.ts`
59+
- `packages/config/src/index.ts`
60+
61+
### Codex-4 (TASK-004: Core engine)
62+
- `packages/engine/src/addons.ts`
63+
- `packages/engine/src/geometry.ts`
64+
- `packages/engine/src/calculator.ts`
65+
- `packages/engine/src/index.ts`
66+
67+
### Codex-5 (TASK-005: API layer)
68+
- `packages/api/src/plugins/sensible.ts`
69+
- `packages/api/src/plugins/swagger.ts`
70+
- `packages/api/src/routes/v1/calculate.ts`
71+
- `packages/api/src/app.ts`
72+
- `packages/api/src/server.ts`
73+
74+
---
75+
76+
## Cross-Agent Integration Issues Resolved
77+
78+
1. Type mismatch between engine and shared `CalculationResult.recommendedTentSize`
79+
- Resolved by aligning shared and engine recommendation shape.
80+
81+
2. Missing workspace/runtime dependencies in package manifests
82+
- Resolved by adding Fastify/plugin/zod/workspace deps and executable scripts.
83+
84+
3. TypeScript config friction under strict settings
85+
- Resolved by normalizing tsconfig package settings and import behavior.
86+
87+
4. API strict optional typing + error handling mismatch
88+
- Resolved by exact-optional-safe route registration and explicit 400 responses.
89+
90+
---
91+
92+
## What Remains
93+
94+
Phase 2 onward remains:
95+
96+
- TASK-006 Prisma schema implementation
97+
- TASK-007 Auth system
98+
- TASK-008 Project CRUD
99+
- TASK-009 React scaffold
100+
- TASK-010 Calculator UI
101+
- TASK-011 Export endpoints
102+
- TASK-012 SDK bundle
103+
104+
---
105+
106+
## Recommended Next Step (Phase 2)
107+
108+
Start with TASK-006 (Prisma schema) and TASK-007 (Auth) before project CRUD to keep data model and auth context stable. Then proceed to TASK-008.

AI/PROJECT_CONTEXT.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# PROJECT_CONTEXT.md
2+
**Agent:** Claude (Planner)
3+
**Date:** 2026-03-24
4+
**Status:** Architecture Phase Complete
5+
6+
---
7+
8+
## System Purpose
9+
10+
MeasureTent is a SaaS-ready Tent & Event Rental Calculator platform. It allows event planners, rental companies, and end-users to calculate tent sizes, seating arrangements, and equipment requirements based on configurable business rules.
11+
12+
## Stack
13+
14+
| Layer | Technology |
15+
|---|---|
16+
| Core Engine | Pure TypeScript (framework-free) |
17+
| Config | JSON files → PostgreSQL (phase 2) |
18+
| API | Fastify + Zod + JWT |
19+
| Database | PostgreSQL + Prisma ORM |
20+
| Auth | JWT (access + refresh) + bcrypt |
21+
| Frontend | React + TailwindCSS + React Query |
22+
| SDK | TypeScript ESM bundle (embeddable) |
23+
| Export | csv-stringify + JSON native |
24+
| Docs | Swagger (fastify-swagger) |
25+
| Validation | Zod (shared between API and engine) |
26+
27+
## Business Goals
28+
29+
1. Accurate, config-driven event calculations
30+
2. User account system with named project saving
31+
3. Exportable project data (JSON + CSV)
32+
4. Open, versioned API for third-party integration
33+
5. Future merge readiness with https://github.com/248Tech/badshuffle
34+
6. Multi-tenant architecture ready from day one
35+
36+
## Constraints
37+
38+
- NO hardcoded business logic (sqft per person, table sizes, chair counts)
39+
- Core engine must run in Node, browser, or as imported SDK
40+
- All calculation rules must be overridable via config
41+
- API must be independently deployable and mergeable
42+
- Database schema must support multi-tenancy (tenantId on all user-owned tables)

0 commit comments

Comments
 (0)