# benameuraimad-beep/rikaz-ai- architecture

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

- Interactive diagram: https://gitdiagram.com/benameuraimad-beep/rikaz-ai-
- Repository: https://github.com/benameuraimad-beep/rikaz-ai-

## Overview

Rikaz AI is a bilingual mineral-analysis web app. The main workflow is image selection, analysis, result display, and—when signed in—saving that result for later history. Separate capabilities include account access, a geological map with prediction controls, and a geology chatbot. The excerpts establish the frontend routes and several component calls; backend-function wiring and some page behavior are unsampled, so those links are left unverified rather than inferred as direct calls.

Main entry points: [`src/App.tsx`](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/App.tsx) (App router), [`src/pages/Index.tsx`](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/Index.tsx) (Analysis page), [`src/integrations/supabase/client.ts`](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/integrations/supabase/client.ts) (Supabase client), [`src/hooks/useAuth.tsx`](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/hooks/useAuth.tsx) (Auth context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and workflows"]
  node_app["App router<br/>[App.tsx]"]
  node_analysis["Analysis page<br/>[Index.tsx]"]
  node_authpage["Sign-in page<br/>[Auth.tsx]"]
  node_historypage["Analysis history<br/>[History.tsx]"]
end

subgraph group_domain["Mineral features"]
  node_map["Geological map<br/>[GeologicalMap.tsx]"]
  node_upload["Image uploader<br/>[ImageUploader.tsx]"]
  node_result["Analysis result<br/>[AnalysisResult.tsx]"]
  node_gemini["Mineral analysis<br/>[gemini.ts]"]
  node_historylib["History persistence<br/>[analysisHistory.ts]"]
  node_locations[("Mineral locations")]
  node_minimap["Mini map<br/>[MiniMap.tsx]"]
  node_chatbot["Geology chatbot<br/>[GeoChatbot.tsx]"]
  node_predictfn["Mineral prediction<br/>[index.ts]"]
  node_analyzefn["Analysis function<br/>[index.ts]"]
  node_chatfn["Chat function<br/>[index.ts]"]
end

subgraph group_state["Identity and state"]
  node_auth["Auth context<br/>[useAuth.tsx]"]
  node_language["Language context<br/>[useLanguage.tsx]"]
  node_supabase["Supabase client<br/>[client.ts]"]
end

subgraph group_ui["Shared interface"]
  node_header["Header<br/>[Header.tsx]"]
  node_primitives["UI primitives<br/>[button.tsx]"]
  node_dropdown["Dropdown menu<br/>[dropdown-menu.tsx]"]
  node_input["Input control<br/>[input.tsx]"]
  node_tooltip["Tooltip<br/>[tooltip.tsx]"]
  node_toast["Toast state<br/>[use-toast.ts]"]
  node_toaster["Toast display<br/>[toaster.tsx]"]
end

node_visitor(("Visitor"))
node_supaservice[("Supabase service")]

node_visitor -->|"opens"| node_app
node_app -->|"routes to"| node_analysis
node_app -->|"routes to"| node_authpage
node_app -->|"routes to"| node_historypage
node_app -->|"routes to"| node_map
node_app -->|"renders"| node_chatbot
node_app -->|"provides context"| node_auth
node_app -->|"provides context"| node_language
node_app -->|"renders"| node_toaster
node_analysis -->|"renders"| node_upload
node_analysis -->|"calls"| node_gemini
node_analysis -->|"renders"| node_result
node_analysis -->|"saves result"| node_historylib
node_analysis -->|"renders"| node_minimap
node_analysis -->|"renders"| node_header
node_analysis -->|"reads user"| node_auth
node_analysis -->|"reads translations"| node_language
node_gemini -->|"uses client"| node_supabase
node_historylib -->|"uses client"| node_supabase
node_auth -->|"calls auth"| node_supabase
node_authpage -->|"uses context"| node_auth
node_historypage -->|"uses context"| node_auth
node_historypage -->|"uses client"| node_supabase
node_map -->|"reads locations"| node_locations
node_minimap -->|"reads locations"| node_locations
node_map -->|"uses client"| node_supabase
node_chatbot -->|"uses client"| node_supabase
node_supabase -->|"connects"| node_supaservice
node_map -.->|"may invoke"| node_predictfn
node_gemini -.->|"may invoke"| node_analyzefn
node_chatbot -.->|"may invoke"| node_chatfn
node_header -->|"uses context"| node_auth
node_header -->|"uses translations"| node_language
node_header -->|"uses"| node_dropdown
node_authpage -->|"uses"| node_input
node_analysis -->|"uses notifications"| node_toast
node_toast -.->|"displays state"| node_toaster
node_app -->|"provides"| node_tooltip

click node_app "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/App.tsx"
click node_analysis "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/Index.tsx"
click node_authpage "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/Auth.tsx"
click node_historypage "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/History.tsx"
click node_map "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/GeologicalMap.tsx"
click node_upload "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ImageUploader.tsx"
click node_result "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/AnalysisResult.tsx"
click node_gemini "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/lib/gemini.ts"
click node_historylib "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/lib/analysisHistory.ts"
click node_locations "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/lib/mineralLocations.ts"
click node_minimap "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/MiniMap.tsx"
click node_chatbot "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/GeoChatbot.tsx"
click node_predictfn "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/supabase/functions/predict-minerals/index.ts"
click node_analyzefn "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/supabase/functions/analyze-mineral/index.ts"
click node_chatfn "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/supabase/functions/geo-chat/index.ts"
click node_auth "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/hooks/useAuth.tsx"
click node_language "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/hooks/useLanguage.tsx"
click node_supabase "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/integrations/supabase/client.ts"
click node_header "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/Header.tsx"
click node_primitives "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/button.tsx"
click node_dropdown "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/dropdown-menu.tsx"
click node_input "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/input.tsx"
click node_tooltip "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/tooltip.tsx"
click node_toast "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/hooks/use-toast.ts"
click node_toaster "https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/toaster.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_app,node_analysis,node_authpage,node_historypage toneBlue
class node_map,node_upload,node_result,node_gemini,node_historylib,node_locations,node_minimap,node_chatbot,node_predictfn,node_analyzefn,node_chatfn,node_supaservice toneAmber
class node_auth,node_language,node_supabase toneMint
class node_header,node_primitives,node_dropdown,node_input,node_tooltip,node_toast,node_toaster toneRose
class node_visitor toneIndigo
```

## Components

### App and workflows

- [App router](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/App.tsx): `src/App.tsx`
- [Analysis page](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/Index.tsx): `src/pages/Index.tsx`
- [Sign-in page](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/Auth.tsx): `src/pages/Auth.tsx`
- [Analysis history](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/History.tsx): `src/pages/History.tsx`

### Mineral features

- [Geological map](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/pages/GeologicalMap.tsx): `src/pages/GeologicalMap.tsx`
- [Image uploader](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ImageUploader.tsx): `src/components/ImageUploader.tsx`
- [Analysis result](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/AnalysisResult.tsx): `src/components/AnalysisResult.tsx`
- [Mineral analysis](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/lib/gemini.ts): `src/lib/gemini.ts`
- [History persistence](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/lib/analysisHistory.ts): `src/lib/analysisHistory.ts`
- [Mineral locations](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/lib/mineralLocations.ts): `src/lib/mineralLocations.ts`
- [Mini map](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/MiniMap.tsx): `src/components/MiniMap.tsx`
- [Geology chatbot](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/GeoChatbot.tsx): `src/components/GeoChatbot.tsx`
- [Mineral prediction](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/supabase/functions/predict-minerals/index.ts): `supabase/functions/predict-minerals/index.ts`
- [Analysis function](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/supabase/functions/analyze-mineral/index.ts): `supabase/functions/analyze-mineral/index.ts`
- [Chat function](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/supabase/functions/geo-chat/index.ts): `supabase/functions/geo-chat/index.ts`

### Identity and state

- [Auth context](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/hooks/useAuth.tsx): `src/hooks/useAuth.tsx`
- [Language context](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/hooks/useLanguage.tsx): `src/hooks/useLanguage.tsx`
- [Supabase client](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`

### Shared interface

- [Header](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/Header.tsx): `src/components/Header.tsx`
- [UI primitives](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/button.tsx): `src/components/ui/button.tsx`
- [Dropdown menu](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/dropdown-menu.tsx): `src/components/ui/dropdown-menu.tsx`
- [Input control](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/input.tsx): `src/components/ui/input.tsx`
- [Tooltip](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/tooltip.tsx): `src/components/ui/tooltip.tsx`
- [Toast state](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/hooks/use-toast.ts): `src/hooks/use-toast.ts`
- [Toast display](https://github.com/benameuraimad-beep/rikaz-ai-/blob/main/src/components/ui/toaster.tsx): `src/components/ui/toaster.tsx`

### Other components

- **Visitor**
- **Supabase service**

## Connections

- Visitor → App router: opens (evidence: `src/App.tsx`)
- App router → Analysis page: routes to (evidence: `src/App.tsx`)
- App router → Sign-in page: routes to (evidence: `src/App.tsx`)
- App router → Analysis history: routes to (evidence: `src/App.tsx`)
- App router → Geological map: routes to (evidence: `src/App.tsx`)
- App router → Geology chatbot: renders (evidence: `src/App.tsx`)
- App router → Auth context: provides context (evidence: `src/App.tsx`)
- App router → Language context: provides context (evidence: `src/App.tsx`)
- App router → Toast display: renders (evidence: `src/App.tsx`)
- Analysis page → Image uploader: renders (evidence: `src/pages/Index.tsx`)
- Analysis page → Mineral analysis: calls (evidence: `src/pages/Index.tsx`)
- Analysis page → Analysis result: renders (evidence: `src/pages/Index.tsx`)
- Analysis page → History persistence: saves result (evidence: `src/pages/Index.tsx`)
- Analysis page → Mini map: renders (evidence: `src/pages/Index.tsx`)
- Analysis page → Header: renders (evidence: `src/pages/Index.tsx`)
- Analysis page → Auth context: reads user (evidence: `src/pages/Index.tsx`)
- Analysis page → Language context: reads translations (evidence: `src/pages/Index.tsx`)
- Mineral analysis → Supabase client: uses client (evidence: `src/lib/gemini.ts`)
- History persistence → Supabase client: uses client (evidence: `src/lib/analysisHistory.ts`)
- Auth context → Supabase client: calls auth (evidence: `src/hooks/useAuth.tsx`)
- Sign-in page → Auth context: uses context (evidence: `src/pages/Auth.tsx`)
- Analysis history → Auth context: uses context (evidence: `src/pages/History.tsx`)
- Analysis history → Supabase client: uses client (evidence: `src/pages/History.tsx`)
- Geological map → Mineral locations: reads locations (evidence: `src/pages/GeologicalMap.tsx`)
- Mini map → Mineral locations: reads locations (evidence: `src/components/MiniMap.tsx`)
- Geological map → Supabase client: uses client (evidence: `src/pages/GeologicalMap.tsx`)
- Geology chatbot → Supabase client: uses client (evidence: `src/components/GeoChatbot.tsx`)
- Supabase client → Supabase service: connects (evidence: `src/integrations/supabase/client.ts`)
- Geological map → Mineral prediction: may invoke
- Mineral analysis → Analysis function: may invoke
- Geology chatbot → Chat function: may invoke
- Header → Auth context: uses context (evidence: `src/components/Header.tsx`)
- Header → Language context: uses translations (evidence: `src/components/Header.tsx`)
- Header → Dropdown menu: uses (evidence: `src/components/Header.tsx`)
- Sign-in page → Input control: uses (evidence: `src/pages/Auth.tsx`)
- Analysis page → Toast state: uses notifications (evidence: `src/pages/Index.tsx`)
- Toast state → Toast display: displays state
- App router → Tooltip: provides (evidence: `src/App.tsx`)
