Collaborative Travel Storytelling OS
Routeory
Collaborative travel storytelling operating system and expedition chronicle platform built with NestJS (Fastify), React Native (Expo SDK 56), and PostgreSQL, featuring real-time Socket.io multi-user sync, greedy bipartite debt settlement, GPT-4o narrative synthesis, and cinematic OSRM route replays.
Executive Summary & Core Value Proposition
01Travel memories and logistics are frequently fragmented across disparate applications: WhatsApp chat threads, photo rolls, Splitwise ledgers, Apple Notes, and Google Maps pins. Routeory unifies the entire expedition lifecycle into a single, cohesive operating system:
1. Live Co-Creation: Multiple co-travelers log notes, photos, places, and expenses into a shared chronological timeline synced over WebSockets in real time. 2. Autonomous AI Storytelling: Ingests raw trip coordinates, notes, expenses, and logs to produce high-grade travel editorial narratives powered by OpenAI GPT-4o. 3. Automated Debt Settlement: Calculates exact multi-party expense splits and runs a greedy bipartite ledger reduction algorithm to settle debts with minimum transactions. 4. Cinematic Route Replay: Connects visited waypoints using cached OSRM routing data and renders animated playback over map projections. 5. Instant Export & Social Sharing: Renders high-resolution story cards with customizable templates (Polaroid, Editorial, Minimalist, Magazine) ready for social media dispatch or web publishing.
High-Level System Architecture & Client-Server Pipeline
02Routeory is organized as a monorepo containing a high-throughput backend service and an offline-ready mobile application:
• Backend API Engine (backend-api): Built with NestJS and the Fastify HTTP platform adapter for maximum request throughput and low serialization overhead. Prisma ORM interfaces with PostgreSQL, and Socket.io powers bi-directional event distribution. • Mobile Client Stack (mobile-app): React Native built on Expo SDK 56 with Expo Router file-based typed routing, NativeWind v4 styling, Zustand global state, TanStack React Query v5 server caching, and hardware-backed Expo SecureStore for JWT tokens. • Direct-to-Cloud Upload Pipeline: To keep backend nodes bandwidth-free, the mobile client requests presigned HMAC SHA-256 signatures from GET /media/signature and uploads images/videos directly to Cloudinary, submitting only media URLs and metadata to the database.
Real-Time Collaboration & Socket.io Synchronization Engine
03The CollaborationGateway synchronizes expedition activities across all active co-travelers:
• Handshake Token Authentication: Extracts and verifies JWT credentials from socket connection headers before granting room access. • Multi-Room Event Routing: - user:<userId>: Dedicated private room for real-time invitations, friend requests, and individual alert payloads. - trip:<tripId>: Broadcast channel for active co-travelers on a specific journey. • Event Mesh: Broadcasts timeline_update → on_timeline_update and budget_update → on_budget_update across the crew room. • Offline Resilience: Local Zustand stores maintain mutation queues while off-grid; when network connectivity returns, drafts are flushed sequentially and React Query invalidates cached timeline slices.
Chronological Timeline & Multi-Modal Expedition Logging
04Expeditions are structured into chronological dayNumber buckets with support for multi-modal milestone entries:
• Photos & Media: High-resolution assets with Cloudinary public IDs, dimensions, and optimized thumbnails. • Quick Notes: Ephemeral thoughts and trail observations. • Geocoded Places: Linked geographic pins with Google Place IDs, addresses, and GPS coordinates. • Linked Expenses: Financial records tied directly to timeline events. • AI Journal Cards: Beautifully formatted editorial summaries generated for each day.
Entries support offline timestamp recording and re-ordering, slotting seamlessly into historical sequence upon synchronization.
Expense Tracking & Greedy Bipartite Debt Settlement
05Routeory manages complex multi-party travel budgets with extreme precision:
• Multi-Currency Split Ledger: Records expenses with high precision (Decimal(12, 2)), currency codes, category tags (Food, Accommodation, Transport, etc.), and custom or equal split allocations. • Greedy Minimal-Transaction Algorithm: 1. Computes Net Balance for each traveler: NetBalance[i] = TotalPaidBy[i] - TotalOwedBy[i]. 2. Partitions travelers into sorted lists: Creditors (NetBalance > 0 descending) and Debtors (NetBalance < 0 descending by absolute debt). 3. Executes a two-pointer reduction loop matching top creditors with top debtors, eliminating circular transfers and resolving all crew balances with the absolute minimal transaction count.
AI Storyteller & GPT-4o Narrative Synthesis
06The AiService turns raw chronological logs into literary travelogues:
• Context Aggregation: Collects all notes, places visited, media captions, and expense summaries for a specified dayNumber. • Prompt Engineering: Structured system instructions emphasize vivid travel prose, sensory detail, tone selection, and an evocative one-sentence summary caption. • Atomic Storage: Saves the synthesized narrative in the Journal database table inside an atomic transaction, generating a JOURNAL timeline card. • Fallback Pipeline: Operates with a deterministic procedural narrative generator when running in offline or sandbox environments.
Cinematic Travel Replay & Geospatial Route Caching
07The ReplayService generates animated expedition playback packages:
• Intelligent Geospatial Caching: Waypoint coordinates are rounded to 5 decimal places (originKey, destKey) and checked against the PostgreSQL RouteCache table (30-day TTL). On cache misses, OSRM turn-by-turn routing coordinates are retrieved and stored as GeoJSON polylines. • Animated Map Controller: The mobile client utilizes useReplayTimelineEngine to smoothly interpolate map camera pitch, heading, waypoint progress markers, and zoom levels across playback speeds (1x, 2x, 4x).
Story Sharing, Canvas Export & Public Web Publishing
08Travelers can export and showcase their memories across multiple formats:
• Visual Story Templates: Features pre-built designer templates including Polaroid (nostalgic frame with handwritten caption notes), Editorial/Magazine (modern typographical showcase), and Minimalist (clean photo display with coordinates). • Native Canvas Capture: Uses react-native-view-shot to render off-screen components into crisp PNG/JPEG files and triggers expo-sharing for instant Instagram or WhatsApp dispatch. • Public Web Publishing: Trip owners can publish public chronicles via unique PublicStory slugs, rendering responsive web views for friends and family.
Database Architecture & Performance Engineering
09The backend persistence layer is built on PostgreSQL with Prisma ORM:
• High-Performance Indexing: High-cardinality compound indices on [tripId, loggedAt], [userId, createdAt], and [ownerId], alongside unique constraints on [tripId, userId] (collaborators) and [expenseId, userId] (splits). • Fastify HTTP Advantage: Replaces standard Express with Fastify, doubling route execution throughput and minimizing JSON serialization latency. • Stateless Architecture: Decoupled socket rooms and JWT session handling allow seamless horizontal node clustering behind a Redis Pub/Sub adapter.
Highlights
010High
Throughput Fastify Engine: Sub-millisecond route handling and Socket.io event broadcasting for real-time co-traveler synchronization.
Greedy Minimal
Transaction Debt Settlement: Bipartite balance reduction algorithm simplifying group expense settlements.
Autonomous GPT
4o Storytelling: Converts raw GPS coordinates, notes, and timestamps into published literary travelogues.
Cinematic Replay with OSRM Caching
Animated map tracking with 30-day GeoJSON route caching in PostgreSQL.
Direct
to-Cloud Presigned Media Pipeline: Zero server-bandwidth media uploads using Cloudinary HMAC SHA-256 signatures.
Multi
Format Social Story Designer: Offline canvas rendering across Polaroid, Magazine, and Minimal templates.
Outcome & Status
011Shipped a production-grade full-stack travel operating system combining mobile native ergonomics, real-time collaboration, and automated narrative intelligence.