-
Notifications
You must be signed in to change notification settings - Fork 9
03 Architecture
Vicky Patel edited this page Sep 14, 2026
·
1 revision
Deep-dive architectural specification for PACT OS.
graph TD
Client[Browser / Mobile PWA] -->|HTTPS / WSS| Edge[Vercel Cloud Edge / Next.js 16]
Edge -->|Server Actions| ActionLayer[Zod Validation & Server Actions]
ActionLayer -->|Authenticated Context| Supabase[(Supabase PostgreSQL 15+)]
Supabase -->|Row Level Security| RLS[RLS Boundary: auth.uid = user_id]
Cron[Vercel Cron / pg_cron] -->|Bearer Auth| Sweeper[/api/cron/sweep-deadlines]
Sweeper -->|Batch Scan| Supabase
- Server Components: Render page shells, fetch initial server-side data, and stream HTML.
-
Client Leaf Components: Interactive controls (modals, timers, form inputs) tagged with
"use client". -
Design Tokens: Custom CSS variables, Tailwind CSS v4 glassmorphism tokens, and obsidian dark mode palette (
#050505).
- Server Actions: Encapsulate all database mutations with strict Zod schema validation.
-
Domain Engines: Pure TypeScript domain logic (e.g.
src/lib/money.ts,src/lib/time.ts,src/lib/accountability/). -
URL as State: Application state (filters, dates, tab selections) is bound deterministically to URL query params via
useUrlState.
-
Database Schema: 26 frozen SQL migrations in
supabase/migrations/. -
Authentication: Session cookie management handled by
@supabase/ssr. - Authorization: Row Level Security (RLS) enforced on 100% of PostgreSQL tables.
sequenceDiagram
participant User as Client Browser
participant SA as Server Action
participant Zod as Zod Schema
participant Auth as Supabase Auth
participant DB as PostgreSQL DB
User->>SA: Submit Form Payload
SA->>Zod: Validate Payload Structure
alt Schema Invalid
Zod-->>User: Return Validation Error
else Schema Valid
SA->>Auth: Verify Identity (supabase.auth.getUser)
Auth-->>SA: Verified User (auth.uid)
SA->>DB: Execute Query with User ID
DB-->>User: Return Success Result
end
-
Server-Side Identity Verification: Identity is derived exclusively from
supabase.auth.getUser(). Client-provideduser_idvalues in payloads are rejected. - Schema Enforcement: 100% of Server Actions validate input objects against Zod schemas prior to database operations.
- No Unencrypted Client State: Confidential consequence payloads remain encrypted/masked in PostgreSQL.
-
Storage: All database timestamps use PostgreSQL
TIMESTAMPTZ(stored in UTC). -
User Anchor: User timezone is stored as an IANA timezone string in
profiles.timezone(e.g.,'America/New_York'). - Day Boundary Conversion: Calculations convert UTC timestamps to localized start-of-day/end-of-day before evaluating streaks or day planner slots.
-
Server Clock Authority: Status transitions (e.g. marking a task
missed) are evaluated against server time (now()), preventing client clock manipulation.
graph LR
UserTrigger[User Starts Timer] --> AudioCtx[Initialize Web Audio Context]
AudioCtx --> Oscillator[Oscillators & Buffer Generators]
AudioCtx --> Filter[BiquadFilterNode]
Filter --> Destination[Audio Output]
-
Offline Sound Synthesis: Generates ambient focus soundscapes dynamically using native Web Audio API (
AudioContext). - Zero External Assets: Contains zero MP3/WAV file downloads or external audio CDN dependencies.
-
Synthesizer Nodes: Uses
BiquadFilterNode, custom audio buffer noise generators, and sine wave chime oscillators.
-
Schedule: Executes automatically every minute via Vercel Cron /
pg_cron. -
Authentication: Protected by timing-safe Bearer token verification (
CRON_SECRET). -
Operation:
- Queries all active commitments where
deadline_at < NOW()andstatus = 'pending'. - Updates task status to
missed. - Activates bound consequence records (
is_activated = true). - Dispatches notification alerts via notification dispatcher.
- Queries all active commitments where
| 🏛️ Project Hub | 🛠️ Developer Docs | 💬 Community & Support |
|---|---|---|
| GitHub Repository | System Architecture | GitHub Discussions |
| Beginner Issue Catalog | Design System | Open Issues |
| Production Deployment | API Reference | Pull Requests |
| Project Roadmap | Testing & QA Matrix | Maintainer Governance |
- Codebase Tour
- Domain Model
- Database Architecture
- Security Model
- Financial System
- Consequence System
- External Integrations
- Discipline Intelligence
- Data Portability & Sync