Prerequisites
Ensure you have installed:- Python 3.11+ (Backend)
- Node.js 18+ and npm (Frontend)
- Git
- InfluxDB Cloud account (or local InfluxDB 2.x)
Backend Setup
The backend is built with FastAPI and requires a Python virtual environment.Create virtual environment
Create an isolated Python environment:
Your terminal prompt should now show
(venv) indicating the virtual environment is active.Install dependencies
Install all required Python packages:This installs:
- FastAPI: Web framework
- Uvicorn: ASGI server
- InfluxDB Client: Time-series database connector
- Scikit-learn: Machine learning (Isolation Forest)
- Pandas & NumPy: Data processing
- ReportLab & OpenPyXL: PDF/Excel report generation
- Pydantic: Data validation
Configure environment variables
Create Edit
.env file from the example:backend/.env with your InfluxDB credentials:Start the development server
Run the FastAPI application with hot-reload:The server will start on http://localhost:8000
The
--reload flag enables auto-restart when code changes are detected. Remove it for production.Verify installation
Test the backend in a new terminal:Expected response:Or visit the interactive API docs at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Frontend Setup
The frontend is built with React 18, Vite, and Recharts for real-time visualization.Install dependencies
Install all Node.js packages:This installs:
- React 18: UI framework
- Vite: Build tool and dev server
- Recharts: Real-time charting library
- Axios: HTTP client
- React Router: Navigation (if used)
Configure environment (optional)
Create Edit
.env.local if you need custom API URL:frontend/.env.local:By default, the frontend assumes the backend is at
http://localhost:8000. Only create this file if using a different URL.Start the development server
Launch the Vite dev server with hot module replacement:The frontend will start on http://localhost:5173
Access the dashboard
Open your browser and navigate to:http://localhost:5173You should see the Predictive Maintenance dashboard with:
- Real-time sensor metrics
- Health score visualization
- Anomaly detection charts
- System control panel
Development Workflow
Running Both Services
For active development, run both backend and frontend concurrently:-
Terminal 1 (Backend):
-
Terminal 2 (Frontend):
Hot Reload Behavior
- Backend: Uvicorn automatically restarts when Python files change
- Frontend: Vite hot-reloads React components without full page refresh
Testing the System
Running Tests
The project includes 182 unit tests covering all major components.Data Generation for Testing
Use the built-in data generator to simulate sensor readings:Troubleshooting
Backend Issues
ModuleNotFoundError: No module named ‘backend’
Solution: EnsurePYTHONPATH includes the project root:
InfluxDB Connection Failed
Solution: Verify credentials inbackend/.env:
Port 8000 Already in Use
Solution: Kill the existing process:Frontend Issues
API Connection Error
Problem:Network Error in browser console
Solution: Verify backend is running:
backend/api/main.py:
npm install Fails
Problem: Package installation errors Solution: Clear cache and reinstall:Port 5173 Already in Use
Solution: Vite will automatically try the next available port (5174, 5175, etc.). Or specify a port:Windows-Specific Issues
Python Virtual Environment Won’t Activate
Problem: PowerShell execution policy error Solution: Allow script execution:Next Steps
- Explore Docker Deployment for containerized development
- Learn about Production Deployment for cloud hosting
- Review the Architecture to understand system components
- Check the API Reference for integration details