System Architecture

Doc Status: Good | ✓ Clear summary | ✓ Easy to read | ✓ Matches code | ✓ Good structure | ✓ Professional look | ✓ Visual components

Architecture Diagram

Data Flow

App Data — Convex

All app data (students, courses, attendance, payments) flows through Convex:
Browser / Mobile

    │ useQuery / useMutation (real-time, auto-subscribed)

Convex DB
(queries / mutations — atomic, transactional)

External APIs — Convex Action

Lark, Meta CAPI, ZNS are called from a Convex action using the vendor’s own SDK or fetch:
Convex Action

    │ fetch / vendor SDK

External API (Lark / Meta CAPI / ZNS)

Inbound Webhooks — CF Worker → Convex

Cloudflare Workers are HTTP entry points only — they verify the signature and forward to a Convex httpAction:
External Service (Lark / Meta)

    │ POST webhook

CF Worker (Hono) — verify signature only

    │ httpAction call

Convex (business logic)

Deployment Targets

SurfaceWhereHow
App data backendConvex Cloudnpx convex deploy --prod
apps/websiteCloudflare Workers Static Assetspnpm build && wrangler deploy
apps/adminCloudflare Workers Static Assetspnpm build && wrangler deploy
apps/lark-syncCloudflare Workers (Hono)wrangler deploy
apps/meta-conversions-workerCloudflare Workers (Hono)wrangler deploy
Marketing CMS (Sanity)Sanity CloudManaged by PM via Studio
apps/mobileEAS Build → App Store / Play Storeeas build

Auth

Convex Auth (@convex-dev/auth) is the auth library. It owns the users / authAccounts / authSessions / authVerificationCodes / authVerifiers tables and exposes sign-in / sign-out hooks.
AppClient Provider
AdminConvexAuthNextjsProvider
MobileConvexAuthProvider + expo-secure-store
WebsitePublic (no auth)
Webhooks (apps/lark-sync, apps/meta-conversions-worker) authenticate via shared secret, not Convex Auth.

Key Environments

EnvironmentBranchURL
Productionmainwondersound.vn, admin.wondersound.vn
Stagingdevdev.wondersound.vn
Convex devlocalnpx convex dev

CI/CD

TriggerAction
Push to mainDeploy website to CF (prod), Convex prod
Push to devDeploy website to CF (staging)
Sanity publishGitHub dispatch → rebuild website