Skip to content

Player Client

Status: 🚧 Partial β€” Core player-client inventory (first-login, galaxy 3D, trading-interface, subscriptions, services/contexts) is accurate … Β· ⚠︎ contains code↔spec divergence (impl audit 2026-06-16)

The player-facing web app at services/player-client/.


1. Tech stack

From services/player-client/package.json:

Layer Choice
Framework React 18.2 + TypeScript 5.2
Build Vite 8.0
Routing react-router-dom 7.13
HTTP axios 1.13
3D three 0.158, @react-three/fiber 8.18, @react-three/drei 9.122
Animation framer-motion 10.16, @react-spring 9.7
Icons lucide-react 0.292
Sanitization isomorphic-dompurify 3.4 (XSS prevention for AI chat)
Utility lodash.debounce, lodash.throttle
i18n i18next 23.16 + react-i18next 13.5 + browser-languagedetector + http-backend
Tests Playwright 1.52

State management: React Context (AuthContext, GameContext, FirstLoginContext, WebSocketContext).

Default ports: player-client on 3000, gameserver on 8080.


2. Project layout

services/player-client/src/
β”œβ”€β”€ App.tsx, main.tsx, i18n.ts
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ai/              AIAssistant, AIAssistantButton, EnhancedAIAssistant (ARIA chat)
β”‚   β”œβ”€β”€ analytics/       AchievementTracker, GoalManager, Leaderboards, PlayerAnalytics, ProgressVisualizer
β”‚   β”œβ”€β”€ auth/
β”‚   β”œβ”€β”€ combat/          CombatInterface, CombatLog, CombatAnalytics, DroneManager,
β”‚   β”‚                    FleetBattlePanel, FormationControl, SiegeInterface, TacticalPlanner
β”‚   β”œβ”€β”€ common/          shared UI (LanguageSwitcher, etc.)
β”‚   β”œβ”€β”€ first-login/     FirstLoginContainer, DialogueExchange, ShipSelection,
β”‚   β”‚                    OutcomeDisplay, TrustMeter
β”‚   β”œβ”€β”€ galaxy/          Galaxy3DRenderer, SectorNode3D, PlayerMarker3D,
β”‚   β”‚                    ConnectionPath3D, StarField
β”‚   β”œβ”€β”€ layouts/
β”‚   β”œβ”€β”€ market-intelligence/  MarketAnalyzer, PricePredictor, RouteOptimizer, CompetitionMonitor
β”‚   β”œβ”€β”€ pages/           7 top-level pages (see Section 3)
β”‚   β”œβ”€β”€ paypal/          PayPalSubscription
β”‚   β”œβ”€β”€ planetary/       PlanetManager, BuildingManager, ColonistAllocator,
β”‚   β”‚                    ColonySpecialization, DefenseConfiguration, GenesisDeployment,
β”‚   β”‚                    ProductionDashboard, SiegeStatusMonitor, CitadelManager
β”‚   β”œβ”€β”€ ranking/         RankDisplay, RankProgress, Leaderboard, MedalShowcase
β”‚   β”œβ”€β”€ ships/           CargoManager, FleetCoordination, InsuranceManager,
β”‚   β”‚                    MaintenanceManager, ShipDetails, ShipSelector, UpgradeInterface
β”‚   β”œβ”€β”€ spacedock/       SpaceDockInterface
β”‚   β”œβ”€β”€ tactical/        SectorViewport, NavigationMap, PlanetCard, PlanetPortPair,
β”‚   β”‚                    StationCard, TacticalCard
β”‚   β”œβ”€β”€ teams/           TeamManager, TeamChat, TeamAnalytics, AllianceManager,
β”‚   β”‚                    DiplomacyInterface, ResourceSharing
β”‚   └── trading/         TradingInterface, MarketIntelligenceDashboard, SmartTradingAutomation
β”œβ”€β”€ contexts/            AuthContext, GameContext, FirstLoginContext, WebSocketContext
β”œβ”€β”€ services/            api.ts, apiClient.ts, websocket.ts, realtimeWebSocket.ts, aiTradingService.ts
β”œβ”€β”€ styles/, themes/, types/, utils/
└── utils/security/      XSS / sanitization helpers (separate from common utils)

