FieldVoice AI is an enterprise-grade, voice-first monorepo application designed specifically for field technicians and supervisors in high-noise industrial environments (e.g., power plants, manufacturing facilities). The system enables hands-free inspections, natural language work order logging with an interactive voice confirmation loop, vector-based (RAG) technical manual search, and offline data queuing.
It is structured as a robust monorepo consisting of:
- Node.js / Express Backend Monolith: Serves REST and WebSocket endpoints, manages PostgreSQL and
pgvectoroperations, coordinates custom AI pipelines (Whisper STT, LLM parsing, FAISS RAG), and implements dynamic API key rotation with file caching. - Next.js Web Dashboard: Provides supervisors with real-time technician streams, playable voice logs with transcripts, and audit tools to resolve low-confidence parse exceptions.
- Flutter Mobile Application: A ruggedized technician client supporting background wake-word listening, Bluetooth headset integration, real-time visual sound wave feedback, and local SQLite offline queueing.
- Hands-Free Voice Confirmation & Loop: Technicians speak inspection logs, hear a synthesized readback of parsed data, and can state natural language modifications (e.g., "change severity to critical") or verify verbally ("confirm" / "cancel"), entirely screen-free.
- API Key Rotation & Failover: Active-passive failover between primary (
GROQ_API_KEY) and secondary (GROQ_API_KEY_2) keys on backend text-to-speech requests to prevent rate limit (TPD) exhaustion. - Static Template TTS Caching: MD5 hashing and local caching of static vocal messages (e.g., "inspection started") to significantly reduce external API dependencies.
- RAG Document Search: Similarity indexing of manual PDFs using localized FAISS-Node and pgvector, yielding conversational, spoken-optimized answers inside a 3-second SLA.
- Idempotent Offline Sync Daemon: Device-local transaction queuing in SQLite (mobile) or IndexedDB (web) using unique UUID payloads to prevent duplicate work orders on the backend upon network reconnection.
- Supervisor Audit Portal: Real-time Socket.io streams highlighting data-entry warnings and low-confidence transcribing exceptions for supervisor correction.
graph TB
%% Custom Professional Theme Styling
classDef clientStyle fill:#F0F4F8,stroke:#102A43,stroke-width:2px,color:#102A43;
classDef serverStyle fill:#F7F9FB,stroke:#334E68,stroke-width:2px,color:#334E68;
classDef aiStyle fill:#EBF8FF,stroke:#1B4D7E,stroke-width:2px,color:#1B4D7E;
classDef dbStyle fill:#FFFBEA,stroke:#7B4216,stroke-width:2px,color:#7B4216;
classDef extStyle fill:#F5F3FF,stroke:#4C1D95,stroke-width:2px,color:#4C1D95;
%% Client Tier Subgraph
subgraph client_tier ["π± Client Tier (Flutter Mobile & React Web)"]
direction TB
Mic([π€ Microphone Input]) -->|Raw Audio| Capture[Audio Capture & Opus Encoder]
Capture --> NetworkCheck{π Network Check}
NetworkCheck -->|Offline| OfflineDB[(πΎ Local SQLite / IndexedDB)]
NetworkCheck -->|Online| APIClient[π‘ API HTTP Client]
OfflineDB -->|Auto-Sync Batch Queue| APIClient
VUI[π£οΈ VUI Controller] -->|Play TTS Readout| Speaker[\π Device Speaker/]
Dash[π Supervisor Dashboard]
end
%% Ingestion Pipeline (Application Entry)
subgraph ingestion_pipeline ["π₯ Ingestion & Orchestration Layer"]
Ingest[Audio Ingestion Module]
SocketManager[π Socket.io Broadcast Manager]
APIClient -->|1. Multipart Form Data / JSON| Ingest
end
%% AI Pipeline Sequential Execution
subgraph ai_pipeline ["π€ Custom AI Pipeline"]
direction LR
STTGateway[π£οΈ Groq Whisper STT]
RAG[π FAISS RAG Searcher]
LLMExtractor[π€ OpenAI Schema Extractor]
TTSGateway[π’ Groq Orpheus TTS]
STTGateway -->|2. Transcribed Text| RAG
RAG -->|3. Matched Specs + Transcript| LLMExtractor
LLMExtractor -->|4. Structured Fields| TTSGateway
end
%% Core Application linking back
Ingest -->|Trigger Job| STTGateway
TTSGateway -->|5. Audio Wav Buffer + JSON Meta| Ingest
Ingest -->|6. JSON Response & Cached TTS URL| VUI
%% External APIs Subgraph
subgraph external_services ["βοΈ External AI Cloud Services"]
GroqSTT((Groq Cloud Whisper))
OpenRouter((OpenRouter API))
GroqTTS((Groq Cloud TTS))
STTGateway <--> GroqSTT
LLMExtractor <--> OpenRouter
TTSGateway <--> GroqTTS
end
%% Data Tier Subgraph
subgraph data_tier ["π Data Tier"]
VectorDB[(pgvector / FAISS Index)]
RelationalDB[(PostgreSQL DB)]
RAG <--> VectorDB
LLMExtractor -->|Save Audited Work Order| RelationalDB
RelationalDB -->|Change Capture / Event Trigger| SocketManager
end
SocketManager -.->|Push Real-time Metrics| Dash
%% Apply Classes
class Mic,Capture,NetworkCheck,OfflineDB,APIClient,VUI,Speaker,Dash clientStyle;
class Ingest,SocketManager serverStyle;
class STTGateway,RAG,LLMExtractor,TTSGateway aiStyle;
class VectorDB,RelationalDB dbStyle;
class GroqSTT,OpenRouter,GroqTTS extStyle;
sequenceDiagram
autonumber
actor Tech as Field Technician
participant Mobile as Flutter Client
participant Server as Node.js Monolith
participant FAISS as FAISS-Node Vector Store
participant LLM as OpenAI (OpenRouter)
participant TTS as Groq Orpheus TTS
Tech->>Mobile: Press PTT Button & Query: "What is the pressure limit for T-402?"
Mobile->>Mobile: Compress audio (Opus .ogg container)
Mobile->>Server: POST /api/queries [Opus Audio Payload]
Server->>Server: Run Speech-to-Text (Groq Whisper API)
Server->>FAISS: Search document embeddings for "T-402 pressure limit"
FAISS-->>Server: Return top matching context paragraph
Server->>LLM: Request conversational answer using context (Temp=0.0)
LLM-->>Server: Return response: "Generator T-402 pressure limit is 150 PSI."
Server->>TTS: Request Speech Synthesis (Voice: Hannah)
Note over Server, TTS: Failover checks GROQ_API_KEY & GROQ_API_KEY_2
TTS-->>Server: Return synthesized WAV buffer
Server-->>Mobile: HTTP 200: { answer_text, audio_url }
Mobile->>Mobile: Play synthesized audio response (Hannah voice)
Mobile-->>Tech: Spoken: "Generator T-402 pressure limit is 150 PSI."
The persistence layer uses a PostgreSQL relational database. Below is the Entity-Relationship structure and indexing strategy implemented to optimize analytical read speeds and JOIN operations.
+------------------------+
| workers |
+------------------------+
| id (UUID, PK) |
| username (VARCHAR) |
| full_name (VARCHAR) |
| role (role_enum) |
| is_active (BOOLEAN) |
| created_at (TIMESTAMPTZ|
+-----------β¬------------+
| 1
|
| 0..* (logged_by)
βΌ
+-----------------------+ 1 +------------------------+
| equipment |<βββββ| work_orders |
+-----------------------+ +------------------------+
| id (UUID, PK) | | id (UUID, PK) |
| tag (VARCHAR, Unique) | | equipment_id (UUID, FK)|
| name (VARCHAR) | | fault_code (VARCHAR) |
| location (VARCHAR) | | severity (severity_enum|
| specifications (JSONB)| | status (status_enum) |
| created_at (TIMESTAMPTZ | actions_taken (TEXT) |
+-----------------------+ | parts_required (ARR) |
| offline_created_at (TS)|
| created_at (TIMESTAMPTZ|
+-----------β¬------------+
| 1
|
| 0..*
βΌ
+------------------------+
| voice_transcripts |
+------------------------+
| id (UUID, PK) |
| work_order_id (UUID,FK)|
| raw_transcript (TEXT) |
| confidence_score (NUM) |
| exception_flag (BOOL) |
| audio_storage_url (VAR)|
| created_at (TIMESTAMPTZ|
+------------------------+
To ensure fast execution of queries displaying real-time technician feeds and search lists:
idx_work_orders_eq_idonwork_orders(equipment_id)idx_work_orders_logged_byonwork_orders(logged_by)idx_transcripts_wo_idonvoice_transcripts(work_order_id)
1. Speech Processing & Extraction [POST /api/audio/process]
Receives raw inspection audio, runs speech-to-text, parses entities, and generates TTS confirmation response.
-
Content-Type:
multipart/form-data -
Request Payload:
audio: Opus encoded file (.ogg, max 10MB)technician_id:e3b0c442-98fc-1111-b303-0242ac120002(UUID)
-
Response Payload (HTTP 200):
{ "transaction_id": "tx-abc-123", "raw_transcript": "log inspection generator T-402 oil leak severity high", "confidence_score": 0.945, "exception_flag": false, "parsed_fields": { "equipment_id": "COMP-7A", "location": "Basement Sump", "fault_code": "F-LEAK-OIL", "severity": "High", "actions_taken": "Closed isolation valve", "parts_required": ["Gasket Kit", "Sealant"] }, "tts_audio_url": "/uploads/speech-172839482.wav" }
2. RAG Knowledge Manual Queries [POST /api/queries]
Resolves technical manuals and system history queries using similarity vector retrieval and outputs plain text with matching source documentation.
-
Content-Type:
application/json -
Request Payload:
{ "query_text": "What is the oil pressure limit for Generator T-402?", "technician_id": "e3b0c442-98fc-1111-b303-0242ac120002" } -
Response Payload (HTTP 200):
{ "answer": "The oil pressure limit for Generator T-402 is 150 PSI.", "source_documents": [ "Turbine manual section 4.2: Max operating pressure 150 PSI." ], "tts_audio_url": "/uploads/cached-speech-abc123hex.wav" }
3. Voice Correction Update [POST /api/extraction/update]
Applies natural language updates to currently parsed fields in the voice confirmation loop.
-
Content-Type:
application/json -
Request Payload:
{ "currentData": { "equipment_id": "T-402", "fault_code": "F-LEAK-OIL", "severity": "HIGH", "parts_required": [] }, "changeRequest": "actually change severity to critical and add a sealant" } -
Response Payload (HTTP 200):
{ "success": true, "updated_fields": { "equipment_id": "T-402", "fault_code": "F-LEAK-OIL", "severity": "CRITICAL", "parts_required": ["Sealant"] }, "tts_audio_url": "/uploads/speech-updated-1823794.wav" }
4. Offline Sync Batch Ingestion [POST /api/sync/batch]
Receives batched offline recordings along with chronological metadata, ensuring write idempotency.
- Content-Type:
multipart/form-data - Request Payload:
manifest: JSON metadata stringaudio_1,audio_2: File binaries
- Response Payload (HTTP 207 Multi-Status):
{ "processed_count": 2, "results": [ { "uuid": "uuid-1234", "status": "SUCCESS" }, { "uuid": "uuid-5678", "status": "DUPLICATE_SKIPPED" } ] }
Click to expand Repository Folder Structure
fieldvoice-ai/
βββ backend/ # Express.js Backend Application
β βββ src/ # Application Source Files
β β βββ config/ # Service clients & environment setup
β β β βββ db.js # PostgreSQL client connection pool
β β β βββ groq.js # Groq API client config (Whisper STT)
β β β βββ openrouter.js # OpenRouter API client config (LLM)
β β βββ controllers/ # API Controller logic handlers
β β β βββ audioController.js # Handles uploads, transcribes, and extracts
β β β βββ orderController.js # Handles manual CRUD and updates
β β β βββ queryController.js # Handles vector search and Q&A answers
β β βββ db/ # PostgreSQL Migrations & Seeding
β β β βββ init.js # SQL DB Initializer Schema code
β β β βββ seeds/ # Starter data (mock assets, manuals)
β β βββ models/ # Database Model Queries
β β β βββ Equipment.js # Queries for asset tags and metadata
β β β βββ WorkOrder.js # Queries for creating/updating orders
β β β βββ Worker.js # Queries for technician directories
β β βββ routes/ # Express API Route definitions
β β βββ services/ # Core Domain Services
β β β βββ faissService.js # FAISS-Node search and indexing service
β β β βββ llmService.js # OpenAI prompt parser using OpenRouter
β β β βββ ttsService.js # CanopyLabs Orpheus TTS with Failover Rotation
β β β βββ syncService.js # Batch queue database sync logic
β β βββ index.js # Express application entry point
β β βββ sockets.js # Socket.io connection coordinator
β βββ package.json # Backend dependencies
β βββ .env.example # Backend environment variables
β
βββ frontend/ # Next.js Client Application
β βββ public/ # Static Assets (audio chimes, icons)
β βββ src/ # Client Source Files
β β βββ app/ # Next.js App Router View pages
β β βββ components/ # Reusable React UI Components
β β βββ hooks/ # Client Hooks (Voice & Network logic)
β β βββ utils/ # Client-side utility functions
β β βββ package.json # Frontend dependencies
β β βββ .env.example # Frontend environment variables
β
βββ mobile/ # Flutter Mobile Application
β βββ lib/ # Flutter Source Code
β β βββ screens/ # Screen widgets (home_screen.dart)
β β βββ services/ # APIs, Audio services, and Bluetooth
β β βββ main.dart # App bootstrap entrypoint
β βββ pubspec.yaml # Flutter package configuration
β βββ README.md # Mobile project starting guide
β
βββ render.yaml # Render.com Cloud Deployment template
βββ README.md # Monorepo root README
βββ package.json # Monorepo workspace root configuration
- Node.js: v18.0.0 or higher
- Flutter SDK: v3.19.0 or higher
- PostgreSQL: v14.0 or higher (with
pgvectorenabled)
Create your PostgreSQL database instance and configure connectivity:
CREATE DATABASE fieldvoice;
-- (The backend service will automatically enable the uuid-ossp extension and seed tables on boot)- Navigate to the backend directory and install dependencies:
cd backend npm install - Create your local
.envconfiguration file:cp .env.example .env
- Configure variables inside
.env:PORT=3000 GROQ_API_KEY=your_primary_groq_api_key GROQ_API_KEY_2=your_secondary_groq_api_key OPENROUTER_API_KEY=your_openrouter_api_key PGHOST=127.0.0.1 PGPORT=5432 PGUSER=postgres PGPASSWORD=your_password PGDATABASE=fieldvoice PGSSL=false
- Boot up the tables schema and seed data, then launch the API server:
node src/db/init.js # Runs schema migrations & mock seeds npm run dev # Runs Express backend in development mode
- Navigate to the frontend folder and install packages:
cd ../frontend npm install - Run the Next.js supervisor dashboard client locally:
The web application dashboard will start at
npm run dev
http://localhost:3001.
- Navigate to the mobile directory:
cd ../mobile flutter pub get - Ensure an Android device or emulator is running:
flutter devices
- Launch the application on the active device:
flutter run
- Build a debug APK package for direct installation:
flutter build apk --debug
We maintain a comprehensive, automated test suite on the backend to verify service limits and schema integrity.
Tests cover:
sttService.test.js: Audio limits checks, size constraints (>25MB errors), and extensions mapping.extractionService.test.js: Valid JSON extraction schema audits and severity fallbacks.queryService.test.js: Local vector matches and timeout child-process termination limits.sse.test.js: Server-sent event client register, broadcast, and removal loops.workOrderService.test.js: Database queries transactions validation and rollback checks.
Run the test suite:
cd backend
npm run test