How gautampartha/smart-sanskriti- works
Purpose and Entry Points
Sanskriti is a Next.js heritage-exploration application combining monument discovery, AI assistance, recognition, audio guides, quizzes, gamification, and itinerary planning. The App Router entry is app/page.tsx; global layout and styling begin at app/layout.tsx and app/globals.css. Major user flows are exposed as route pages under app/, including app/explore/page.tsx, app/recognition/page.tsx, and app/dashboard/page.tsx.
Application Shell and Navigation
Shared client UI is organized around reusable shells, navigation, theming, and responsive/mobile presentation. components/app-shell.tsx, components/app-wrapper.tsx, and components/top-nav.tsx establish the main application frame; components/mobile/bottom-nav.tsx provides a mobile-specific navigation boundary. components/auth-guard.tsx protects authenticated experiences.
Heritage Content and Monument Experience
Monument data is handled locally through lib/monuments.ts and lib/monumentStore.ts, then rendered in discovery and detail routes such as app/explore/page.tsx and app/monument/[id]/page.tsx. Recognition-result UI includes monument detail tabs, panorama presentation, and upload handling in components/recognition/monument-detail-tabs.tsx, components/recognition/panorama-viewer.tsx, and components/recognition/upload-zone.tsx. Static audio and time-travel assets are served from public/audio/ and public/time_travel/.
AI Server Boundary
Browser-facing AI features call Next.js server routes, keeping NVIDIA credentials server-side. app/api/chat/route.ts proxies heritage chat, while app/api/recognize/route.ts handles monument image recognition and app/api/transcribe/route.ts handles speech transcription. NVIDIA integration is centralized in lib/nvidia.ts; NVIDIA NIM models and NVIDIA_API_KEY are environment-provided. The related client pages are app/chat/page.tsx, app/recognize/page.tsx, and app/scan/page.tsx.
Personalized Planning and Learning
Itinerary generation is exposed through app/api/itinerary/route.ts and consumed by app/itinerary/page.tsx; planning/domain logic resides in lib/itinerary.ts. Quiz requests flow through app/api/quiz/route.ts, with question content in lib/quizQuestions.ts and presentation in app/quiz/page.tsx. These features feed the broader engagement surface, including app/achievements/page.tsx, app/badges/page.tsx, and app/leaderboard/page.tsx.
Identity, Persistence, and Progression
Authentication and user state are separated into client/context layers: lib/authClient.ts, lib/authContext.tsx, and hooks/useAuth.ts. Supabase is the apparent backend persistence/auth provider, initialized through lib/supabase.ts and lib/supabase/client.ts; XP schema is defined in supabase/migrations/0001_xp_system.sql. Progression logic is represented by lib/xp.ts, while local/offline profile behavior is supported by lib/localProfile.ts.
Runtime and Deployment
This is a TypeScript Next.js runtime configured by next.config.ts, with Tailwind styling configured in tailwind.config.ts. It is deployable to Vercel via vercel.json; deployment must supply NVIDIA environment variables and, where enabled, Supabase credentials. components/BackendPrewarmer.tsx suggests proactive warming of backend/API availability from the client shell.
Components 20
App UI
- Next.js App Router
app/page.tsx - Application shell · Frame, navigation, responsive presentation, and backend warming.
components/app-shell.tsx - Mobile navigation
components/mobile/bottom-nav.tsx - Auth guard
components/auth-guard.tsx
Heritage experience
- Explore & monument detail
app/explore/page.tsx - Monument catalog & store
lib/monuments.ts - Recognition presentation · Detail tabs, panorama, and image upload surface.
components/recognition/monument-detail-tabs.tsx - Audio & time-travel media
AI boundary
Server routes keep NVIDIA credentials off the client.
- Heritage chat
app/chat/page.tsx - Recognition & scan
app/recognize/page.tsx - Chat, recognize & transcribe APIs
app/api/chat/route.ts - NVIDIA NIM · Accessed with server-side NVIDIA_API_KEY.
lib/nvidia.ts
Planning & learning
- Itinerary planner
app/itinerary/page.tsx - Itinerary API & domain
app/api/itinerary/route.ts - Quiz experience
app/quiz/page.tsx - Quiz API & questions
app/api/quiz/route.ts - Achievements, badges & leaderboard
app/achievements/page.tsx
Identity & progress
- Client auth state
lib/authContext.tsx - Supabase auth & persistence · Stores authenticated user state and progression data.
lib/supabase.ts - XP & local profile
lib/xp.ts
Connections 19
- Next.js App Router → Application shell: renders
- Application shell → Mobile navigation: adapts for mobile
- Application shell → Auth guard: wraps protected UI
- Application shell → Client auth state: reads session
- Explore & monument detail → Monument catalog & store: reads monuments
- Recognition presentation → Monument catalog & store: shows identified monument
- Recognition presentation → Audio & time-travel media: presents media
- Recognition & scan → Recognition presentation: renders results
- Heritage chat → Chat, recognize & transcribe APIs: chat request
- Recognition & scan → Chat, recognize & transcribe APIs: image / speech request
- Chat, recognize & transcribe APIs → NVIDIA NIM: proxies inference
- Itinerary planner → Itinerary API & domain: generates plan
- Itinerary API & domain → Monument catalog & store: uses destination data
- Quiz experience → Quiz API & questions: requests questions
- Quiz API & questions → XP & local profile: awards XP
- Achievements, badges & leaderboard → XP & local profile: displays progress
- Auth guard → Client auth state: checks identity
- Client auth state → Supabase auth & persistence: authenticates
- XP & local profile → Supabase auth & persistence: persists XP