# vandanmittal28/smart-sanskriti architecture

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

- Interactive diagram: https://gitdiagram.com/vandanmittal28/smart-sanskriti
- Repository: https://github.com/vandanmittal28/smart-sanskriti

## Overview

#### Purpose and deployment shape
Sanskriti AI is a heritage-tourism experience delivered primarily as a Next.js web application, with an Android WebView shell for mobile distribution. The web app supplies interactive monument discovery, AI-assisted recognition and chat, itineraries, quizzes, translations, narration, profiles, and gamification. The Android app loads a deployed or emulator-accessible web URL rather than duplicating product logic.

Paths: `web-ui/app/page.tsx`, `apk/app/src/main/java/ai/sanskriti/app/MainActivity.java`, `apk/README.md`.

#### Web application entry and composition
The Next.js App Router application enters through the root layout and home page. Shared application framing, navigation, theme, language, authentication, and backend warm-up are composed through wrapper/shell components. Feature pages are route-local client/server UI boundaries under `app/`.

Paths: `web-ui/app/layout.tsx`, `web-ui/components/app-wrapper.tsx`, `web-ui/components/app-shell.tsx`.

#### Experience modules
Primary user journeys are independently routed: exploration and monument detail; image recognition/scan; conversational assistance; trip itinerary generation; quizzes and treasure hunts; tickets, festivals, sustainability, and achievement views. Monument content and some user-facing state are locally modeled, allowing screens to work alongside remote AI and persistence services.

Paths: `web-ui/app/explore/page.tsx`, `web-ui/app/monument/[id]/page.tsx`, `web-ui/app/recognition/page.tsx`.

#### Server-side AI capability boundary
Next.js route handlers expose backend endpoints for chat, landmark recognition, audio transcription/narration, itinerary and quiz generation, and translation. Browser UI should call these routes rather than directly owning provider integration; `apiClient` is the likely client-side request abstraction. NVIDIA integration is isolated in a library module, while a separate local Python Chatterbox service supports local AI/audio capability.

Paths: `web-ui/app/api/chat/route.ts`, `web-ui/app/api/recognize/route.ts`, `web-ui/lib/nvidia.ts`, `web-ui/local-ai/chatterbox/server.py`.

#### Identity, profiles, and persistence
Supabase is the durable backend boundary for authentication, profiles, multilingual preferences, XP, badges, and realtime-facing leaderboard/profile data. Client/auth contexts distribute identity and user state through the React tree; route/page guards enforce protected UI access. SQL migrations define the database-side evolution.

Paths: `web-ui/lib/supabase/client.ts`, `web-ui/lib/authContext.tsx`, `web-ui/components/auth-guard.tsx`, `web-ui/supabase/migrations/0001_xp_system.sql`.

#### Content, media, and localization flow
Static monument datasets, ticket data, quiz questions, and audio assets provide baseline content. Language context and language metadata coordinate localized UI/content selection. Audio guides can resolve to bundled MP3 files, while narration APIs provide generated alternatives; time-travel visual assets are served directly from the Next.js public directory.

Paths: `web-ui/lib/monuments.ts`, `web-ui/lib/languageContext.tsx`, `web-ui/hooks/useAudioGuide.ts`, `web-ui/public/audio/`.

#### Android wrapper runtime
The Android Gradle project has one native activity and manifest-configured WebView runtime. It targets the hosted web product by default, with an environment-configurable URL for local emulator development. Network security configuration is a material boundary for HTTP/local endpoint access.

Paths: `apk/app/src/main/java/ai/sanskriti/app/MainActivity.java`, `apk/app/src/main/AndroidManifest.xml`, `apk/app/src/main/res/xml/network_security_config.xml`.

