Skip to content

About

Real-time IoT analytics platform with Go, Kafka, and React

Resources

Stars

0 stars

Watchers

0 watching

Forks

Β 
Β 

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌑️ IoT Analytics Dashboard

A real-time IoT analytics platform built with Go, Apache Kafka, and React. This system simulates IoT devices, processes telemetry data using stream processing, and visualizes metrics through an interactive dashboard.

Dashboard Preview Go React Kafka

🎯 Features

  • Real-time Data Streaming: Apache Kafka message broker
  • Stream Processing: 1-minute windowed aggregations
  • REST API: Go-based API server
  • Interactive Dashboard: React frontend with live charts
  • Scalable Architecture: Microservices design
  • Docker Support: Easy setup with Docker Compose

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Producer   β”‚ ───▢ β”‚  Kafka   β”‚ ───▢ β”‚ Aggregator β”‚ ───▢ β”‚  Kafka   β”‚
β”‚ (5 devices) β”‚      β”‚  (raw)   β”‚      β”‚ (windows)  β”‚      β”‚  (agg)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                  β”‚
                                                                  β–Ό
                                                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                           β”‚  API Server  β”‚
                                                           β”‚  (REST API)  β”‚
                                                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                  β”‚
                                                                  β–Ό
                                                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                           β”‚   Frontend   β”‚
                                                           β”‚   (React)    β”‚
                                                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

πŸ€– Automated Scripts

One-Command Setup

# Complete setup (installs dependencies, starts Kafka)
./scripts/setup.sh

Using Makefile

# See all available commands
make help

# Install dependencies
make install

# Start Kafka
make kafka-up

# Run individual services
make producer      # Terminal 1
make aggregator    # Terminal 2
make api           # Terminal 3
make frontend      # Terminal 4

# Check service status
make status

# Run all backend services at once
make all

# Run tests
make test

# Stop Kafka
make kafka-down

Helper Scripts

# Complete automated setup
./scripts/setup.sh

# Check all service status
./scripts/check-status.sh

# Test API endpoints
./scripts/test-api.sh

# Start all services (requires tmux)
./scripts/start-all.sh

Prerequisites

Installation

  1. Clone the repository
git clone https://github.com/berylm1/iot-analytics-dashboard.git
cd iot-analytics-dashboard
  1. Start Kafka
docker-compose up -d
  1. Install Go dependencies
go mod download
  1. Install Frontend dependencies
cd frontend
npm install
cd ..

Running the Application

Open 4 separate terminals:

Terminal 1 - Producer:

go run cmd/producer/main.go

Terminal 2 - Aggregator:

go run cmd/aggregator/main.go

Terminal 3 - API Server:

go run cmd/api/main.go

Terminal 4 - Frontend:

cd frontend
npm start

Access the Dashboard

Open your browser to: http://localhost:3000

πŸ“Š API Endpoints

Endpoint Method Description
/health GET Health check
/api/aggregations GET Get recent aggregations (query: ?limit=N)
/api/aggregations/latest GET Get most recent aggregation
/api/stats GET Get overall statistics

Example API Calls

# Health check
curl http://localhost:8080/health

# Get latest data
curl http://localhost:8080/api/aggregations/latest

# Get last 10 aggregations
curl "http://localhost:8080/api/aggregations?limit=10"

# Get statistics
curl http://localhost:8080/api/stats

πŸ“ Project Structure

iot-analytics-dashboard/
β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ producer/       # IoT device simulator
β”‚   β”œβ”€β”€ aggregator/     # Stream processor
β”‚   └── api/            # REST API server
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ models/         # Data models
β”‚   β”œβ”€β”€ api/            # HTTP handlers
β”‚   └── storage/        # In-memory storage
β”œβ”€β”€ frontend/           # React dashboard
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.js      # Main component
β”‚   β”‚   └── App.css     # Styles
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yml  # Kafka infrastructure
β”œβ”€β”€ go.mod
└── README.md

πŸ”§ Configuration

Default configuration (modify in source code):

Component Config Default
Kafka Broker Address localhost:9092
API Server Port 8080
Producer Devices 5
Producer Interval 2 seconds
Aggregator Window 1 minute
Frontend Port 3000

πŸ› οΈ Technology Stack

Backend

  • Go - High-performance backend services
  • Apache Kafka - Distributed event streaming
  • segmentio/kafka-go - Kafka client library
  • gorilla/mux - HTTP router
  • rs/cors - CORS middleware

Frontend

  • React - UI framework
  • Recharts - Data visualization
  • Axios - HTTP client

Infrastructure

  • Docker - Containerization
  • Zookeeper - Kafka coordination

πŸ“ˆ Data Flow

  1. Producer generates simulated IoT telemetry (temperature, humidity)
  2. Kafka receives and distributes raw telemetry data
  3. Aggregator consumes raw data, computes 1-minute window statistics
  4. Kafka receives aggregated metrics
  5. API Server consumes aggregated data and exposes REST endpoints
  6. Frontend fetches and visualizes data every 30 seconds

πŸ§ͺ Testing

# Run Go tests
go test ./...

# Test API endpoints
curl http://localhost:8080/health
curl http://localhost:8080/api/stats

🐳 Docker Commands

# Start Kafka and Zookeeper
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

# Remove volumes
docker-compose down -v

πŸ“ Development

Adding New Features

  1. New API endpoint: Add handler in internal/api/handlers.go
  2. New data model: Update internal/models/models.go
  3. New chart: Modify frontend/src/App.js

Debugging

# Check Kafka topics
docker exec kafka kafka-topics --list --bootstrap-server localhost:9092

# View Kafka messages
docker exec kafka kafka-console-consumer \
  --bootstrap-server localhost:9092 \
  --topic iot-telemetry-raw \
  --from-beginning

πŸš€ Future Enhancements

  • WebSocket support for real-time updates
  • PostgreSQL/MongoDB for data persistence
  • User authentication and authorization
  • Alert system for threshold violations
  • Device management dashboard
  • Historical data analysis
  • Kubernetes deployment
  • Grafana integration
  • Multi-tenant support

πŸ“„ License

MIT License - feel free to use this project for learning or commercial purposes.

πŸ‘€ Author

Beryl Malomo

πŸ™ Acknowledgments

  • Apache Kafka for event streaming
  • React community for excellent documentation
  • Go community for great libraries

⭐ Star this repo if you find it helpful!

About

Real-time IoT analytics platform with Go, Kafka, and React

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages