# joshua-onyekachukwu/lockedin architecture

> Architecture diagram of the GitHub repository joshua-onyekachukwu/lockedin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joshua-onyekachukwu/lockedin
- Repository: https://github.com/joshua-onyekachukwu/lockedin

## Overview

#### Purpose and Runtime
Lockedin is a stake-backed behavioral commitment platform: users create protocols, fund a vault, submit evidence, receive witness decisions, and accrue penalties when requirements are missed. It is a TypeScript TanStack Start/React client backed by Convex server functions and database; Vercel hosts the frontend and Convex hosts backend/API jobs.

Entry points: `src/client.tsx`, `src/router.tsx`, `src/routes/__root.tsx`, and Convex HTTP surface `convex/http.ts`.

#### Client Routing and Access Gates
TanStack Router maps product surfaces to route modules. Main authenticated user flows are dashboard, vault detail, wallet, community, and leaderboard; public sharing has its own route. Auth callback and verification routes establish/gate access before normal product workflows.

Paths: `src/routes/dashboard.tsx`, `src/routes/vault.$id.tsx`, `src/routes/wallet.tsx`, `src/routes/verify-required.tsx`, `src/routes/share.$vaultId.tsx`.

#### Authoritative Domain Model
Convex owns persistent state and business invariants. The schema defines users, vaults/protocols, goals, check-ins/evidence, witness relationships, payments, wallet/ledger activity, penalties, notifications, and audit-oriented records. Client UI should consume Convex query/mutation APIs rather than duplicate lifecycle rules.

Paths: `convex/schema.ts`, `convex/goals.ts`, `convex/vaultLifecycle.ts`.

#### Protocol and Evidence Lifecycle
Protocol creation produces an unfunded `vault` and linked goal. Funding or wallet activation moves eligible vaults active. Users submit pending check-ins with notes and proof images; assigned witnesses approve/reject with written reports. Lifecycle logic manages status transitions, penalties, credits/shields, and downstream notifications/rewards.

Paths: `convex/goals.ts`, `convex/verifications.ts`, `convex/penalties.ts`, `convex/rewards.ts`.

#### Money Movement and Wallet Boundary
Paystack is the external payment processor for protocol funding, with initialization, verification, reconciliation, and webhook handling isolated in backend modules. Wallet supports balances, activation from available funds, withdrawal requests/cancellation, and admin-managed processing. Do not treat frontend payment status as authoritative; webhooks/reconciliation and Convex mutations establish final state.

Paths: `convex/payments.ts`, `convex/http.ts`, `src/routes/wallet.tsx`, `src/components/dashboard/fund-protocol-modal.tsx`.

#### Identity, Authorization, and Verification
Convex Auth provides sign-in. Email verification gates most app access. Admin operations require authenticated and verified users plus both a persisted admin flag and allowlisted email. Mono is the supported identity/KYC integration; direct public BVN lookup is disabled. Security and rate limiting are backend responsibilities.

Paths: `convex/auth.ts`, `convex/emailVerification.ts`, `convex/security.ts`, `convex/rateLimit.ts`, `convex/mono.ts`.

#### Community, Administration, and Automation
Partner/witness relationships support discovery, recruitment, reporting, and community-facing integrity signals. Admin routes provide user review, transaction/payment operations, lifecycle overrides, and audit access. Convex crons drive scheduled lifecycle/penalty work; notifications provide user-facing follow-up.

Paths: `convex/partners.ts`, `convex/admin.ts`, `src/routes/admin.tsx`, `convex/crons.ts`, `convex/notifications.ts`.

#### Operations and Integrations
Deployment coordination is critical: frontend `VITE_CONVEX_URL`, Convex deployment, and Paystack webhook target must all reference the same environment. External services include Paystack, Mono, Google OAuth, Resend email, optional Sentry, and Vercel. The client includes an installable PWA shell and offline fallback.

Paths: `app.config.ts`, `vercel.json`, `public/sw.js`, `convex/sentry.ts`.

