# sunithvs/jiobase architecture

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

- Interactive diagram: https://gitdiagram.com/sunithvs/jiobase
- Repository: https://github.com/sunithvs/jiobase

## Overview

1. **Repository shape and deployment model**  
   JioBase is a pnpm monorepo split into three runtime applications plus shared libraries and a CLI. The production stack is intentionally Cloudflare-centric: a reverse proxy Worker, a management API Worker, and a SvelteKit frontend deployed on Cloudflare Pages.

2. **End-user request path: the reverse proxy**  
   `apps/proxy` is the runtime that actually sits in the traffic path. It accepts requests on a `slug.jiobase.com` subdomain, resolves the target Supabase project from app config, and forwards HTTP traffic and WebSockets transparently to the upstream Supabase origin. The proxy is the core boundary between Indian ISP-facing traffic and the blocked `*.supabase.co` destination.

3. **Management plane: the API Worker**  
   `apps/api` is a Hono-based API on Cloudflare Workers. It handles account/app management, authentication, and operational concerns for the dashboard. Its route split suggests two main domains: `auth` for user/session flows and `apps` for CRUD and configuration of proxied apps.

4. **Persistence and state**  
   The API uses Cloudflare D1 with Drizzle ORM for persistent metadata. The presence of migrations and `schema.ts` indicates a relational model for users, apps, and related settings. Cloudflare KV is used alongside D1 for synchronization or cached operational state, reflected by the `kv-sync` service.

5. **Security and abuse controls**  
   The API has dedicated middleware for authentication and rate limiting. Password hashing utilities and ID generation helpers live under `src/lib`, which implies the API owns user identity creation and credential verification rather than delegating those concerns to the frontend.

6. **Frontend: marketing site, docs, and dashboard**  
   `apps/web` is a SvelteKit application that combines public content, documentation, blog posts, and the authenticated dashboard. Route groups separate concerns: landing and informational pages, blog content, docs, fix/guides sections, and dashboard pages for creating and editing apps.

7. **Frontend-to-API boundary**  
   The web app uses a small client API layer and an auth store, showing a clear boundary where the browser talks to the management API for login, registration, and dashboard actions. Server-side route modules under `fix/[slug]` and `guides/[framework]` indicate some pages also fetch or compute data during SSR/build time.

8. **Content and conversion surfaces**  
   The web app is not just a dashboard; it also serves SEO-heavy educational content around Supabase blocking in India, self-hosting, and proxy usage. Components like donation gates, related pages, blog suggestions, and platform installers show that content, onboarding, and conversion are first-class parts of the product architecture.

9. **Shared contracts across apps**  
   `packages/shared` contains constants, types, and validation logic reused by the API, web app, proxy, and CLI. This package is the repo’s contract layer, keeping configuration formats, enums, and input validation consistent across deployment targets and reducing drift between services.

10. **CLI and scaffolding flow**  
    `packages/cli` provides a `create-jiobase` command that scaffolds worker-based projects from templates. It generates starter files such as `wrangler.toml`, `package.json`, `tsconfig`, and worker entrypoints, which means the repo includes a developer-facing product surface for bootstrapping self-hosted or companion Workers.

11. **Infrastructure and build boundaries**  
    Each app has its own `wrangler.toml`, `.env.example`, and TypeScript config, reinforcing that they are deployed independently even though they share code. Drizzle migrations are checked into the API app, while the web app is built through SvelteKit/Vite and the proxy/API are built for the Workers runtime.

12. **Overall system diagram view**  
    The main data flow is: browser or app client → `apps/web` for dashboard/login/content → `apps/api` for app/account management → D1/KV for persistence and operational state → `apps/proxy` for live request forwarding to Supabase. The proxy is the runtime traffic plane, the API is the control plane, and the web app is the operator-facing UI plus public site.

