AI-powered intelligence platform for railway infrastructure management. Turns reactive maintenance into predictive operations.
Railway signal failures cause 23% of all train delays. Investigating a single failure takes 4–8 hours of manual log searches. When senior engineers retire, decades of diagnostic knowledge disappear. The same signals fail for the same reasons because no system connects the dots.
RailMind gives every engineer the combined knowledge of the entire organization. One question → 60-second AI pipeline → root cause + risk score + maintenance recommendation, backed by every historical incident ever recorded.
| Feature | Description |
|---|---|
| Digital Twin | Interactive Mapbox map of all 50 assets, risk-colored live |
| 7-Agent AI Pipeline | LangGraph StateGraph: investigate → recall → assess → recommend → plan → learn |
| Knowledge Graph | Neo4j with 10 node types, 12 relationship types across all incidents |
| Semantic Memory | Qdrant vector search across 6 collections — find by meaning, not keyword |
| Risk Intelligence | 5-factor formula + graph propagation to connected assets |
| Decision Engine | 7-layer synthesis: evidence → conflict resolution → explainability chain |
| Continuous Learning | Every closed incident auto-ingested into vector memory |
| Real-time Streaming | WebSocket agent thought trail — watch the AI reason step by step |
┌──────────────────────────────────────────────────────┐
│ Next.js 15 Frontend :3000 │
│ Dashboard · Twin · Agents · Graph · Risk · Incidents │
└────────────────────┬─────────────────────────────────┘
│ REST + WebSocket
┌────────────────────▼─────────────────────────────────┐
│ NestJS API :3001 │
│ 16 modules · JWT · RolesGuard · Helmet · Swagger │
└───┬──────────────────┬──────────────┬────────────────┘
│ │ │
PostgreSQL Neo4j Qdrant + Redis
(13 tables) (10 node types) (6 vector collections)
Frontend (Next.js 15) Backend (NestJS) AI Layer
───────────────── ──────────────── ────────
Digital Twin (Mapbox) → 16 REST modules → LangGraph (7 agents)
Knowledge Graph (ReactFlow) WebSocket gateway OpenAI GPT-4o-mini
Agent Console Prisma ORM Qdrant vector search
Risk Dashboard Neo4j graph traversal
Databases
──────────
PostgreSQL (facts)
Neo4j (relationships)
Qdrant (semantic memory)
Redis (cache + pub/sub)
Backend: NestJS 10 · TypeScript · Prisma 5 · LangGraph 0.2 · OpenAI GPT-4o-mini Frontend: Next.js 15 · React 19 · Tailwind CSS · ReactFlow · Mapbox GL · Recharts · Framer Motion Databases: PostgreSQL 15 · Neo4j 5 · Qdrant · Redis Infrastructure: Docker Compose · Socket.io · Turborepo · pnpm workspaces
| Layer | Technology |
|---|---|
| Frontend | Next.js 15, React 19, Tailwind CSS, shadcn/ui |
| State | Zustand + React Query |
| Maps | Mapbox GL JS (+ fallback SVG grid) |
| Graph UI | ReactFlow 11 |
| Charts | Recharts |
| Animations | Framer Motion |
| Backend | NestJS 10, TypeScript |
| ORM | Prisma 5 |
| AI Orchestration | LangGraph 0.2 (StateGraph) |
| LLM | OpenAI GPT-4o-mini |
| Embeddings | OpenAI text-embedding-3-small |
| Graph DB | Neo4j 5 |
| Vector DB | Qdrant |
| Cache | Redis |
| Relational DB | PostgreSQL 15 |
| Real-time | Socket.io |
| API Docs | Swagger/OpenAPI |
| Monorepo | Turborepo + pnpm workspaces |
| Document | What you'll find | |
|---|---|---|
| 📋 | Product Brief | Problem statement, 15 use cases, ROI, competitive analysis, Signal S11 story |
| ⚙️ | Setup Guide | Local development — step-by-step from clone to running app |
| 🚀 | Deployment Guide | Deploy to Render with Neo4j AuraDB + Qdrant Cloud |
| 🔬 | System Documentation | Full A–Z technical reference: every module, agent, schema, API route |
New here? Start with the Product Brief to understand what RailMind does and why, then come back to run it locally.
- Node.js 20+
- pnpm 8+ — install with
npm install -g pnpm@8 - Docker Desktop (running)
git clone https://github.com/Ambivert01/RAIL-MIND.git
cd RAIL-MIND
pnpm installCreate environment files from the example:
cp .env.example .env
cp .env services/api/.env
cp .env.example apps/web/.env.localThe defaults in .env.example are pre-configured for local Docker. Optional keys to fill in:
services/api/.env
OPENAI_API_KEY="sk-..." # optional — enables GPT responsesapps/web/.env.local
NEXT_PUBLIC_API_URL="http://localhost:3001" # do NOT append /api/v1
NEXT_PUBLIC_WS_URL="http://localhost:3001"
NEXT_PUBLIC_MAPBOX_TOKEN="pk.eyJ1..." # optional — fallback map works without itWithout OpenAI key: agent responses use templates, vector search uses hash embeddings — all other features work normally.
If you have old containers from a previous run, remove them first:
docker rm -f railmind_minio railmind_neo4j railmind_redis railmind_postgres railmind_qdrant 2>/dev/null || trueStart all databases:
docker compose up -d
# Wait ~30s for Neo4j to fully initializecd packages/shared-types
npx tsc
cd ../..cd services/api
npx prisma db push
cd ../..cd services/api
npx ts-node \
--transpile-only \
--compiler-options '{"module":"commonjs","target":"ES2020","esModuleInterop":true,"allowSyntheticDefaultImports":true,"resolveJsonModule":true}' \
../../scripts/seed/index.ts
cd ../..Loads: 10 stations · 50 assets · 100 incidents · 30 lessons · 10 procedures · 50 recommendations · Risk scores for all assets · Signal S11 escalating storyline (5 incidents, risk 87/100)
Terminal 1 — API:
cd services/api
npm run dev
# Wait for: 🚂 RailMind API running on port 3001Terminal 2 — Frontend:
cd apps/web
npm run dev
# Wait for: ✓ Ready in XsOnce both are running (first time only):
bash scripts/start-demo.shThis runs: Neo4j graph seeding → Risk recalculation → Qdrant vector ingestion
Free tier — cold start may take 30–60s on first request.
| Role | Password | |
|---|---|---|
| Administrator | admin@railmind.com | railmind123 |
| Engineer | engineer@railmind.com | railmind123 |
| Operator | operator@railmind.com | railmind123 |
| Maintenance Manager | manager@railmind.com | railmind123 |
| Safety Officer | safety@railmind.com | railmind123 |
Login → Dashboard → Digital Twin → Click Signal S11
→ Asset Profile → "Ask RailMind: Why is Signal S11 unstable?"
→ 7 agents reason live via WebSocket → Evidence + Risk 87/100 CRITICAL + Recommendation
→ Graph Explorer → S11 connected to 5 incidents, root causes, weather events
→ Risk Center → Heatmap of all 50 assets
Login as engineer@railmind.com. Dashboard shows:
- Network health across 50 assets
- 100 incidents with open/investigating/resolved breakdown
- Real-time agent activity feed
Navigate to Twin. The Mapbox map renders all 50 assets risk-colored:
- 🔴 Red = CRITICAL (score 81+)
- 🟠 Orange = HIGH (61–80)
- 🟡 Yellow = MODERATE (31–60)
- 🟢 Green = LOW (0–30)
Click Signal S11 (Rivergate station, red marker).
Signal S11 profile loads with 5 tabs:
- Overview: Health 13%, Risk 87/100 CRITICAL, 5 incidents
- Incidents: INC-044 through INC-090 — full escalation pattern
- Maintenance: Last maintenance history
- Recommendations: Pre-generated maintenance actions
- Graph: Relationship visualization
Click Ask RailMind and type:
Why is Signal S11 unstable?
Watch the agent trail in real-time (WebSocket):
- EXECUTIVE → Workflow started
- INCIDENT → Found 5 similar incidents (INC-044, INC-057, INC-081, INC-061, INC-090)
- KNOWLEDGE → Retrieved lessons on relay corrosion
- RISK → Score 87/100 CRITICAL — weather correlation detected
- ENGINEER → Relay replacement + housing seal inspection
- PLANNER → Emergency inspection within 24 hours
- LEARNING → Knowledge captured
Response includes:
- Root cause: Relay degradation + water ingress
- Evidence: 5 cited incidents
- Risk score: 87/100
- Confidence: ~85%
- Recommended action: Schedule emergency relay inspection
Navigate to Graph. Click Quick Load → Signal S11.
Visualizes (ReactFlow):
Signal S11 ──FAILED_IN──► INC-044 (Relay Corrosion)
└──► INC-057 (Water Ingress)
└──► INC-081 (Connector Degradation)
└──► INC-090 (Current Anomaly) ← ACTIVE
INC-044 ──HAS_CAUSE──► Relay Contact Degradation
INC-057 ──OCCURRED_DURING──► WeatherEvent:Heavy Rainfall
INC-044 ──RESOLVED_BY──► Resolution:Relay Replaced
Signal S11 ──PART_OF──► Station:Rivergate
INC-044 ──SIMILAR_TO──► INC-057
Navigate to Risk. Shows:
- Network KPIs: Critical assets count, average risk score
- Critical assets list with S11 at top
- Risk heatmap (50 asset grid, color-coded)
- 7-day trend chart (S11 escalating from 72→87)
- 30-day forecast per critical asset
Navigate to Recommendations. Shows 50 recommendations:
- Filter by status: PENDING / APPROVED / IN_PROGRESS / COMPLETED
- Click approve/reject/complete on any recommendation
- S11 recommendation: "Replace relay — component 15 years past spec"
Signal S11 at Rivergate Station has a documented failure pattern over 18 months:
| Incident | Date | Issue | Severity | Status |
|---|---|---|---|---|
| INC-044 | 18 months ago | Relay corrosion → intermittent failure | MEDIUM | RESOLVED |
| INC-057 | 14 months ago | Water ingress during heavy rainfall | HIGH | RESOLVED |
| INC-081 | 10 months ago | Connector degradation → comms loss | HIGH | RESOLVED |
| INC-061 | 8 months ago | Relay resistance drift detected | HIGH | RESOLVED |
| INC-090 | Current | Current anomaly — active investigation | CRITICAL | INVESTIGATING |
RailMind connects all 5 incidents through graph relationships, identifies the root cause pattern (relay degradation + environmental exposure), and recommends immediate relay replacement before total failure.
Swagger UI: http://localhost:3001/api/v1/docs
POST /auth/login Authentication
GET /twin/state Digital twin state (50 assets)
GET /assets/:id/profile Full asset intelligence profile
POST /agents/ask Trigger 7-agent investigation
GET /graph/asset/:id Asset knowledge graph
GET /risk/dashboard Network risk summary
GET /risk/heatmap All 50 assets with risk scores
POST /memory/ingest-all Batch vector ingestion
POST /graph/seed Seed Neo4j from PostgreSQL
POST /risk/recalculate Recalculate all asset risk scores
railmind/
├── apps/
│ └── web/ Next.js frontend
│ ├── src/app/ 17 pages (all functional)
│ ├── src/components/ Shared UI components
│ ├── src/stores/ Zustand state stores
│ ├── src/hooks/ Custom hooks (WebSocket, etc.)
│ └── src/lib/ API client, utilities
├── services/
│ └── api/ NestJS backend
│ ├── src/modules/ 16 feature modules
│ ├── src/database/ DB service clients
│ ├── prisma/ Schema + migrations
│ └── src/common/ Guards, decorators, filters
├── packages/
│ ├── shared-types/ TypeScript interfaces
│ └── ui/ Shared UI primitives
├── scripts/
│ ├── seed/ Database seed script
│ ├── data/ JSON seed data (50 assets, 100 incidents)
│ └── start-demo.sh One-command demo setup
└── docker-compose.yml Infrastructure stack
The system degrades gracefully:
- Agent answers use template fallback (not LLM-generated)
- Vector search uses deterministic hash embeddings (non-semantic)
- Risk scores, graph, and all other features work normally
- Warning displayed in
/memory/statsresponse
For best demo quality, set OPENAI_API_KEY.
pnpm: command not found
Install pnpm first: npm install -g pnpm@8
Docker container name conflict
Remove old containers: docker rm -f railmind_minio railmind_neo4j railmind_redis railmind_postgres railmind_qdrant
DATABASE_URL not found during prisma db push
Prisma needs .env inside services/api/. Run: cp .env services/api/.env
Login fails in the browser
Check apps/web/.env.local has NEXT_PUBLIC_API_URL="http://localhost:3001" — without /api/v1.
Graph shows placeholder nodes (9 nodes)
Neo4j not seeded. Run: bash scripts/start-demo.sh or POST /api/v1/graph/seed as admin.
Memory search returns irrelevant results
Qdrant not ingested. Run: bash scripts/start-demo.sh or POST /api/v1/memory/ingest-all as engineer+.
Risk heatmap shows all green
Risk not calculated. Run: POST /api/v1/risk/recalculate as admin.
Map shows grid instead of Mapbox
NEXT_PUBLIC_MAPBOX_TOKEN not set. All features work in fallback mode.
Agent investigation hangs
60-second timeout active. Check OPENAI_API_KEY validity.
WebSocket not connecting
Ensure NEXT_PUBLIC_WS_URL matches backend URL. Default: http://localhost:3001
Stale build / UI errors after code changes
Clear Next.js cache: rm -rf apps/web/.next then restart frontend.
MIT © RailMind 2024