# hmohamed080/aladdin architecture

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

- Interactive diagram: https://gitdiagram.com/hmohamed080/aladdin
- Repository: https://github.com/hmohamed080/aladdin

## Overview

Aladdin is described as an AI-first operating system for Egypt’s construction and finishing sector, with B2C, B2B, and admin surfaces. Its intended journey runs from need and advice through discovery, trusted matching, RFQ, quotation, decision, execution, and follow-up. The README says these product features remain scaffolded, so the domain map represents intended capabilities, not verified implemented flows. The runtime foundation is a Next.js app, Supabase, and a specialized FastAPI AI/document service, with Cloudflare Workers for hosting and selected media and OTP functions. Several domain links below are documented product flow rather than inspected calls.

Main entry points: [`frontend/src/app`](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app) (Next.js web app), [`backend/app/main.py`](https://github.com/hmohamed080/aladdin/blob/main/backend/app/main.py) (FastAPI service), [`edge/whatsapp-otp-worker/src/index.ts`](https://github.com/hmohamed080/aladdin/blob/main/edge/whatsapp-otp-worker/src/index.ts) (WhatsApp OTP Worker), [`frontend/src/app/home`](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/home) (Need discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product["Product surfaces"]
  node_people(("B2C B2B Admin"))
end

subgraph group_journey["Value journey"]
  node_discovery["Need discovery"]
  node_advice["AI advice"]
  node_catalog["Catalog discovery"]
  node_matching["Trusted match"]
  node_rfq["RFQ<br/>[rfq-form.tsx]"]
  node_quotes["Quotations"]
  node_decision["Sales decision"]
  node_execution["Project execution"]
  node_followup["Follow-up"]
end

subgraph group_platform["Application platform"]
  node_web["Next.js web app"]
  node_supabase[("Supabase data platform")]
  node_cloudflare["Frontend Worker<br/>[worker.ts]"]
end

subgraph group_edge["Edge services"]
  node_media["Media Worker<br/>[handler.ts]"]
  node_bucket[("Media bucket")]
  node_otp["WhatsApp OTP Worker<br/>[index.ts]"]
  node_d1[("OTP D1 state")]
  node_meta["Meta WhatsApp API"]
end

subgraph group_specialized["AI document service"]
  node_fastapi["FastAPI service<br/>[main.py]"]
  node_retrieval["AI OCR RAG"]
  node_documents["Documents embeddings"]
end

node_people -->|"use surfaces"| node_web
node_web -->|"start journey"| node_discovery
node_discovery -->|"seek advice"| node_advice
node_advice -->|"discover options"| node_catalog
node_catalog -->|"find match"| node_matching
node_matching -->|"request quote"| node_rfq
node_rfq -->|"receive quote"| node_quotes
node_quotes -->|"decide"| node_decision
node_decision -->|"proceed to work"| node_execution
node_execution -->|"follow up"| node_followup
node_web -->|"uses data platform"| node_supabase
node_web -->|"hosted by"| node_cloudflare
node_cloudflare -->|"proxies backend"| node_fastapi
node_fastapi -->|"provides service scope"| node_retrieval
node_fastapi -->|"provides service scope"| node_documents
node_media -->|"reads media objects"| node_bucket
node_otp -->|"uses settings state"| node_d1
node_otp -->|"sends OTP"| node_meta

click node_web "https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app"
click node_discovery "https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/home"
click node_advice "https://github.com/hmohamed080/aladdin/tree/main/backend/app/ai"
click node_catalog "https://github.com/hmohamed080/aladdin/tree/main/frontend/src/features/commerce"
click node_matching "https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/(workspace)/showroom"
click node_rfq "https://github.com/hmohamed080/aladdin/blob/main/frontend/src/features/commerce/rfq-form.tsx"
click node_quotes "https://github.com/hmohamed080/aladdin/blob/main/frontend/src/features/commerce/quotation-detail.tsx"
click node_decision "https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/(workspace)/b2b"
click node_execution "https://github.com/hmohamed080/aladdin/tree/main/frontend/src/features/execution"
click node_followup "https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/(workspace)/b2b/follow-ups"
click node_cloudflare "https://github.com/hmohamed080/aladdin/blob/main/frontend/cloudflare/worker.ts"
click node_fastapi "https://github.com/hmohamed080/aladdin/blob/main/backend/app/main.py"
click node_retrieval "https://github.com/hmohamed080/aladdin/tree/main/backend/app/retrieval"
click node_documents "https://github.com/hmohamed080/aladdin/tree/main/backend/app/documents"
click node_media "https://github.com/hmohamed080/aladdin/blob/main/edge/media-worker/src/handler.ts"
click node_otp "https://github.com/hmohamed080/aladdin/blob/main/edge/whatsapp-otp-worker/src/index.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_people toneBlue
class node_discovery,node_advice,node_catalog,node_matching,node_rfq,node_quotes,node_decision,node_execution,node_followup toneAmber
class node_web,node_supabase,node_cloudflare toneMint
class node_media,node_bucket,node_otp,node_d1,node_meta toneRose
class node_fastapi,node_retrieval,node_documents toneIndigo
```

## Components

### Product surfaces

- **B2C B2B Admin**

### Value journey

- [Need discovery](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/home): `frontend/src/app/home`
- [AI advice](https://github.com/hmohamed080/aladdin/tree/main/backend/app/ai): `backend/app/ai`
- [Catalog discovery](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/features/commerce): `frontend/src/features/commerce`
- [Trusted match](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/(workspace)/showroom): `frontend/src/app/(workspace)/showroom`
- [RFQ](https://github.com/hmohamed080/aladdin/blob/main/frontend/src/features/commerce/rfq-form.tsx): `frontend/src/features/commerce/rfq-form.tsx`
- [Quotations](https://github.com/hmohamed080/aladdin/blob/main/frontend/src/features/commerce/quotation-detail.tsx): `frontend/src/features/commerce/quotation-detail.tsx`
- [Sales decision](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/(workspace)/b2b): `frontend/src/app/(workspace)/b2b`
- [Project execution](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/features/execution): `frontend/src/features/execution`
- [Follow-up](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app/(workspace)/b2b/follow-ups): `frontend/src/app/(workspace)/b2b/follow-ups`

### Application platform

- [Next.js web app](https://github.com/hmohamed080/aladdin/tree/main/frontend/src/app): `frontend/src/app`
- **Supabase data platform**
- [Frontend Worker](https://github.com/hmohamed080/aladdin/blob/main/frontend/cloudflare/worker.ts): `frontend/cloudflare/worker.ts`

### Edge services

- [Media Worker](https://github.com/hmohamed080/aladdin/blob/main/edge/media-worker/src/handler.ts): `edge/media-worker/src/handler.ts`
- **Media bucket**
- [WhatsApp OTP Worker](https://github.com/hmohamed080/aladdin/blob/main/edge/whatsapp-otp-worker/src/index.ts): `edge/whatsapp-otp-worker/src/index.ts`
- **OTP D1 state**
- **Meta WhatsApp API**

### AI document service

- [FastAPI service](https://github.com/hmohamed080/aladdin/blob/main/backend/app/main.py): `backend/app/main.py`
- [AI OCR RAG](https://github.com/hmohamed080/aladdin/tree/main/backend/app/retrieval): `backend/app/retrieval`
- [Documents embeddings](https://github.com/hmohamed080/aladdin/tree/main/backend/app/documents): `backend/app/documents`

## Connections

- B2C B2B Admin → Next.js web app: use surfaces (evidence: `README.md`)
- Next.js web app → Need discovery: start journey (evidence: `README.md`)
- Need discovery → AI advice: seek advice (evidence: `README.md`)
- AI advice → Catalog discovery: discover options (evidence: `README.md`)
- Catalog discovery → Trusted match: find match (evidence: `README.md`)
- Trusted match → RFQ: request quote (evidence: `README.md`)
- RFQ → Quotations: receive quote (evidence: `README.md`)
- Quotations → Sales decision: decide (evidence: `README.md`)
- Sales decision → Project execution: proceed to work (evidence: `README.md`)
- Project execution → Follow-up: follow up (evidence: `README.md`)
- Next.js web app → Supabase data platform: uses data platform (evidence: `README.md`)
- Next.js web app → Frontend Worker: hosted by (evidence: `README.md`)
- Frontend Worker → FastAPI service: proxies backend (evidence: `frontend/cloudflare/worker.ts`)
- FastAPI service → AI OCR RAG: provides service scope (evidence: `README.md`)
- FastAPI service → Documents embeddings: provides service scope (evidence: `README.md`)
- Media Worker → Media bucket: reads media objects (evidence: `edge/media-worker/src/handler.ts`)
- WhatsApp OTP Worker → OTP D1 state: uses settings state (evidence: `edge/whatsapp-otp-worker/src/index.ts`)
- WhatsApp OTP Worker → Meta WhatsApp API: sends OTP (evidence: `edge/whatsapp-otp-worker/src/index.ts`)
