How srijitagoswami/mailxp works
MailXP combines a Phaser office game with a Next.js inbox and progression app. The main player journey is to connect Gmail, sync and read messages, optionally request advisory AI analysis, and advance through game, rewards, and shop features. The graph preserves the documented product branches and central runtime modules. Source excerpts are partial; relationships not established by them or the README are omitted rather than inferred.
Main entry points: v1 Versioned API · aiAnalysis.ts AI analysis · worker.ts Job worker · apiClient.ts API client
Components 31
Player experience
- App shell
components/AppShell.tsx - Inbox screen
components/screens/InboxScreen.tsx - Settings screen
components/screens/SettingsScreen.tsx - Shop screen
components/screens/ShopScreen.tsx - API client
components/apiClient.ts
Game runtime
- Phaser canvas
components/PhaserCanvas.tsx - Office scene
game/scenes/OfficeScene.ts - Quest config
game/data/questConfig.ts - Game bridge
game/bridge.ts - Local profile
game/profile.ts - Profile storage
game/profileStorage.ts - Game economy
lib/server/economy.ts
Mail intelligence
- Gmail sync
lib/server/gmailSync.ts - Google OAuth
lib/server/googleOAuth.ts - AI analysis
lib/server/aiAnalysis.ts
API and identity
- Versioned API
app/api/v1 - API contract
game/backend/contract.ts - Sessions
lib/server/session.ts - HTTP helpers
lib/server/http.ts
Server services
- PostgreSQL
lib/server/prisma.ts - Job worker
lib/server/worker.ts - Job queue
lib/server/jobQueue.ts - Event outbox
lib/server/outbox.ts - Audit records
lib/server/audit.ts - Live events
lib/server/sseHub.ts - Rate limits
lib/server/rateLimit.ts - Idempotency
lib/server/idempotency.ts - Structured logger
lib/server/logger.ts
Other components
- Player
- Gmail
- Gemini API
Connections 36
- Player → App shell: uses
README.md - App shell → Inbox screen: opens
README.md - App shell → Phaser canvas: hosts
README.md - Player → Google OAuth: connects account
README.md - Google OAuth → Gmail: authorizes access
README.md - Inbox screen → API client: requests messages
README.md - API client → Versioned API: calls
components/apiClient.ts - Versioned API → API contract: uses shapes
app/api/v1/gmail/messages/route.ts - Versioned API → Sessions: authenticates
app/api/v1/ai/settings/route.ts - Versioned API → HTTP helpers: formats responses
app/api/v1/ai/settings/route.ts - Versioned API → Gmail sync: queues sync
README.md - Gmail sync → Gmail: reads messages
README.md - Player → AI analysis: requests analysis
README.md - AI analysis → Gemini API: analyzes message
lib/server/aiAnalysis.ts - Job worker → Gmail sync: runs sync
lib/server/worker.ts - Job worker → AI analysis: runs analysis
lib/server/worker.ts - Job worker → Job queue: claims and completes
lib/server/worker.ts - Job worker → Event outbox: relays events
lib/server/worker.ts - AI analysis → Job queue: uses
lib/server/aiAnalysis.ts - AI analysis → Game economy: awards progression
lib/server/aiAnalysis.ts - Versioned API → Game economy: handles purchases
app/api/v1/shop/purchases/route.ts - Versioned API → Audit records: records events
app/api/v1/ai/settings/route.ts - Versioned API → Rate limits: checks limits
app/api/v1/ai/settings/route.ts - Versioned API → PostgreSQL: accesses data
app/api/v1/ai/settings/route.ts - Settings screen → API client: calls
components/screens/SettingsScreen.tsx - Shop screen → API client: calls
components/apiClient.ts - Phaser canvas → Office scene: renders
README.md - Office scene → Game bridge: dispatches interactions
game/bridge.ts - Game bridge → Quest config: uses configuration
game/bridge.ts - Local profile → Profile storage: reads and writes
game/profile.ts - Local profile → Quest config: uses configuration
game/profile.ts - Game economy → Audit records: records purchase
lib/server/economy.ts - HTTP helpers → Structured logger: resolves request IDs
lib/server/http.ts - Audit records → Structured logger: redacts metadata
lib/server/audit.ts - Versioned API → Idempotency: guards purchases
app/api/v1/shop/purchases/route.ts - Versioned API → Live events: streams updates
app/api/v1/events/route.ts