How sesuraja/aperture-people-tracking-in-construction works
Purpose and Entry Points
Aperture is an operations/tracking dashboard for workforce, assets, visitors, devices, incidents, maps, and external hardware/API integrations. It combines a Vite React client with a TypeScript server/API layer. Client bootstraps at src/main.tsx into src/App.tsx; deployment/server entry points are server.ts and api/index.ts.
Application Shell and Navigation
src/App.tsx owns the dashboard composition, tab-level navigation, and shared modal surfaces. src/components/TopBar.tsx and src/components/CommandPaletteModal.tsx provide global interaction controls. The main feature areas are independently rendered tab components, including src/components/DashboardTab.tsx, src/components/LiveTrackingTab.tsx, and src/components/SettingsTab.tsx.
Live Tracking State and Visualization
Tracking-centric UI state is centralized in src/context/TrackingContext.tsx. It feeds live map and inspection experiences in src/components/LiveFloorMap.tsx, src/components/CustomMapPage.tsx, and src/components/LiveTrackingContextDrawer.tsx. Spatial/display-layer transformation is separated in src/lib/trackingLayers.ts, creating a boundary between incoming location/tag data and map presentation.
Device, RFID, and Event Ingestion
The backend exposes dedicated integration surfaces for hardware, RFID, events, and real-time streams through src/server/routes/hardware.ts, src/server/routes/rfid.ts, src/server/routes/events.ts, and src/server/routes/realtime.ts. Ingestion and hardware-specific orchestration reside in src/server/services/ingestionService.ts and src/server/services/hardwareIntegrationService.ts. The client configures these sources through src/components/HardwareIntegrationForm.tsx and src/components/RfidApiConfiguration.tsx.
Real-Time Transport Boundary
WebSocket, SSE, and MQTT are first-class transport options. Server-side adapters are in src/server/services/websocket.ts, src/server/services/sse.ts, and src/server/services/mqtt.ts; browser-facing access is in src/lib/webSocketService.ts, src/lib/useWebSocket.ts, and src/lib/mqttService.ts. This separates live feed acquisition/distribution from the tracking UI and allows diagnostics through src/components/StreamDiagnostics.tsx.
Persistence and External Connections
MongoDB-oriented schemas distinguish historical and current tag records in src/db/schemas/mongodb/history_records.ts and src/db/schemas/mongodb/real_time_tags.ts; server DB access is organized in src/server/services/db.ts. Connection discovery/polling and third-party integration management are handled by src/server/services/connectionsService.ts, src/server/services/connectionPoller.ts, and src/server/services/apiIntegrationService.ts, exposed via src/server/routes/connections.ts and src/server/routes/apiIntegrations.ts.
AI, Authentication, and Operational APIs
Gemini is an explicit runtime dependency via GEMINI_API_KEY; AI request handling and pipeline logic are located in src/server/routes/ai.ts and src/server/services/aiPipeline.ts, with client outputs in src/components/AIFeed.tsx and src/components/AIInsightsTab.tsx. Authentication and authorization form a server boundary through src/server/routes/auth.ts, src/server/middleware/auth.ts, and src/constants/permissions.ts. Cross-cutting failures are handled by src/server/middleware/errorHandler.ts and src/components/ErrorBoundary.tsx.
Runtime and Deployment
The repository uses Node.js, TypeScript, React, and Vite, with built client/server artifacts under dist/. It includes Firebase/Firestore deployment or policy artifacts in firebase-applet-config.json and firestore.rules, Mongo runtime configuration in .mongo_runtime.json, and Vercel configuration in vercel.json.
Main entry points: App.tsx Dashboard shell · hardware.ts Operational routes · ingestionService.ts Ingestion orchestration · webSocketService.ts Browser live transports
Components 21
React client
Dashboard shell and operational feature UI.
- Client bootstrap
src/main.tsx - Dashboard shell · Owns navigation and shared modal surfaces.
src/App.tsx - Global controls · Top bar and command palette interactions.
src/components/TopBar.tsx - Operational tabs · Dashboard, live tracking, and settings feature areas.
src/components/DashboardTab.tsx - Integration configuration · Hardware and RFID source setup.
src/components/HardwareIntegrationForm.tsx - AI insights UI · AI feed and insights presentation.
src/components/AIFeed.tsx
Live tracking
State, spatial transformation, and live map views.
- Tracking state · Central client state for tracking UI.
src/context/TrackingContext.tsx - Spatial layer transform · Converts location and tag data into map layers.
src/lib/trackingLayers.ts - Live map & inspector · Floor map, custom map, and context drawer.
src/components/LiveFloorMap.tsx - Browser live transports · WebSocket, hook, and MQTT access.
src/lib/webSocketService.ts - Stream diagnostics
src/components/StreamDiagnostics.tsx
Server API
Node/TypeScript API, integration, and transport boundaries.
- Server entry · Deployment and API entry points.
server.ts - Operational routes · Hardware, RFID, event, and realtime endpoints.
src/server/routes/hardware.ts - Ingestion orchestration · Processes incoming events and hardware data.
src/server/services/ingestionService.ts - Live transport adapters · WebSocket, SSE, and MQTT distribution.
src/server/services/websocket.ts - External connection management · Discovery, polling, and API integration management.
src/server/services/connectionsService.ts - Gemini AI pipeline · AI request processing through the Gemini runtime key.
src/server/services/aiPipeline.ts - Auth & authorization · Authentication and permission enforcement.
src/server/middleware/auth.ts
Data & external services
Persistence and third-party runtime dependencies.
- MongoDB tracking records · Historical records and current real-time tags.
src/db/schemas/mongodb/real_time_tags.ts - Hardware & third-party APIs
- Gemini · Configured with GEMINI_API_KEY.
Connections 22
- Client bootstrap → Dashboard shell: mounts
- Dashboard shell → Global controls: renders
- Dashboard shell → Operational tabs: navigates
- Dashboard shell → Tracking state: provides
- Dashboard shell → Integration configuration: renders
- Dashboard shell → AI insights UI: renders
- Tracking state → Spatial layer transform: supplies tag state
- Spatial layer transform → Live map & inspector: builds map display
- Browser live transports → Tracking state: updates live state
- Browser live transports → Stream diagnostics: reports status
- Integration configuration → Operational routes: configures
- Server entry → Operational routes: serves
- Operational routes → Auth & authorization: protected by
- Operational routes → Ingestion orchestration: submits events
- Operational routes → External connection management: manages connections
- Ingestion orchestration → Live transport adapters: publishes updates
- Live transport adapters → Browser live transports: streams live feeds
- Ingestion orchestration → MongoDB tracking records: stores tags and history
- External connection management → Hardware & third-party APIs: discovers and polls
- Hardware & third-party APIs → Ingestion orchestration: sends hardware data
- AI insights UI → Gemini AI pipeline: requests insights
- Gemini AI pipeline → Gemini: invokes