# spiritbulb/mcloud architecture

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

- Interactive diagram: https://gitdiagram.com/spiritbulb/mcloud
- Repository: https://github.com/spiritbulb/mcloud

## Overview

Menengai Cloud is a multi-app platform for merchants, NGOs and creators. A central workflow is merchant onboarding and organization/store management, followed by storefront configuration and publication; shoppers then browse, order and pay through the storefront. The repository also includes the Nuru learning app and mobile APIs, plus server provisioning. The README establishes the apps’ roles, while sampled files and the source index expose selected implementation links; unsampled paths are represented cautiously, and links without direct evidence are omitted.

Main entry points: [`tools/reverb-upcloud/src/app.ts`](https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/app.ts) (Provisioning API), [`apps/web/app/(marketing)/home/page.tsx`](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/(marketing)/home/page.tsx) (Platform hub), [`apps/storefront/app/(storefront)/store/[slug]/page.tsx`](https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/app/(storefront)/store/%5Bslug%5D/page.tsx) (Public storefront), [`apps/web/app/api/mobile/chat/route.ts`](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/route.ts) (Notes-aware chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform and identity"]
  node_web_platform["Platform hub<br/>[page.tsx]"]
  node_onboarding["Organization onboarding<br/>[page.tsx]"]
  node_org_management["Organization management<br/>[page.tsx]"]
  node_identity_handoff["Authentication handoff<br/>[tickets.ts]"]
  node_mobile_api["Mobile API<br/>[_lib.ts]"]
end

subgraph group_commerce["Storefront commerce"]
  node_store_management["Store management<br/>[page.tsx]"]
  node_merchant_stores["Store access logic<br/>[stores.ts]"]
  node_storefront["Public storefront<br/>[page.tsx]"]
  node_theme_engine["Theme rendering<br/>[engine.ts]"]
  node_theme_manifest["Bundled themes<br/>[themes-manifest.ts]"]
  node_service_detail["Service detail theme"]
  node_mdx_content["Rich content renderer<br/>[MdxContent.tsx]"]
  node_commerce_api["Store and checkout APIs<br/>[route.ts]"]
  node_payment_provider["Payment providers"]
end

subgraph group_learning["Nuru learning"]
  node_nuru_app["Nuru study app<br/>[page.tsx]"]
  node_nuru_files["Study file workflows<br/>[route.ts]"]
  node_note_ingest["Note ingestion<br/>[route.ts]"]
  node_note_embedding["Note embeddings<br/>[embed.ts]"]
  node_mobile_chat["Notes-aware chat<br/>[route.ts]"]
  node_chat_loop["Chat orchestration<br/>[loop.ts]"]
  node_chat_adapters["Model adapters<br/>[adapters.ts]"]
  node_chat_anthropic["Anthropic completion"]
  node_chat_azure["Azure completion<br/>[complete.azure.ts]"]
end

subgraph group_shared["Shared services"]
  node_database[("Supabase data layer<br/>[server.ts]")]
  node_database_types["Database schema types<br/>[database.types.ts]"]
end

subgraph group_infrastructure["Server provisioning"]
  node_server_api["Provisioning API<br/>[app.ts]"]
  node_server_create["Create validation<br/>[create.ts]"]
  node_lxd_client["LXD operations<br/>[lxd.ts]"]
  node_server_mapping["Server state mapping<br/>[map.ts]"]
end

node_merchant(("Merchant"))
node_shopper(("Shopper"))
node_mobile_user(("Mobile user"))
node_lxd_service["LXD service"]

node_merchant -->|"uses platform"| node_web_platform
node_web_platform -->|"starts setup"| node_onboarding
node_merchant -->|"manages organization"| node_org_management
node_web_platform -.->|"supports sign-in"| node_identity_handoff
node_mobile_user -->|"calls mobile APIs"| node_mobile_api
node_merchant -->|"configures store"| node_store_management
node_store_management -.->|"uses access logic"| node_merchant_stores
node_shopper -->|"browses store"| node_storefront
node_storefront -.->|"renders themes"| node_theme_engine
node_theme_engine -->|"reads templates"| node_theme_manifest
node_storefront -.->|"renders service page"| node_service_detail
node_service_detail -->|"renders content"| node_mdx_content
node_shopper -->|"places orders"| node_commerce_api
node_commerce_api -->|"initiates payments"| node_payment_provider
node_mobile_user -.->|"studies materials"| node_nuru_app
node_nuru_app -.->|"manages files"| node_nuru_files
node_mobile_user -->|"submits notes"| node_note_ingest
node_note_ingest -->|"embeds chunks"| node_note_embedding
node_mobile_user -->|"chats about notes"| node_mobile_chat
node_mobile_chat -->|"runs chat"| node_chat_loop
node_mobile_chat -->|"selects adapter"| node_chat_adapters
node_chat_adapters -->|"dispatches completion"| node_chat_anthropic
node_chat_adapters -->|"dispatches completion"| node_chat_azure
node_database -->|"types queries"| node_database_types
node_server_api -->|"validates creation"| node_server_create
node_server_api -.->|"manages instances"| node_lxd_client
node_server_api -->|"maps server state"| node_server_mapping
node_lxd_client -.->|"calls hypervisor"| node_lxd_service

click node_web_platform "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/(marketing)/home/page.tsx"
click node_onboarding "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/(merchant)/org/onboarding/page.tsx"
click node_org_management "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/(merchant)/org/%5BorgSlug%5D/(org)/page.tsx"
click node_identity_handoff "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/_handoff/tickets.ts"
click node_mobile_api "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/_lib.ts"
click node_store_management "https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/app/(merchant)/org/%5BorgSlug%5D/%5BstoreSlug%5D/settings/page.tsx"
click node_merchant_stores "https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/lib/merchant/stores.ts"
click node_storefront "https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/app/(storefront)/store/%5Bslug%5D/page.tsx"
click node_theme_engine "https://github.com/spiritbulb/mcloud/blob/main/packages/liquid/src/engine.ts"
click node_theme_manifest "https://github.com/spiritbulb/mcloud/blob/main/packages/liquid/src/themes-manifest.ts"
click node_service_detail "https://github.com/spiritbulb/mcloud/blob/main/packages/themes/src/classic/ServiceDetailsPage.tsx"
click node_mdx_content "https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/components/MdxContent.tsx"
click node_commerce_api "https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/app/api/store/%5Bslug%5D/checkout/route.ts"
click node_nuru_app "https://github.com/spiritbulb/mcloud/blob/main/apps/nuru/app/files/page.tsx"
click node_nuru_files "https://github.com/spiritbulb/mcloud/blob/main/apps/nuru/app/api/files/route.ts"
click node_note_ingest "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/notes/route.ts"
click node_note_embedding "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/notes/_ingest/embed.ts"
click node_mobile_chat "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/route.ts"
click node_chat_loop "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/_chat/loop.ts"
click node_chat_adapters "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/_chat/adapters.ts"
click node_chat_anthropic "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/_chat/complete.anthropic.ts"
click node_chat_azure "https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/_chat/complete.azure.ts"
click node_database "https://github.com/spiritbulb/mcloud/blob/main/packages/db/src/server.ts"
click node_database_types "https://github.com/spiritbulb/mcloud/blob/main/packages/db/src/database.types.ts"
click node_server_api "https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/app.ts"
click node_server_create "https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/create.ts"
click node_lxd_client "https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/lxd.ts"
click node_server_mapping "https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/map.ts"

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_platform,node_onboarding,node_org_management,node_identity_handoff,node_mobile_api,node_mobile_user toneBlue
class node_store_management,node_merchant_stores,node_storefront,node_theme_engine,node_theme_manifest,node_service_detail,node_mdx_content,node_commerce_api,node_payment_provider toneAmber
class node_nuru_app,node_nuru_files,node_note_ingest,node_note_embedding,node_mobile_chat,node_chat_loop,node_chat_adapters,node_chat_anthropic,node_chat_azure toneMint
class node_database,node_database_types toneRose
class node_server_api,node_server_create,node_lxd_client,node_server_mapping,node_merchant,node_shopper,node_lxd_service toneIndigo
```

## Components

### Platform and identity

- [Platform hub](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/(marketing)/home/page.tsx): `apps/web/app/(marketing)/home/page.tsx`
- [Organization onboarding](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/(merchant)/org/onboarding/page.tsx): `apps/web/app/(merchant)/org/onboarding/page.tsx`
- [Organization management](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/(merchant)/org/%5BorgSlug%5D/(org)/page.tsx): `apps/web/app/(merchant)/org/[orgSlug]/(org)/page.tsx`
- [Authentication handoff](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/_handoff/tickets.ts): `apps/web/app/api/_handoff/tickets.ts`
- [Mobile API](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/_lib.ts): `apps/web/app/api/mobile/_lib.ts`

### Storefront commerce

- [Store management](https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/app/(merchant)/org/%5BorgSlug%5D/%5BstoreSlug%5D/settings/page.tsx): `apps/storefront/app/(merchant)/org/[orgSlug]/[storeSlug]/settings/page.tsx`
- [Store access logic](https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/lib/merchant/stores.ts): `apps/storefront/lib/merchant/stores.ts`
- [Public storefront](https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/app/(storefront)/store/%5Bslug%5D/page.tsx): `apps/storefront/app/(storefront)/store/[slug]/page.tsx`
- [Theme rendering](https://github.com/spiritbulb/mcloud/blob/main/packages/liquid/src/engine.ts): `packages/liquid/src/engine.ts`
- [Bundled themes](https://github.com/spiritbulb/mcloud/blob/main/packages/liquid/src/themes-manifest.ts): `packages/liquid/src/themes-manifest.ts`
- [Service detail theme](https://github.com/spiritbulb/mcloud/blob/main/packages/themes/src/classic/ServiceDetailsPage.tsx): `packages/themes/src/classic/ServiceDetailsPage.tsx`
- [Rich content renderer](https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/components/MdxContent.tsx): `apps/storefront/components/MdxContent.tsx`
- [Store and checkout APIs](https://github.com/spiritbulb/mcloud/blob/main/apps/storefront/app/api/store/%5Bslug%5D/checkout/route.ts): `apps/storefront/app/api/store/[slug]/checkout/route.ts`
- **Payment providers**

### Nuru learning

- [Nuru study app](https://github.com/spiritbulb/mcloud/blob/main/apps/nuru/app/files/page.tsx): `apps/nuru/app/files/page.tsx`
- [Study file workflows](https://github.com/spiritbulb/mcloud/blob/main/apps/nuru/app/api/files/route.ts): `apps/nuru/app/api/files/route.ts`
- [Note ingestion](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/notes/route.ts): `apps/web/app/api/mobile/notes/route.ts`
- [Note embeddings](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/notes/_ingest/embed.ts): `apps/web/app/api/mobile/notes/_ingest/embed.ts`
- [Notes-aware chat](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/route.ts): `apps/web/app/api/mobile/chat/route.ts`
- [Chat orchestration](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/_chat/loop.ts): `apps/web/app/api/mobile/chat/_chat/loop.ts`
- [Model adapters](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/_chat/adapters.ts): `apps/web/app/api/mobile/chat/_chat/adapters.ts`
- [Anthropic completion](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/_chat/complete.anthropic.ts): `apps/web/app/api/mobile/chat/_chat/complete.anthropic.ts`
- [Azure completion](https://github.com/spiritbulb/mcloud/blob/main/apps/web/app/api/mobile/chat/_chat/complete.azure.ts): `apps/web/app/api/mobile/chat/_chat/complete.azure.ts`

### Shared services

- [Supabase data layer](https://github.com/spiritbulb/mcloud/blob/main/packages/db/src/server.ts): `packages/db/src/server.ts`
- [Database schema types](https://github.com/spiritbulb/mcloud/blob/main/packages/db/src/database.types.ts): `packages/db/src/database.types.ts`

### Server provisioning

- [Provisioning API](https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/app.ts): `tools/reverb-upcloud/src/app.ts`
- [Create validation](https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/create.ts): `tools/reverb-upcloud/src/create.ts`
- [LXD operations](https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/lxd.ts): `tools/reverb-upcloud/src/lxd.ts`
- [Server state mapping](https://github.com/spiritbulb/mcloud/blob/main/tools/reverb-upcloud/src/map.ts): `tools/reverb-upcloud/src/map.ts`

### Other components

- **Merchant**
- **Shopper**
- **Mobile user**
- **LXD service**

## Connections

- Merchant → Platform hub: uses platform (evidence: `README.md`)
- Platform hub → Organization onboarding: starts setup (evidence: `README.md`)
- Merchant → Organization management: manages organization (evidence: `README.md`)
- Platform hub → Authentication handoff: supports sign-in
- Mobile user → Mobile API: calls mobile APIs (evidence: `README.md`)
- Merchant → Store management: configures store (evidence: `README.md`)
- Store management → Store access logic: uses access logic
- Shopper → Public storefront: browses store (evidence: `README.md`)
- Public storefront → Theme rendering: renders themes
- Theme rendering → Bundled themes: reads templates (evidence: `packages/liquid/src/engine.ts`)
- Public storefront → Service detail theme: renders service page
- Service detail theme → Rich content renderer: renders content (evidence: `packages/themes/src/classic/ServiceDetailsPage.tsx`)
- Shopper → Store and checkout APIs: places orders (evidence: `README.md`)
- Store and checkout APIs → Payment providers: initiates payments (evidence: `README.md`)
- Mobile user → Nuru study app: studies materials
- Nuru study app → Study file workflows: manages files
- Mobile user → Note ingestion: submits notes (evidence: `apps/web/app/api/mobile/notes/route.ts`)
- Note ingestion → Note embeddings: embeds chunks (evidence: `apps/web/app/api/mobile/notes/route.ts`)
- Mobile user → Notes-aware chat: chats about notes (evidence: `apps/web/app/api/mobile/chat/route.ts`)
- Notes-aware chat → Chat orchestration: runs chat (evidence: `apps/web/app/api/mobile/chat/route.ts`)
- Notes-aware chat → Model adapters: selects adapter (evidence: `apps/web/app/api/mobile/chat/route.ts`)
- Model adapters → Anthropic completion: dispatches completion (evidence: `apps/web/app/api/mobile/chat/_chat/adapters.ts`)
- Model adapters → Azure completion: dispatches completion (evidence: `apps/web/app/api/mobile/chat/_chat/adapters.ts`)
- Supabase data layer → Database schema types: types queries (evidence: `packages/db/src/server.ts`)
- Provisioning API → Create validation: validates creation (evidence: `tools/reverb-upcloud/src/app.ts`)
- Provisioning API → LXD operations: manages instances (evidence: `tools/reverb-upcloud/src/app.ts`)
- Provisioning API → Server state mapping: maps server state (evidence: `tools/reverb-upcloud/src/app.ts`)
- LXD operations → LXD service: calls hypervisor