Main entry points: [`web-ui/components/app-shell.tsx`](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/components/app-shell.tsx) (App shell), [`web-ui/components/app-wrapper.tsx`](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/components/app-wrapper.tsx) (App wrappers), [`web-ui/app/explore/page.tsx`](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/explore/page.tsx) (Explore & monument), [`web-ui/app/api/chat/route.ts`](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/api/chat/route.ts) (Chat API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js Web App"]
  node_layout["Root layout<br/>App Router entry<br/>[layout.tsx]"]
  node_wrappers["App wrappers<br/>React composition<br/>[app-wrapper.tsx]"]
  node_shell["App shell<br/>Shared UI<br/>[app-shell.tsx]"]
  node_home["Home page<br/>Route UI<br/>[page.tsx]"]
  node_explore["Explore &amp; monument<br/>Route UI<br/>[page.tsx]"]
  node_recognition["Recognition scan<br/>Route UI<br/>[page.tsx]"]
  node_feature_routes["Other experience routes<br/>Route UI"]
  node_auth_guard["Auth guard<br/>Access control<br/>[auth-guard.tsx]"]
end

subgraph group_ai["AI Services"]
  node_chat_api{{"Chat API<br/>Route handler<br/>[route.ts]"}}
  node_recognize_api{{"Recognition API<br/>Route handler<br/>[route.ts]"}}
  node_nvidia["NVIDIA integration<br/>AI provider adapter<br/>[nvidia.ts]"]
  node_chatterbox{{"Chatterbox service<br/>Local Python AI/audio service<br/>[server.py]"}}
end

subgraph group_data["Identity &amp; Data"]
  node_auth_context["Auth context<br/>React user state<br/>[authContext.tsx]"]
  node_supabase[("Supabase<br/>Auth, realtime &amp; persistence<br/>[client.ts]")]
  node_xp_schema["XP schema migration<br/>Database migration<br/>[0001_xp_system.sql]"]
  node_content["Monument content<br/>Local dataset<br/>[monuments.ts]"]
  node_localization["Language context<br/>Localization state"]
  node_audio["Audio guides<br/>Media hook &amp; assets<br/>[useAudioGuide.ts]"]
end

subgraph group_mobile["Android Shell"]
  node_android_activity["WebView activity<br/>Android entrypoint<br/>[MainActivity.java]"]
  node_android_manifest["Android WebView config<br/>Manifest &amp; network policy"]
end

node_layout -->|"composes"| node_wrappers
node_wrappers -->|"provides"| node_shell
node_shell -->|"frames"| node_home
node_shell -->|"frames"| node_explore
node_shell -->|"frames"| node_recognition
node_shell -->|"frames"| node_feature_routes
node_wrappers -->|"distributes"| node_auth_context
node_auth_guard -->|"checks"| node_auth_context
node_auth_context -->|"auth and profile access"| node_supabase
node_xp_schema -->|"evolves"| node_supabase
node_explore -->|"reads"| node_content
node_wrappers -->|"provides"| node_localization
node_explore -->|"plays guides"| node_audio
node_recognition -->|"scan request"| node_recognize_api
node_feature_routes -->|"AI requests"| node_chat_api
node_chat_api -->|"provider calls"| node_nvidia
node_recognize_api -->|"provider calls"| node_nvidia
node_chat_api -.->|"local AI/audio option"| node_chatterbox
node_android_activity -->|"configured by"| node_android_manifest
node_android_activity -->|"loads web URL"| node_home

click node_layout "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/layout.tsx"
click node_wrappers "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/components/app-wrapper.tsx"
click node_shell "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/components/app-shell.tsx"
click node_home "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/page.tsx"
click node_explore "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/explore/page.tsx"
click node_recognition "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/recognition/page.tsx"
click node_auth_guard "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/components/auth-guard.tsx"
click node_chat_api "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/api/chat/route.ts"
click node_recognize_api "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/api/recognize/route.ts"
click node_nvidia "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/nvidia.ts"
click node_chatterbox "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/local-ai/chatterbox/server.py"
click node_auth_context "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/authContext.tsx"
click node_supabase "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/supabase/client.ts"
click node_xp_schema "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/supabase/migrations/0001_xp_system.sql"
click node_content "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/monuments.ts"
click node_localization "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/languageContext.tsx"
click node_audio "https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/hooks/useAudioGuide.ts"
click node_android_activity "https://github.com/vandanmittal28/smart-sanskriti/blob/main/apk/app/src/main/java/ai/sanskriti/app/MainActivity.java"
click node_android_manifest "https://github.com/vandanmittal28/smart-sanskriti/blob/main/apk/app/src/main/AndroidManifest.xml"

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_layout,node_wrappers,node_shell,node_home,node_explore,node_recognition,node_feature_routes,node_auth_guard toneBlue
class node_chat_api,node_recognize_api,node_nvidia,node_chatterbox toneAmber
class node_auth_context,node_supabase,node_xp_schema,node_content,node_localization,node_audio toneMint
class node_android_activity,node_android_manifest toneRose
```

## Components

### Next.js Web App

Primary product runtime.

- [Root layout](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/layout.tsx): App Router entry · `web-ui/app/layout.tsx`
- [App wrappers](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/components/app-wrapper.tsx): React composition · Provides theme, language, auth, and backend warm-up. · `web-ui/components/app-wrapper.tsx`
- [App shell](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/components/app-shell.tsx): Shared UI · Shared framing and navigation. · `web-ui/components/app-shell.tsx`
- [Home page](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/page.tsx): Route UI · `web-ui/app/page.tsx`
- [Explore & monument](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/explore/page.tsx): Route UI · Discovery and monument-detail journey. · `web-ui/app/explore/page.tsx`
- [Recognition scan](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/recognition/page.tsx): Route UI · `web-ui/app/recognition/page.tsx`
- **Other experience routes**: Route UI · Chat, itineraries, quizzes, tickets, festivals, and achievements.
- [Auth guard](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/components/auth-guard.tsx): Access control · Protects authenticated UI routes. · `web-ui/components/auth-guard.tsx`

### AI Services

Server-side AI capability boundary.

- [Chat API](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/api/chat/route.ts): Route handler · `web-ui/app/api/chat/route.ts`
- [Recognition API](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/app/api/recognize/route.ts): Route handler · `web-ui/app/api/recognize/route.ts`
- [NVIDIA integration](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/nvidia.ts): AI provider adapter · `web-ui/lib/nvidia.ts`
- [Chatterbox service](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/local-ai/chatterbox/server.py): Local Python AI/audio service · `web-ui/local-ai/chatterbox/server.py`

### Identity & Data

Durable user state and content.

- [Auth context](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/authContext.tsx): React user state · Distributes identity and profile state. · `web-ui/lib/authContext.tsx`
- [Supabase](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/supabase/client.ts): Auth, realtime & persistence · Stores profiles, preferences, XP, badges, and leaderboard data. · `web-ui/lib/supabase/client.ts`
- [XP schema migration](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/supabase/migrations/0001_xp_system.sql): Database migration · `web-ui/supabase/migrations/0001_xp_system.sql`
- [Monument content](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/monuments.ts): Local dataset · Baseline monument, ticket, and quiz content. · `web-ui/lib/monuments.ts`
- [Language context](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/lib/languageContext.tsx): Localization state · `web-ui/lib/languageContext.tsx`
- [Audio guides](https://github.com/vandanmittal28/smart-sanskriti/blob/main/web-ui/hooks/useAudioGuide.ts): Media hook & assets · Uses bundled audio and generated narration alternatives. · `web-ui/hooks/useAudioGuide.ts`

### Android Shell

WebView distribution runtime.

- [WebView activity](https://github.com/vandanmittal28/smart-sanskriti/blob/main/apk/app/src/main/java/ai/sanskriti/app/MainActivity.java): Android entrypoint · Loads hosted or emulator-accessible web product. · `apk/app/src/main/java/ai/sanskriti/app/MainActivity.java`
- [Android WebView config](https://github.com/vandanmittal28/smart-sanskriti/blob/main/apk/app/src/main/AndroidManifest.xml): Manifest & network policy · Configures runtime and local HTTP access. · `apk/app/src/main/AndroidManifest.xml`

## Connections

- Root layout → App wrappers: composes
- App wrappers → App shell: provides
- App shell → Home page: frames
- App shell → Explore & monument: frames
- App shell → Recognition scan: frames
- App shell → Other experience routes: frames
- App wrappers → Auth context: distributes
- Auth guard → Auth context: checks
- Auth context → Supabase: auth and profile access
- XP schema migration → Supabase: evolves
- Explore & monument → Monument content: reads
- App wrappers → Language context: provides
- Explore & monument → Audio guides: plays guides
- Recognition scan → Recognition API: scan request
- Other experience routes → Chat API: AI requests
- Chat API → NVIDIA integration: provider calls
- Recognition API → NVIDIA integration: provider calls
- Chat API → Chatterbox service: local AI/audio option
- WebView activity → Android WebView config: configured by
- WebView activity → Home page: loads web URL
