A full-stack telemetry and metrics platform for racecar data visualization and management. Built with FastAPI, React, InfluxDB, and Grafana, this system provides real-time data ingestion, storage, visualization, and user authentication.
The platform consists of several microservices:
- Frontend: React + TypeScript + Vite application
- Backend API: FastAPI server for data ingestion
- Auth Service: Separate authentication microservice with JWT tokens
- InfluxDB: Time-series database for telemetry data
- Grafana: Data visualization and dashboard service
- Nginx: Reverse proxy and SSL termination (production)
- User Authentication: JWT-based authentication with role-based access control (authorization levels)
- Data Ingestion: REST API endpoints for writing telemetry data to InfluxDB
- Real-time Visualization: Embedded Grafana dashboards for data visualization
- Authorization Levels: Level-based permissions (Level 5 required for write operations)
- Secure Production Deployment: SSL/TLS support with Let's Encrypt integration
- Rate Limiting: API rate limiting to prevent abuse
- Docker and Docker Compose
- Node.js (for local frontend development)
- Python 3.x (for local backend development)
-
Clone the repository
git clone <repository-url> cd metrics
-
Create environment file Create a
.envfile in the root directory, follow .env.example -
Start all services
docker-compose up -d
-
Access the services
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- Auth Service: http://localhost:8001
- Grafana: http://localhost:3000
- InfluxDB: http://localhost:8086
-
Configure SSL certificates
./init-letsencrypt.sh
-
Start production services
docker-compose -f docker-compose-prod.yml up -d
-
Access via HTTPS
- Application: https://your-domain.com
- API: https://your-domain.com/api/
- Auth: https://your-domain.com/auth/
-
POST /register- Register a new user{ "username": "string", "password": "string" } -
POST /login- Login and receive JWT token{ "username": "string", "password": "string" } -
GET /me- Get current user information (requires authentication)
All endpoints require authentication and authorization level 5.
-
POST /write- Write custom data point to InfluxDB{ "measurement": "string", "tags": { "key": "value" }, "fields": { "key": "value" } } -
POST /write-graph- Write graph data point{ "timestamp": 1234567890, "value": 42.5 } -
POST /write-simple- Write simple test messageQuery parameter: query=string
The system uses a level-based authorization system:
- Level 1: Default level for new users (read-only access)
- Level 5: Required for write operations to InfluxDB
- React 19
- TypeScript
- Vite
- React Router
- TanStack Query
- FastAPI
- Python 3
- InfluxDB Client
- SQLAlchemy
- JWT Authentication (python-jose)
- Uvicorn
- Docker & Docker Compose
- Nginx (reverse proxy)
- Let's Encrypt (SSL certificates)
- InfluxDB 2.x
- Grafana
metrics/
├── backend/ # Backend API service
│ ├── server.py # Main FastAPI application
│ ├── influx.py # InfluxDB client utilities
│ ├── auth_utils.py # JWT verification utilities
│ └── auth/ # Auth microservice
│ ├── app.py # Auth FastAPI application
│ ├── models.py # Database models
│ ├── database.py # Database configuration
│ └── utils.py # Auth utilities
├── frontend/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── contexts/ # React contexts (Auth)
│ │ ├── api/ # API client utilities
│ │ └── Pages/ # Page components
│ └── public/
├── nginx/ # Nginx configuration
│ └── nginx.conf # Production reverse proxy config
├── docker-compose.yml # Development compose file
├── docker-compose-prod.yml # Production compose file
└── grafana.ini # Grafana configuration
- Organization:
racecar - Bucket:
telemetry - Default admin credentials:
admin/password123(change in production!)
- Default admin credentials:
admin/admin - Anonymous access enabled for viewers
- Embedding allowed for iframe integration
All sensitive configuration should be set via environment variables or .env file.
- All ports exposed for direct access
- Hot-reload enabled for frontend and backend
- Volume mounts for live code updates
- Services exposed only through Nginx reverse proxy
- SSL/TLS termination
- Automatic certificate renewal
- Rate limiting enabled
- User authenticates via
/auth/loginand receives JWT token - Frontend stores token and includes it in subsequent requests
- Backend verifies token and authorization level
- Authorized requests write data to InfluxDB
- Grafana visualizes data from InfluxDB
- Frontend embeds Grafana dashboards
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
- Verify
INFLUXDB_TOKENand connection settings - Check if InfluxDB container is running:
docker ps - View logs:
docker logs racecar-influxdb
- Ensure
SECRET_KEYis consistent across backend and auth services - Check auth service logs:
docker logs racecar-auth - Verify token is being sent in Authorization header
- Check if all services are running:
docker-compose ps - Verify environment variables are set correctly
- Check browser console for errors