Main entry points: [`src/routes/dashboard.tsx`](https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/routes/dashboard.tsx) (Product routes), [`src/client.tsx`](https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/client.tsx) (Client entry & router), [`convex/payments.ts`](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/payments.ts) (Wallet & payments), [`convex/goals.ts`](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/goals.ts) (Protocol lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_client_entry["Client entry &amp; router<br/>TanStack Start<br/>[client.tsx]"]
  node_product_routes["Product routes<br/>route modules<br/>[dashboard.tsx]"]
  node_access_routes["Access &amp; sharing routes<br/>route modules"]
  node_funding_ui["Funding UI<br/>React modal"]
  node_pwa_shell["PWA offline shell<br/>service worker<br/>[sw.js]"]
end

subgraph group_backend["Convex backend"]
  node_domain_schema[("Domain schema<br/>Convex schema<br/>[schema.ts]")]
  node_protocol_lifecycle["Protocol lifecycle<br/>Convex mutations<br/>[goals.ts]"]
  node_evidence_review["Evidence &amp; witness review<br/>Convex mutations<br/>[verifications.ts]"]
  node_penalties_rewards["Penalties &amp; rewards<br/>Convex jobs<br/>[penalties.ts]"]
  node_wallet_payments["Wallet &amp; payments<br/>Convex payment boundary<br/>[payments.ts]"]
  node_http_webhooks{{"HTTP &amp; webhooks<br/>Convex HTTP<br/>[http.ts]"}}
  node_identity_security["Identity &amp; access control<br/>Convex auth/security<br/>[auth.ts]"]
  node_mono_kyc["Mono KYC<br/>Convex integration<br/>[mono.ts]"]
  node_community_admin["Partners &amp; administration<br/>Convex operations<br/>[admin.ts]"]
  node_scheduled_followup["Scheduled follow-up<br/>Convex crons<br/>[crons.ts]"]
end

subgraph group_external["External services"]
  node_paystack{{"Paystack<br/>payment processor"}}
  node_identity_email{{"OAuth, email &amp; KYC services<br/>external services"}}
  node_deployment["Vercel &amp; deployment config<br/>hosting<br/>[vercel.json]"]
end

node_client_entry -->|"renders"| node_product_routes
node_client_entry -->|"routes through"| node_access_routes
node_client_entry -->|"installs"| node_pwa_shell
node_product_routes -->|"requires access gate"| node_identity_security
node_product_routes -->|"queries and mutates"| node_protocol_lifecycle
node_product_routes -->|"submits and reviews evidence"| node_evidence_review
node_funding_ui -->|"initiates funding"| node_wallet_payments
node_wallet_payments -->|"persists authoritative state"| node_domain_schema
node_protocol_lifecycle -->|"creates and transitions"| node_domain_schema
node_evidence_review -->|"drives protocol outcomes"| node_protocol_lifecycle
node_penalties_rewards -->|"records penalties and rewards"| node_domain_schema
node_scheduled_followup -->|"runs"| node_penalties_rewards
node_community_admin -->|"manages witness relationships"| node_evidence_review
node_community_admin -->|"enforces admin policy"| node_identity_security
node_http_webhooks -->|"reconciles payment events"| node_wallet_payments
node_paystack -->|"sends webhooks"| node_http_webhooks
node_wallet_payments -->|"initializes and verifies payments"| node_paystack
node_identity_security -->|"uses auth and verification services"| node_identity_email
node_mono_kyc -->|"connects KYC provider"| node_identity_email
node_deployment -->|"hosts frontend"| node_client_entry
node_deployment -.->|"coordinates environment endpoint"| node_http_webhooks

click node_client_entry "https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/client.tsx"
click node_product_routes "https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/routes/dashboard.tsx"
click node_access_routes "https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/routes/verify-required.tsx"
click node_funding_ui "https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/components/dashboard/fund-protocol-modal.tsx"
click node_pwa_shell "https://github.com/joshua-onyekachukwu/lockedin/blob/main/public/sw.js"
click node_domain_schema "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/schema.ts"
click node_protocol_lifecycle "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/goals.ts"
click node_evidence_review "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/verifications.ts"
click node_penalties_rewards "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/penalties.ts"
click node_wallet_payments "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/payments.ts"
click node_http_webhooks "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/http.ts"
click node_identity_security "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/auth.ts"
click node_mono_kyc "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/mono.ts"
click node_community_admin "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/admin.ts"
click node_scheduled_followup "https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/crons.ts"
click node_deployment "https://github.com/joshua-onyekachukwu/lockedin/blob/main/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_entry,node_product_routes,node_access_routes,node_funding_ui,node_pwa_shell toneBlue
class node_domain_schema,node_protocol_lifecycle,node_evidence_review,node_penalties_rewards,node_wallet_payments,node_http_webhooks,node_identity_security,node_mono_kyc,node_community_admin,node_scheduled_followup toneAmber
class node_paystack,node_identity_email,node_deployment toneMint
```

## Components

### React client

- [Client entry & router](https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/client.tsx): TanStack Start · `src/client.tsx`
- [Product routes](https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/routes/dashboard.tsx): route modules · Dashboard, vault, wallet, community, and leaderboard surfaces. · `src/routes/dashboard.tsx`
- [Access & sharing routes](https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/routes/verify-required.tsx): route modules · Verification-gated access and public vault sharing. · `src/routes/verify-required.tsx`
- [Funding UI](https://github.com/joshua-onyekachukwu/lockedin/blob/main/src/components/dashboard/fund-protocol-modal.tsx): React modal · `src/components/dashboard/fund-protocol-modal.tsx`
- [PWA offline shell](https://github.com/joshua-onyekachukwu/lockedin/blob/main/public/sw.js): service worker · `public/sw.js`

### Convex backend

- [Domain schema](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/schema.ts): Convex schema · Persistent users, vaults, goals, evidence, payments, ledger, and audit records. · `convex/schema.ts`
- [Protocol lifecycle](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/goals.ts): Convex mutations · Creates goals and vaults, then governs activation and status transitions. · `convex/goals.ts`
- [Evidence & witness review](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/verifications.ts): Convex mutations · Manages pending check-ins and witness approval or rejection reports. · `convex/verifications.ts`
- [Penalties & rewards](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/penalties.ts): Convex jobs · Applies missed-requirement penalties, credits, shields, and rewards. · `convex/penalties.ts`
- [Wallet & payments](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/payments.ts): Convex payment boundary · Authoritative funding, reconciliation, wallet activation, and withdrawals. · `convex/payments.ts`
- [HTTP & webhooks](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/http.ts): Convex HTTP · Receives external webhook traffic. · `convex/http.ts`
- [Identity & access control](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/auth.ts): Convex auth/security · Auth, verification, admin authorization, and rate limiting. · `convex/auth.ts`
- [Mono KYC](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/mono.ts): Convex integration · Supported identity/KYC integration; public BVN lookup is disabled. · `convex/mono.ts`
- [Partners & administration](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/admin.ts): Convex operations · Witness relationships, integrity signals, admin review, overrides, and audits. · `convex/admin.ts`
- [Scheduled follow-up](https://github.com/joshua-onyekachukwu/lockedin/blob/main/convex/crons.ts): Convex crons · Runs lifecycle and penalty work and triggers user notifications. · `convex/crons.ts`

### External services

- **Paystack**: payment processor
- **OAuth, email & KYC services**: external services · Google OAuth, Resend email, and Mono support identity workflows.
- [Vercel & deployment config](https://github.com/joshua-onyekachukwu/lockedin/blob/main/vercel.json): hosting · Frontend, Convex URL, and webhook target must use the same environment. · `vercel.json`

## Connections

- Client entry & router → Product routes: renders
- Client entry & router → Access & sharing routes: routes through
- Client entry & router → PWA offline shell: installs
- Product routes → Identity & access control: requires access gate
- Product routes → Protocol lifecycle: queries and mutates
- Product routes → Evidence & witness review: submits and reviews evidence
- Funding UI → Wallet & payments: initiates funding
- Wallet & payments → Domain schema: persists authoritative state
- Protocol lifecycle → Domain schema: creates and transitions
- Evidence & witness review → Protocol lifecycle: drives protocol outcomes
- Penalties & rewards → Domain schema: records penalties and rewards
- Scheduled follow-up → Penalties & rewards: runs
- Partners & administration → Evidence & witness review: manages witness relationships
- Partners & administration → Identity & access control: enforces admin policy
- HTTP & webhooks → Wallet & payments: reconciles payment events
- Paystack → HTTP & webhooks: sends webhooks
- Wallet & payments → Paystack: initializes and verifies payments
- Identity & access control → OAuth, email & KYC services: uses auth and verification services
- Mono KYC → OAuth, email & KYC services: connects KYC provider
- Vercel & deployment config → Client entry & router: hosts frontend
- Vercel & deployment config → HTTP & webhooks: coordinates environment endpoint
