Skip to content

About

FieldVoice AI is an enterprise-grade, voice-first application designed 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 manual search

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

41 Commits

Folders and files

Repository files navigation

FieldVoice AI: Voice-First AI Assistant for Field Workers

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:

  1. Node.js / Express Backend Monolith: Serves REST and WebSocket endpoints, manages PostgreSQL and pgvector operations, coordinates custom AI pipelines (Whisper STT, LLM parsing, FAISS RAG), and implements dynamic API key rotation with file caching.
  2. 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.
  3. 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.

πŸš€ Key Capabilities & core Innovations

  • 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.

πŸ—οΈ System Architecture & Data Flow

πŸ”„ Logical Architecture Flowchart

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;
Loading

⏱️ End-to-End Query Response Sequence (RAG Pipeline)

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."
Loading

πŸ—„οΈ Database Schema & Relational Structure

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|
                               +------------------------+

Performance Optimization Indexes

To ensure fast execution of queries displaying real-time technician feeds and search lists:

  • idx_work_orders_eq_id on work_orders(equipment_id)
  • idx_work_orders_logged_by on work_orders(logged_by)
  • idx_transcripts_wo_id on voice_transcripts(work_order_id)

πŸ“‘ API Interface Specification

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 string
    • audio_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" }
      ]
    }

πŸ“ Repository Directory Layout

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

πŸ› οΈ Installation & Setup Instructions

System Prerequisites

  • Node.js: v18.0.0 or higher
  • Flutter SDK: v3.19.0 or higher
  • PostgreSQL: v14.0 or higher (with pgvector enabled)

1. Database Setup

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)

2. Backend Service Configuration

  1. Navigate to the backend directory and install dependencies:
    cd backend
    npm install
  2. Create your local .env configuration file:
    cp .env.example .env
  3. 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
  4. 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

3. Frontend Web Dashboard Setup

  1. Navigate to the frontend folder and install packages:
    cd ../frontend
    npm install
  2. Run the Next.js supervisor dashboard client locally:
    npm run dev
    The web application dashboard will start at http://localhost:3001.

4. Mobile Client Setup (Flutter)

  1. Navigate to the mobile directory:
    cd ../mobile
    flutter pub get
  2. Ensure an Android device or emulator is running:
    flutter devices
  3. Launch the application on the active device:
    flutter run
  4. Build a debug APK package for direct installation:
    flutter build apk --debug

πŸ§ͺ Testing Specifications

We maintain a comprehensive, automated test suite on the backend to verify service limits and schema integrity.

50 Integration & Unit Tests

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

About

FieldVoice AI is an enterprise-grade, voice-first application designed 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 manual search

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages