How harshagw/kahani works
Kahani World turns a player’s scene description into an AI-generated, explorable adventure: sign in, create a story bible, generate a connected world and character, explore and talk with clue-bearing NPCs, then reach a generated ending. The README identifies World as the client orchestrator for parallel scene prefetch, clues, finale, and persistence; sampled routes confirm the generation calls and server-side game listing/creation. Some client and storage wiring is documented but not present in the sampled source, so the graph omits uncertain call details.
Main entry points: World.tsx World orchestrator · world-engine.ts World engine · auth.ts Session validation · route.ts Overworld scenes
Components 23
Player experience
- World gallery
components/Home.tsx - Sign-in
app/login/page.tsx - World orchestrator
components/World.tsx - Movement and map
components/GameCanvas.tsx - NPC conversations
components/DialogueBox.tsx
World generation
- Story bible
app/api/universe/route.ts - Overworld scenes
app/api/screen/route.ts - Interior scenes
app/api/scene/route.ts - Player sprite
app/api/sprite/route.ts - Dialogue generation
app/api/dialogue/route.ts - Voice generation
app/api/voice/route.ts - Finale generation
app/api/finale/route.ts - World engine
lib/world-engine.ts
Identity and persistence
- Session validation
lib/supabase/auth.ts - Supabase clients
lib/supabase/server.ts - Game persistence helpers
lib/games.ts
Application API
- Saved worlds API
app/api/games/route.ts - Auth callback
app/auth/callback/route.ts - Profile API
app/api/profile/route.ts
Other components
- Player
- Text and image generation
- Speech synthesis
- Supabase database and storage
Connections 40
- Player → Sign-in: signs in
- Sign-in → Auth callback: completes sign-in
- Player → World gallery: describes world
- World gallery → Story bible: requests bible
- Story bible → Session validation: checks session
- Story bible → World engine: generates bible
- World engine → Text and image generation: generates text and images
- World gallery → Saved worlds API: creates or lists worlds
- Saved worlds API → Session validation: checks session
- Saved worlds API → Supabase clients: creates client
- Saved worlds API → Game persistence helpers: checks quota and formats
- Game persistence helpers → Supabase database and storage: reads and writes game assets
- Supabase clients → Supabase database and storage: accesses database
- Player → World orchestrator: plays saved world
- World orchestrator → Overworld scenes: requests scenes
- World orchestrator → Interior scenes: prefetches rooms
- World orchestrator → Player sprite: requests sprite
- World orchestrator → Movement and map: provides playable scene
- Movement and map → World orchestrator: reports exploration
- World orchestrator → NPC conversations: opens NPC conversation
- NPC conversations → Dialogue generation: submits conversation
- Dialogue generation → Session validation: checks session
- Dialogue generation → World engine: generates reply
- World orchestrator → Voice generation: requests spoken lines
- Voice generation → Session validation: checks session
- Voice generation → World engine: synthesizes speech
- World engine → Speech synthesis: synthesizes voice
- World orchestrator → Finale generation: requests ending
- Finale generation → Session validation: checks session
- Finale generation → World engine: generates finale
- Overworld scenes → Session validation: checks session
- Overworld scenes → World engine: generates screen
- Overworld scenes → Game persistence helpers: fetches saved frame
- Interior scenes → Session validation: checks session
- Interior scenes → World engine: generates interior
- Player sprite → Session validation: checks session
- Player sprite → World engine: generates sprite
- Player sprite → Game persistence helpers: fetches reference frame
- Auth callback → Supabase clients: exchanges session
- Profile API → Session validation: checks session