Skip to content

Architecture

Overview

Neverline utilizes a monorepo architecture comprising a React frontend suite, a Fastify REST API, and Supabase for underlying data structuring and resilient authentication.

neverline/
├── apps/client/        # React + Vite (customer PWA)
├── apps/dashboard/     # React + Vite (admin dashboard)
├── apps/mobile-access/ # Expo + React Native (staff mobile app)
├── services/api/       # Fastify REST API
├── packages/shared/    # Shared types, schemas, constants
├── supabase/           # Migrations, seed data
└── docs/manual/        # VitePress documentation

Frontend — Customer PWA (apps/client)

  • React with TypeScript and Vite
  • Mobile-first Progressive Web App
  • Framer Motion for animations

Key Routes

PathComponentDescription
/join/:queueIdJoinPageQueue joining form
/statusStatusPageWaiting screen with position, chat, wayfinding
/actionActionPageDeep-link action handler
/feedbackFeedbackPagePost-service feedback
/planPlanArrivalPagePre-arrival time window picker

Key Components

ComponentFeature
ChatViewIn-app two-way chat with staff
WayfindingViewArrival guidance with map + overrides
AlternativesCardSmart queue alternative suggestions
AnnouncementBannerReal-time announcement display
AwayModeTimerAway countdown timer
LatePickerSheetETA picker for running late
ReturnPickerSheetReturn from away picker
CancelConfirmDialogQueue leave confirmation

Frontend — Admin Dashboard (apps/dashboard)

  • React with TypeScript and Vite
  • React Router for client-side routing
  • Recharts for analytics charts
  • Framer Motion for queue view animations

Dashboard Routes

PathComponentDescription
/loginLoginPageStaff authentication
/adminAdminLayoutDashboard shell with sidebar
/admin/dashboardDashboardPageOverview KPIs
/admin/queuesQueuesPageQueue management (4 view modes)
/admin/queues/:idQueueDetailPageQueue detail + policy settings
/admin/analyticsAnalyticsPageHistory & statistics
/admin/customersCustomersPageCustomer list
/admin/announcementsAnnouncementsPageAnnouncement CRUD
/admin/forecastForecastPagePlanned arrival forecasting
/admin/locationsLocationsPageLocation & wayfinding management
/admin/chatChatInboxStaff chat inbox
/admin/settingsSettingsPageOrganization settings
  • AuthContext — Supabase session and user profile
  • LanguageContext — FI/EN translations (admin)
  • ThemeContext — Light/dark mode
  • ServingContext — Active serving sessions for the current staff member

Frontend — Staff Mobile Scanner (apps/mobile-access)

  • React Native + Expo
  • Expo Router for file-based routing
  • Engineered specifically for staff operators managing rapid venue ingress
  • Native camera integration for QR/Barcode ticket verification

Key Features

  • High-performance barcode scanning
  • Direct connection to the Fastify API (via LAN IP in development)
  • Native haptic feedback upon successful verification

Backend (services/api)

  • Fastify with TypeScript
  • Routes organized by domain
  • Supabase client for database access (service role key)

Routes

FilePurpose
routes/queues.tsQueue CRUD, status management, alternatives
routes/sessions.tsJoin, call, complete, requeue, away, late, return
routes/analytics.tsAnalytics summary endpoint
routes/announcements.tsAnnouncement CRUD (scoped)
routes/chat.tsChat thread and message endpoints
routes/locations.tsLocation management, wayfinding overrides
routes/planned-arrivals.tsPre-arrival signals, forecast, conversion

Services

FilePurpose
services/queue-engine.tsCore queue logic, policy enforcement, alternatives, jump detection
services/notification-trigger.tsEvent-driven notification dispatch
services/notification-templates.tsSMS/push message templates
services/timer-processor.tsBackground expired-timer scanner
services/event-emitter.tsQueue event emission
services/position-manager.tsQueue position recalculation
services/wait-time-estimator.tsWait time algorithm

Libraries

FilePurpose
lib/deep-links.tsHMAC-signed action URL generation/verification
lib/wait-estimate.tsWait time estimation algorithm
lib/crypto.tsAES-256-GCM PII encryption
lib/errors.tsStructured error handling

Database

PostgreSQL via Supabase with the following tables:

Core Tables

TablePurpose
organizationsTenant isolation
queuesQueue definitions, settings, and policies
queue_sessionsIndividual customer visits
staff_profilesStaff user metadata

Feature Tables

TablePurpose
announcementsScoped announcements (org/location/queue)
chat_threadsChat conversation threads
chat_messagesIndividual chat messages
planned_arrivalsPre-arrival signals
service_locationsPhysical venue details
wayfinding_overridesTemporary navigation alerts
queue_alternativesCross-queue alternative mappings

System Tables

TablePurpose
webhook_subscriptionsWebhook configuration
api_keysAPI key management
feedbackCustomer feedback
staff_queue_assignmentsStaff-to-queue access control

Row-Level Security (RLS) policies ensure organization-level data isolation.

Wait Time Estimation

The wait time algorithm (in lib/wait-estimate.ts) computes:

  1. Weighted average service time from completed sessions:
    • 70% from sessions in the same 2-hour time window
    • 30% from all sessions in the period
    • Looks at 7 days, falls back to 30 days, then to queue.avg_service_time_s
  2. Active server count from sessions with status = 'serving'
  3. Per-person estimate: (peopleAhead × avgServiceTime) / activeServers