How h-rathod/ai-predictive-maintenance works
Project type and purpose
• This is a full-stack mobile application (“AI Predictive Maintenance”) composed of a React Native + Expo frontend (“SensorDashboard”) and a Node.js + Express backend (“chatbot-backend”).
• Purpose: allow users to monitor IoT sensor data, view historical charts, and pose natural-language questions via a chatbot that uses OpenAI and Supabase.
File structure
• Top-level folders:
• SensorDashboard/ – Expo React Native app
• chatbot-backend/ – Express server
• SensorDashboard/src:
• screens/ – UI screens (Dashboard, Graph, Chatbot, etc.)
• utils/ – theme context, Supabase client, anomaly & sensor utilities
• chatbot-backend/src:
• controllers/ – request handlers (chatController)
• services/ – OpenAI integration, Supabase data access
• config/ – environment & constants
• utils/ – seed scripts
• Key configs & build scripts: app.json, babel.config.js, package.json, .env samples.
README for additional insights
• Frontend uses Expo, React Navigation, Victory Native (charts), Gifted Chat, Supabase client.
• Backend uses Express, OpenAI API, Supabase client, CORS, body-parser, health-check endpoint.
• Supabase PostgreSQL holds a sensor_history table.
a. Main components:
• Mobile Client (SensorDashboard)
• REST API Server (chatbot-backend)
• Supabase Database (PostgreSQL)
• OpenAI External Service API
• (Optional) Authentication / Env. config service
b. Relationships & data flows:
1. Mobile Client ↔ Supabase – direct reads for real-time & historical sensor data (via Supabase JS client).
2. Mobile Client → REST API – chatbot queries and health check.
3. REST API → Supabase – fetch sensor data for NL queries.
4. REST API → OpenAI – forward user queries, receive AI-driven responses.
5. REST API → Mobile Client – return JSON responses to display in Gifted Chat.
c. Architectural patterns & design principles:
• Separation of concerns: UI screens vs. data-access vs. business logic
• “Service” modules in backend for external integrations (OpenAI, Supabase)
• React Context (ThemeContext) and Hooks for state & theming in frontend
• RESTful API layer for natural-language chatbot interactions
d. Key technologies & libraries:
• Frontend: Expo, React Navigation, Victory Native, React Native Paper, Gifted Chat, @env, Supabase JS
• Backend: Node.js, Express, OpenAI SDK, Supabase JS, CORS, body-parser
Essential elements
• Component labels and purpose