Main entry points: [`apps/api`](https://github.com/sunithvs/jiobase/tree/main/apps/api) (API), [`apps/proxy`](https://github.com/sunithvs/jiobase/tree/main/apps/proxy) (Proxy), [`apps/web`](https://github.com/sunithvs/jiobase/tree/main/apps/web) (Web), [`packages/cli`](https://github.com/sunithvs/jiobase/tree/main/packages/cli) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Applications"]
  node_web["Web<br/>SvelteKit site"]
  node_web_routes["Routes"]
  node_web_components["Components"]
  node_web_client["API Client<br/>browser client<br/>[api.ts]"]
  node_web_auth_store(("Auth Store<br/>session state<br/>[auth.svelte.ts]"))
  node_api["API<br/>Hono worker"]
  node_api_routes_auth["Auth Routes<br/>session routes<br/>[auth.ts]"]
  node_api_routes_apps["App Routes<br/>management routes<br/>[apps.ts]"]
  node_api_middleware["Middleware<br/>security layer"]
  node_proxy["Proxy<br/>Cloudflare Worker"]
  node_proxy_handler["Handler<br/>request router<br/>[handler.ts]"]
  node_proxy_ws(("WebSocket<br/>ws tunneling<br/>[websocket.ts]"))
  node_proxy_config["Config<br/>proxy settings<br/>[config.ts]"]
end

subgraph group_packages["Shared Packages"]
  node_shared["Shared<br/>contracts package"]
  node_cli["CLI<br/>scaffolding tool"]
end

subgraph group_infra["Platform State"]
  node_d1[("D1<br/>relational state")]
  node_kv[("KV<br/>sync cache")]
  node_supabase[("Supabase<br/>upstream origin")]
end

node_web -->|"renders"| node_web_routes
node_web -->|"uses"| node_web_components
node_web -->|"calls"| node_web_client
node_web -->|"tracks"| node_web_auth_store
node_web_client -->|"HTTP"| node_api
node_api -->|"serves"| node_api_routes_auth
node_api -->|"serves"| node_api_routes_apps
node_api -->|"protects"| node_api_middleware
node_api -->|"persists"| node_d1
node_api -->|"syncs"| node_kv
node_api -->|"shares contracts"| node_shared
node_proxy -->|"configures"| node_proxy_config
node_proxy -->|"executes"| node_proxy_handler
node_proxy -->|"tunnels"| node_proxy_ws
node_proxy -->|"shares contracts"| node_shared
node_proxy_handler -->|"forwards to"| node_supabase
node_proxy_ws -->|"bridges to"| node_supabase
node_cli -->|"validates with"| node_shared
node_cli -.->|"generates"| node_proxy
node_cli -.->|"generates"| node_api

click node_web "https://github.com/sunithvs/jiobase/tree/main/apps/web"
click node_web_routes "https://github.com/sunithvs/jiobase/tree/main/apps/web/src/routes"
click node_web_components "https://github.com/sunithvs/jiobase/tree/main/apps/web/src/lib/components"
click node_web_client "https://github.com/sunithvs/jiobase/blob/main/apps/web/src/lib/api.ts"
click node_web_auth_store "https://github.com/sunithvs/jiobase/blob/main/apps/web/src/lib/stores/auth.svelte.ts"
click node_api "https://github.com/sunithvs/jiobase/tree/main/apps/api"
click node_api_routes_auth "https://github.com/sunithvs/jiobase/blob/main/apps/api/src/routes/auth.ts"
click node_api_routes_apps "https://github.com/sunithvs/jiobase/blob/main/apps/api/src/routes/apps.ts"
click node_api_middleware "https://github.com/sunithvs/jiobase/tree/main/apps/api/src/middleware"
click node_proxy "https://github.com/sunithvs/jiobase/tree/main/apps/proxy"
click node_proxy_handler "https://github.com/sunithvs/jiobase/blob/main/apps/proxy/src/handler.ts"
click node_proxy_ws "https://github.com/sunithvs/jiobase/blob/main/apps/proxy/src/websocket.ts"
click node_proxy_config "https://github.com/sunithvs/jiobase/blob/main/apps/proxy/src/config.ts"
click node_shared "https://github.com/sunithvs/jiobase/tree/main/packages/shared"
click node_cli "https://github.com/sunithvs/jiobase/tree/main/packages/cli"

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_web_routes,node_web_components,node_web_client,node_web_auth_store,node_api,node_api_routes_auth,node_api_routes_apps,node_api_middleware,node_proxy,node_proxy_handler,node_proxy_ws,node_proxy_config toneBlue
class node_shared,node_cli toneAmber
class node_d1,node_kv,node_supabase toneMint
```

## Components

### Applications

Deployable runtime apps and the public site

- [Web](https://github.com/sunithvs/jiobase/tree/main/apps/web): SvelteKit site · Public marketing site, docs, blog, and authenticated dashboard · `apps/web`
- [Routes](https://github.com/sunithvs/jiobase/tree/main/apps/web/src/routes): content+UI routes · Landing pages, blog, docs, guides, fix pages, auth screens, and dashboard views · `apps/web/src/routes`
- [Components](https://github.com/sunithvs/jiobase/tree/main/apps/web/src/lib/components): ui components · Reusable UI for onboarding, conversion, navigation, and content presentation · `apps/web/src/lib/components`
- [API Client](https://github.com/sunithvs/jiobase/blob/main/apps/web/src/lib/api.ts): browser client · Frontend boundary for login, registration, and dashboard actions · `apps/web/src/lib/api.ts`
- [Auth Store](https://github.com/sunithvs/jiobase/blob/main/apps/web/src/lib/stores/auth.svelte.ts): session state · Client-side auth state for the dashboard and account flows · `apps/web/src/lib/stores/auth.svelte.ts`
- [API](https://github.com/sunithvs/jiobase/tree/main/apps/api): Hono worker · Management plane for auth, app CRUD, and operational control · `apps/api`
- [Auth Routes](https://github.com/sunithvs/jiobase/blob/main/apps/api/src/routes/auth.ts): session routes · User registration, login, and session handling · `apps/api/src/routes/auth.ts`
- [App Routes](https://github.com/sunithvs/jiobase/blob/main/apps/api/src/routes/apps.ts): management routes · CRUD and configuration endpoints for proxied apps · `apps/api/src/routes/apps.ts`
- [Middleware](https://github.com/sunithvs/jiobase/tree/main/apps/api/src/middleware): security layer · Authentication and rate limiting around API requests · `apps/api/src/middleware`
- [Proxy](https://github.com/sunithvs/jiobase/tree/main/apps/proxy): Cloudflare Worker · Traffic plane that forwards slug-based requests to upstream Supabase · `apps/proxy`
- [Handler](https://github.com/sunithvs/jiobase/blob/main/apps/proxy/src/handler.ts): request router · Resolves target projects and forwards HTTP traffic transparently · `apps/proxy/src/handler.ts`
- [WebSocket](https://github.com/sunithvs/jiobase/blob/main/apps/proxy/src/websocket.ts): ws tunneling · WebSocket forwarding path for live upstream connections · `apps/proxy/src/websocket.ts`
- [Config](https://github.com/sunithvs/jiobase/blob/main/apps/proxy/src/config.ts): proxy settings · Runtime configuration and origin mapping for slug routing · `apps/proxy/src/config.ts`

### Shared Packages

Reusable contracts and developer tooling

- [Shared](https://github.com/sunithvs/jiobase/tree/main/packages/shared): contracts package · Cross-app constants, types, and validation shared by all runtimes · `packages/shared`
- [CLI](https://github.com/sunithvs/jiobase/tree/main/packages/cli): scaffolding tool · create-jiobase project generator for worker-based starter apps · `packages/cli`

### Platform State

Persistence and external services

- **D1**: relational state · Persistent metadata store for users, apps, and settings
- **KV**: sync cache · Operational cache or synchronization state paired with D1
- **Supabase**: upstream origin · Blocked or proxied backend destination for live application traffic

## Connections

- Web → Routes: renders · Page routing and SSR content live here
- Web → Components: uses · Pages compose reusable UI components
- Web → API Client: calls · Browser-side actions talk to the management API
- Web → Auth Store: tracks · Client session state for authenticated dashboard flows
- API Client → API: HTTP · Login, registration, and dashboard requests
- API → Auth Routes: serves · Auth endpoints are mounted in the worker
- API → App Routes: serves · App management endpoints are mounted in the worker
- API → Middleware: protects · Authentication and rate limits wrap routes
- API → D1: persists · Primary relational storage for metadata
- API → KV: syncs · Operational cache / synchronization state
- API → Shared: shares contracts · Uses common types and validation with other runtimes
- Proxy → Config: configures · Loads slug and origin mapping at runtime
- Proxy → Handler: executes · Core request forwarding path
- Proxy → WebSocket: tunnels · WebSocket forwarding path for upstream connections
- Proxy → Shared: shares contracts · Uses shared config and validation shapes
- Handler → Supabase: forwards to · Transparent HTTP proxy to upstream origin
- WebSocket → Supabase: bridges to · WebSocket traffic is relayed upstream
- CLI → Shared: validates with · Uses shared schema and config rules for scaffolding
- CLI → Proxy: generates · Creates worker-style starter projects similar to runtime apps
- CLI → API: generates · Scaffolds worker-based project templates
