# kriasoft/react-starter-kit architecture

> Architecture diagram of the GitHub repository kriasoft/react-starter-kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kriasoft/react-starter-kit
- Repository: https://github.com/kriasoft/react-starter-kit

## Overview

React Starter Kit is a full-stack SaaS starter: a user enters the React app through the edge-routed web worker, uses authentication and organization/billing capabilities, and reaches API-backed results. The API worker constructs request context and mounts Hono/tRPC plus Better Auth; Drizzle schemas define persistent domain state. The README documents independently deployed web, app, and API Workers with service bindings. Authentication, billing, email, marketing, UI primitives, and the standalone WebSocket protocol are preserved as meaningful branches. Some app-to-API and database runtime wiring is not shown in the excerpts, so those links are left unverified.

Main entry points: [`apps/api/lib/app.ts`](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/app.ts) (Hono and tRPC routes), [`apps/api/worker.ts`](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/worker.ts) (API Worker), [`apps/app/components/auth/auth-form.tsx`](https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/components/auth/auth-form.tsx) (Auth form), [`apps/api/lib/auth.ts`](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/auth.ts) (Authentication and orgs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge entrypoints"]
  node_web["Marketing edge router<br/>[worker.ts]"]
end

subgraph group_frontend["React application"]
  node_spa["React SPA<br/>[index.tsx]"]
  node_routes["App routes<br/>[route.tsx]"]
  node_authform["Auth form<br/>[auth-form.tsx]"]
  node_otpview["OTP verification UI"]
  node_apiclient["Typed API queries<br/>[config.ts]"]
end

subgraph group_services["API services"]
  node_apiworker["API Worker<br/>[worker.ts]"]
  node_httpapi["Hono and tRPC routes<br/>[app.ts]"]
  node_requestctx["Request context<br/>[context.ts]"]
  node_auth["Authentication and orgs<br/>[auth.ts]"]
  node_billing["Billing procedures<br/>[billing.ts]"]
  node_config["Config procedures<br/>[config.ts]"]
  node_emailservice["Email delivery<br/>[email.ts]"]
end

subgraph group_data["Persistence and messaging"]
  node_dbclient["Database clients<br/>[db.ts]"]
  node_schema["Domain schema<br/>[organization.ts]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_shared["Shared capabilities"]
  node_emailtemplates["Email templates<br/>[otp-email.tsx]"]
  node_websocket["WebSocket routing<br/>[router.ts]"]
  node_messages["Typed messages<br/>[messages.ts]"]
  node_ui["UI primitives<br/>[dialog.tsx]"]
end

node_visitor(("User"))
node_stripe["Stripe"]

node_visitor -->|"requests site"| node_web
node_web -->|"routes app traffic"| node_spa
node_web -->|"proxies API traffic"| node_apiworker
node_visitor -.->|"uses application"| node_spa
node_spa -.->|"renders routes"| node_routes
node_routes -.->|"offers sign-in"| node_authform
node_authform -->|"renders OTP step"| node_otpview
node_authform -->|"uses controls"| node_ui
node_authform -->|"loads providers"| node_apiclient
node_apiclient -.->|"queries API"| node_httpapi
node_apiworker -->|"creates clients"| node_dbclient
node_apiworker -->|"creates auth"| node_auth
node_apiworker -->|"mounts app"| node_httpapi
node_apiworker -->|"sets request state"| node_requestctx
node_httpapi -->|"builds tRPC context"| node_requestctx
node_httpapi -->|"registers router"| node_billing
node_httpapi -->|"registers router"| node_config
node_httpapi -->|"handles auth requests"| node_auth
node_auth -->|"sends OTP and mail"| node_emailservice
node_emailservice -->|"renders templates"| node_emailtemplates
node_auth -->|"configures subscriptions"| node_stripe
node_billing -.->|"uses billing provider"| node_stripe
node_dbclient -.->|"uses schema"| node_schema
node_schema -.->|"persists domain data"| node_postgres
node_websocket -->|"registers handlers"| node_messages

click node_web "https://github.com/kriasoft/react-starter-kit/blob/main/apps/web/worker.ts"
click node_spa "https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/index.tsx"
click node_routes "https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/routes/(app)/route.tsx"
click node_authform "https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/components/auth/auth-form.tsx"
click node_otpview "https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/components/auth/otp-verification.tsx"
click node_apiclient "https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/lib/queries/config.ts"
click node_apiworker "https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/worker.ts"
click node_httpapi "https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/app.ts"
click node_requestctx "https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/context.ts"
click node_auth "https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/auth.ts"
click node_billing "https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/routers/billing.ts"
click node_config "https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/routers/config.ts"
click node_emailservice "https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/email.ts"
click node_emailtemplates "https://github.com/kriasoft/react-starter-kit/blob/main/apps/email/templates/otp-email.tsx"
click node_dbclient "https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/db.ts"
click node_schema "https://github.com/kriasoft/react-starter-kit/blob/main/db/schema/organization.ts"
click node_websocket "https://github.com/kriasoft/react-starter-kit/blob/main/packages/ws-protocol/router.ts"
click node_messages "https://github.com/kriasoft/react-starter-kit/blob/main/packages/ws-protocol/messages.ts"
click node_ui "https://github.com/kriasoft/react-starter-kit/blob/main/packages/ui/components/dialog.tsx"

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_web,node_visitor toneBlue
class node_spa,node_routes,node_authform,node_otpview,node_apiclient toneAmber
class node_apiworker,node_httpapi,node_requestctx,node_auth,node_billing,node_config,node_emailservice toneMint
class node_dbclient,node_schema,node_postgres toneRose
class node_emailtemplates,node_websocket,node_messages,node_ui,node_stripe toneIndigo
```

## Components

### Edge entrypoints

- [Marketing edge router](https://github.com/kriasoft/react-starter-kit/blob/main/apps/web/worker.ts): `apps/web/worker.ts`

### React application

- [React SPA](https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/index.tsx): `apps/app/index.tsx`
- [App routes](https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/routes/(app)/route.tsx): `apps/app/routes/(app)/route.tsx`
- [Auth form](https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/components/auth/auth-form.tsx): `apps/app/components/auth/auth-form.tsx`
- [OTP verification UI](https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/components/auth/otp-verification.tsx): `apps/app/components/auth/otp-verification.tsx`
- [Typed API queries](https://github.com/kriasoft/react-starter-kit/blob/main/apps/app/lib/queries/config.ts): `apps/app/lib/queries/config.ts`

### API services

- [API Worker](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/worker.ts): `apps/api/worker.ts`
- [Hono and tRPC routes](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/app.ts): `apps/api/lib/app.ts`
- [Request context](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/context.ts): `apps/api/lib/context.ts`
- [Authentication and orgs](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/auth.ts): `apps/api/lib/auth.ts`
- [Billing procedures](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/routers/billing.ts): `apps/api/routers/billing.ts`
- [Config procedures](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/routers/config.ts): `apps/api/routers/config.ts`
- [Email delivery](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/email.ts): `apps/api/lib/email.ts`

### Persistence and messaging

- [Database clients](https://github.com/kriasoft/react-starter-kit/blob/main/apps/api/lib/db.ts): `apps/api/lib/db.ts`
- [Domain schema](https://github.com/kriasoft/react-starter-kit/blob/main/db/schema/organization.ts): `db/schema/organization.ts`
- **PostgreSQL**

### Shared capabilities

- [Email templates](https://github.com/kriasoft/react-starter-kit/blob/main/apps/email/templates/otp-email.tsx): `apps/email/templates/otp-email.tsx`
- [WebSocket routing](https://github.com/kriasoft/react-starter-kit/blob/main/packages/ws-protocol/router.ts): `packages/ws-protocol/router.ts`
- [Typed messages](https://github.com/kriasoft/react-starter-kit/blob/main/packages/ws-protocol/messages.ts): `packages/ws-protocol/messages.ts`
- [UI primitives](https://github.com/kriasoft/react-starter-kit/blob/main/packages/ui/components/dialog.tsx): `packages/ui/components/dialog.tsx`

### Other components

- **User**
- **Stripe**

## Connections

- User → Marketing edge router: requests site
- Marketing edge router → React SPA: routes app traffic
- Marketing edge router → API Worker: proxies API traffic
- User → React SPA: uses application
- React SPA → App routes: renders routes
- App routes → Auth form: offers sign-in
- Auth form → OTP verification UI: renders OTP step (evidence: `apps/app/components/auth/auth-form.tsx`)
- Auth form → UI primitives: uses controls (evidence: `apps/app/components/auth/auth-form.tsx`)
- Auth form → Typed API queries: loads providers (evidence: `apps/app/components/auth/auth-form.tsx`)
- Typed API queries → Hono and tRPC routes: queries API
- API Worker → Database clients: creates clients (evidence: `apps/api/worker.ts`)
- API Worker → Authentication and orgs: creates auth (evidence: `apps/api/worker.ts`)
- API Worker → Hono and tRPC routes: mounts app (evidence: `apps/api/worker.ts`)
- API Worker → Request context: sets request state (evidence: `apps/api/worker.ts`)
- Hono and tRPC routes → Request context: builds tRPC context (evidence: `apps/api/lib/app.ts`)
- Hono and tRPC routes → Billing procedures: registers router (evidence: `apps/api/lib/app.ts`)
- Hono and tRPC routes → Config procedures: registers router (evidence: `apps/api/lib/app.ts`)
- Hono and tRPC routes → Authentication and orgs: handles auth requests (evidence: `apps/api/lib/app.ts`)
- Authentication and orgs → Email delivery: sends OTP and mail (evidence: `apps/api/lib/auth.ts`)
- Email delivery → Email templates: renders templates (evidence: `apps/api/lib/email.ts`)
- Authentication and orgs → Stripe: configures subscriptions (evidence: `apps/api/lib/auth.ts`)
- Billing procedures → Stripe: uses billing provider
- Database clients → Domain schema: uses schema
- Domain schema → PostgreSQL: persists domain data
- WebSocket routing → Typed messages: registers handlers (evidence: `packages/ws-protocol/router.ts`)
