ArchitectureOverview

Architecture Overview

Lacroo Pro follows a polyglot monorepo architecture with clear service boundaries.

High-Level Data Flow

Browser/Mobile → Next.js BFF (Auth + Server Actions) → Go API (Chi + WebSockets) → PostgreSQL 16
                                                        ↕
                                                   Temporal Workers
                                                        ↕
                                                   Redis (Cache)

Key Principles

  1. OpenAPI Contract is God — Every cross-boundary type is generated from /openapi.yaml
  2. No ORMs — Raw SQL via sqlc + pgx
  3. Next.js is a BFF only — Never talks directly to Postgres
  4. No client-side polling — Postgres LISTEN/NOTIFY → Go WebSocket → TanStack Query invalidation
  5. Temporal for durable work — Any task >500ms or needing retry guarantees

Monorepo Boundaries

WorkspacePurposeRuntime
apps/webNext.js frontend + BFFVercel
apps/mobileExpo React Native appiOS/Android
apps/docsNextra documentationVercel
packages/uiShared shadcn/ui components—
packages/configShared linting/TS configs—
packages/api-clientGenerated OpenAPI TS client—
backend/apiGo Chi router handlersFly.io
backend/workersTemporal workflowsFly.io
backend/dbPostgres migrations + sqlc—