AI-powered field service equipment analysis and repair planning system. Demonstrates Gemini 2.0 as the core reasoning engine with multimodal analysis, knowledge base retrieval, cited repair plans, safety validation, and automated work order generation.
- Multimodal Analysis: Vision AI analyzes equipment images to identify problems and risks
- Knowledge Base Integration: Searches manuals, runbooks, and incident reports
- Cited Repair Plans: Step-by-step plans with KB citations for every step
- Safety Validation: Automated safety checks with PPE and hazard identification
- Work Order Generation: Automatic parts lists and time estimates
- Timeline & Metrics: Track execution time and efficiency gains vs baseline
- Next.js 15 (App Router) + TypeScript
- Gemini 2.0 API via
@google/generative-ai - Prisma + SQLite (local dev)
- TailwindCSS for UI
- Zod for schema validation
npm install
cp .env.example .env
npx prisma migrate dev
npm run devOpen http://localhost:3000 and go to /live.
- Open
/live - Select a scenario
- Click "Run Full Demo"
- Review the session pages: Overview → Plan → Safety → Work Order → QA Gate → Metrics
- Node.js 18+ and npm
- A Gemini API key from Google AI Studio
- Clone and install dependencies
npm install- Set up environment variables
Copy .env.example to .env:
cp .env.example .envEdit .env and add your Gemini API key:
GEMINI_API_KEY=your_api_key_here
GEMINI_MODEL=gemini-3-flash-preview
DATABASE_URL="file:./dev.db"
DEMO_ONLY=0
- Set up database
npx prisma migrate dev
npx prisma generate- Add demo images (OPTIONAL)
The demo now works without actual images! If demo images are missing, the system automatically uses realistic mock observation data, so you can run the full demo immediately.
To test with real Gemini Vision analysis (optional):
- Add 3 equipment images to
/public/demo_media/frames/:scenario1.jpg- HVAC/cooling equipmentscenario2.jpg- Generator/power equipmentscenario3.jpg- Equipment with visible hazards
- Or run:
node scripts/create-placeholders.jsto create minimal placeholder JPEGs
- Run development server
npm run devOpen http://localhost:3000 in your browser.
- Try the demo
- Go to
/live - Select a scenario
- Click "Run Full Demo"
- View results in the session dashboard
The /live page provides a one-click demo that:
- Creates a new session
- Analyzes equipment image with Gemini Vision (or uses mock data if images missing)
- Searches knowledge base for relevant info
- Generates repair plan with citations
- Runs safety validation
- Creates work order
- Redirects to session dashboard with timeline
No images required! The system automatically detects missing images and uses realistic mock observation data for each scenario. This allows you to test the complete workflow immediately without adding actual equipment photos.
fieldfix-ai/
├── src/
│ ├── app/ # Next.js App Router pages
│ │ ├── api/ # API route handlers
│ │ ├── session/[id]/ # Session detail pages
│ │ ├── live/ # Demo page
│ │ ├── layout.tsx # Root layout
│ │ └── page.tsx # Landing page
│ └── lib/
│ ├── gemini/ # Gemini API client & helpers
│ ├── kb/ # Knowledge base loader & search
│ ├── safety/ # Safety rules engine
│ ├── schemas/ # Zod validation schemas
│ ├── utils/ # JSON parsing utilities
│ ├── prompts.ts # Inline prompts (no fs reads)
│ └── db.ts # Prisma client
├── prisma/
│ ├── schema.prisma # Database schema
│ └── migrations/ # DB migrations
├── kb/ # Knowledge base JSON files
│ ├── manuals.json
│ ├── runbooks.json
│ └── incidents.json
└── public/
└── demo_media/
└── frames/ # Demo scenario images
POST /api/sessions- Create new sessionGET /api/sessions/[id]- Get session detailsPOST /api/analyze- Analyze equipment imagePOST /api/kb-search- Search knowledge basePOST /api/plan- Generate repair planPOST /api/qa- Quality assurance check (optional)POST /api/safety- Run safety validationPOST /api/workorders- Create work orderPOST /api/events- Log timeline eventPOST /api/upload- Upload handler (disabled in demo mode)
Set these in Vercel project settings:
GEMINI_API_KEY=your_api_key
GEMINI_MODEL=gemini-3-flash-preview
DATABASE_URL="file:./dev.db"
DEMO_ONLY=1
NEXT_PUBLIC_BASE_URL=https://fieldfix-ai.vercel.app
One-click demo URL:
https://fieldfix-ai.vercel.app/live?mode=demo
npm install -g vercel
vercelOr connect your GitHub repo to Vercel for automatic deployments.
The vercel.json config handles:
- Prisma generation during build
- Setting
DEMO_ONLY=1environment variable - Proper build command execution
Important: On Vercel, the SQLite database is ephemeral. Each deployment starts fresh. This is acceptable for demo purposes. For production, use a persistent database like PostgreSQL.
Once deployed, visit:
https://your-app.vercel.app/live
All prompts are in src/lib/prompts.ts as exported strings - no filesystem reads at runtime.
All Gemini responses are:
- Parsed with
safeJsonParse()utility - Validated with Zod schemas
- Retried once with
FIX_JSON_PROMPTif parsing fails
Every plan step must include citations array with KB IDs. The search system returns stable IDs (KB1, KB2, etc.) that are referenced in the plan.
Deterministic safety checks examine:
- Risk flags from observation
- Plan step keywords (electrical, height, etc.)
- Output: PPE requirements, hazards, required pre-steps
Events table logs all operations with timestamps for calculating:
- Analysis latency
- Plan generation time
- End-to-end duration
- Time saved vs 35-minute baseline
✅ Local: npm install && npx prisma migrate dev && npm run dev
✅ Navigate to /live, select scenario, click "Run Full Demo"
✅ Redirects to /session/:id showing timeline
✅ Plan page shows ≥3 steps with citations
✅ Safety page shows required presteps for hazardous scenarios
✅ Work order shows WO-###### number
✅ Metrics page shows latency and time saved
✅ Vercel: With DEMO_ONLY=1, demo works without uploads
✅ /api/upload returns 403 in demo mode
Gemini API errors: Verify your API key in .env
Database errors: Run npx prisma migrate dev and npx prisma generate
Missing images: ✅ Fixed! The system now automatically uses mock data when images are missing. To create placeholder images anyway, run: node scripts/create-placeholders.js
JSON parsing errors: Check Gemini responses - retry logic should handle most issues
TypeScript errors: Run npm install to ensure all dependencies are installed
- Demo mode uses pre-loaded scenarios (no uploads needed)
- KB files are loaded at runtime from
/kbdirectory - All prompts are inline (no fs.readFile in API routes)
- Zod validates all AI responses
- Safety rules are deterministic (no AI calls)
- Session status:
created→analyzing→planning→complete
Demo application - MIT License
For issues or questions, check:
- Gemini API docs: https://ai.google.dev/docs
- Next.js docs: https://nextjs.org/docs
- Prisma docs: https://www.prisma.io/docs