A shared API layer lives in services/api.ts (~14.6 KB) plus services/apiClient.ts. Real-time traffic flows through services/realtimeWebSocket.ts (the multiplayer protocol client).


3. Pages

components/pages/ has 7 top-level pages:

Page Purpose
LoginPage.tsx Auth
Dashboard.tsx, GameDashboard.tsx Player landing pages
GalaxyMap.tsx Galaxy / sector navigation (uses galaxy/ 3D components)
SubscriptionResult.tsx PayPal subscription confirmation
DebugPage.tsx, TestAuthPage.tsx Dev / QA tools

Most actual gameplay UI happens inside the dashboards via the feature modules above rather than dedicated pages.

A markdown sketch (components/GameDashboardIntegration.md) sits alongside the code as in-tree design notes.


4. Key features

First-Login AI dialogue

first-login/FirstLoginContainer.tsx orchestrates the AI guard interrogation. DialogueExchange.tsx renders the conversation, TrustMeter.tsx shows persuasion progress, ShipSelection.tsx is the ship picker, OutcomeDisplay.tsx shows the resolution. CSS is heavy (first-login.css). Backed by /api/v1/first-login/* and the multi-provider AI dialogue service (OpenAI primary, Anthropic secondary, deterministic fallback).

Trading + ARIA market intelligence

trading/TradingInterface.tsx is the core buy/sell UI. trading/MarketIntelligenceDashboard.tsx (~22 KB) and trading/SmartTradingAutomation.tsx (~29 KB) plus the market-intelligence/ quartet (MarketAnalyzer, PricePredictor, RouteOptimizer, CompetitionMonitor) surface ARIA's per-player observations and predictions. Service: services/aiTradingService.ts.

Combat

Eight components in combat/ covering combat interface, log, analytics, drone management, fleet battle panel, formation control, siege interface, and tactical planner. The combat/README.md indicates the directory has its own internal docs.

Planetary management

Nine components in planetary/ covering planet manager, building manager, colonist allocation, colony specialization, defense configuration, genesis deployment, production dashboard, siege monitoring, and citadel management.

Galaxy / 3D

galaxy/Galaxy3DRenderer.tsx plus SectorNode3D, PlayerMarker3D, ConnectionPath3D, StarField provide the Three.js view. tactical/SectorViewport.tsx is the in-sector 2D view.

Teams / alliances

Six components in teams/: TeamManager, TeamChat, TeamAnalytics, AllianceManager, DiplomacyInterface, ResourceSharing.

Ships & space dock

ships/ has 7 components (cargo, fleet coordination, insurance, maintenance, details, selector, upgrade UI). spacedock/SpaceDockInterface.tsx is the standalone dock view.

ARIA chat

See ./aria.md β€” ai/EnhancedAIAssistant.tsx is the main chat component with DOMPurify sanitization, client-side rate limiting, Web Speech API, and WebSocket integration.

Subscriptions

paypal/PayPalSubscription.tsx plus pages/SubscriptionResult.tsx handle the PayPal monetization flow used by multi-regional ($25/mo regional ownership, $5/mo galactic citizenship β€” see ./multi-regional.md).

Player progression UI

  • ranking/ (RankDisplay, RankProgress, Leaderboard, MedalShowcase) renders the military-rank progression. See FEATURES/gameplay/ranking.md.
  • analytics/AchievementTracker.tsx, GoalManager.tsx, and the rest of the analytics/ directory cover lifetime achievements and personal goals.

Real-time multiplayer

services/realtimeWebSocket.ts is the multiplayer-protocol client (presence, sector chat, combat events). See ./realtime.md.

i18n

common/LanguageSwitcher.tsx; full i18next setup. Six languages targeted (English / Spanish / French / Portuguese / Chinese launch-complete; German Partial β€” see ./i18n.md).


5. Build / test

# from services/player-client/
npm run dev         # vite dev (port 3000)
npm run build       # tsc + vite build
npm run lint        # eslint
npm run test:e2e    # playwright via scripts/run-tests.js
npm run test:e2e:ui # playwright UI mode

E2E specs: - e2e_tests/player/ui/player-ui.spec.ts β€” player-UI spec. - e2e_tests/foundation-sprint/security-validation.spec.ts, websocket-realtime.spec.ts β€” cross-cutting tests.