From Streaming Data to Live Dashboard using Kafka, FastAPI, PostgreSQL & Valkey
🌍 How This All Started (Aiven + Inspiration)
A few days ago, while scrolling through social media, I came across something exciting…
👉 A challenge by Aiven — the #AivenFreeTier competition.
And honestly… it immediately caught my attention.
Why?
Because they are offering something that every developer dreams of:
💡 Real cloud infrastructure — completely FREE — with no credit card, no trial expiration.
⚡ What Makes Aiven So Exciting?
At Aiven, the philosophy is simple:
“The best way to learn is by building real systems.”
And they truly mean it.
🔥 Their Free Tier Includes:
- Apache Kafka → Real-time data streaming
- PostgreSQL → Powerful, production-grade database
- MySQL → Classic web database
- Valkey → Ultra-fast caching (Redis alternative)
✨ And the best part:
- No credit card
- No expiry
- Fully managed
- Ready for real-world projects
🏆 The Challenge That Hooked Me
The competition is simple but powerful:
- Build something cool using Aiven services
- Share your journey publicly
- Tell your story (not just code!)
- Use #AivenFreeTier
And…
💰 Win $1000 for the most compelling project
✨ Why I Built This Project
Instead of just reading about distributed systems, I asked myself:
🤔 “Can I actually build a real-time system like companies use in production?”
That curiosity led me to build something ambitious:
✈️ A Real-Time Flight Anomaly Detection System
🎯 The Problem
In aviation systems:
- Aircraft continuously send telemetry data
- Engineers must monitor everything in real-time
- Failures must be detected instantly
❌ Challenges:
- High-volume streaming data
- Real-time processing required
- No data loss allowed
- Dashboard must always stay in sync
💡 My Solution
I built an event-driven, real-time system powered by Aiven cloud services.
✔️ What it does:
- Generates synthetic flight telemetry data
- Streams data using Kafka
- Detects anomalies instantly
- Stores history in PostgreSQL
- Caches live data using Valkey
- Displays everything on a real-time dashboard
⚠️ Note: This uses synthetic/sample data, not real aircraft data.
🧠 Architecture Overview
🔄 End-to-End Flow
- FastAPI generates flight data
- Data is sent to Kafka
- Consumer processes events
- Anomalies detected
- Stored in PostgreSQL
- Cached in Valkey
- WebSocket pushes updates
- Dashboard updates instantly
📸 Screenshots
🖥️ Real-Time Dashboard
Live flight tracking, alerts, and graphs
☁️ Aiven Cloud Services
Managed Kafka, PostgreSQL & Valkey
📡 Kafka Streaming
Real-time event flow
⚙️ Tech Stack
- FastAPI → Backend
- Apache Kafka → Streaming
- PostgreSQL → Storage
- Valkey → Cache
- Chart.js → Visualization
- Aiven → Managed Cloud
🔥 Why Aiven Made This Easy
Without Aiven, setting up all this would mean:
❌ Manual Kafka setup
❌ Database provisioning
❌ Scaling issues
❌ DevOps overhead
But with Aiven:
✅ Ready-to-use services
✅ Secure connections
✅ Zero setup complexity
✅ Focus on building, not infrastructure
🔥 Key Features
✅ Real-Time Streaming
Powered by Kafka
✅ Live Dashboard
WebSocket-based instant updates
✅ Fault Tolerance
- Auto reconnect
- Data recovery
- No refresh loss
✅ Smart Visualization
- Continuous graphs
- Stable colors
- Smooth rendering
✅ Multi-Alert System
Tracks multiple anomalies simultaneously
🧩 Core Logic Example
Risk Calculation
def calculate_risk(data):
score = 0
if data["altitude"] < 25000:
score += 30
if data["speed"] > 850:
score += 25
if data["engine_status"] == "FAIL":
score += 50
if data["fuel_level"] < 20:
score += 20
return min(score, 100)
📊 Why This Feels Like a Real System
This is not just a demo:
- Event-driven architecture
- Real-time streaming
- Fault-tolerant design
- Cloud-native services
- Scalable approach
📁 Project Structure
flight-anomaly-system/ │ ├── src/ │ ├── api/ │ │ ├── main.py # FastAPI + WebSocket + generator │ │ └── kafka_producer.py │ │ │ ├── consumer/ │ │ └── kafka_consumer.py # Anomaly detection │ │ │ ├── db/ │ │ └── db.py │ │ │ ├── cache/ │ │ └── cache.py │ │ │ └── dashboard/ │ │ └── index.html # Real-time UI │ │ │ └── certs/ │ │ ├── kafka/ │ │ └── postgres/ │ │ │ ├── images/ │ └── aeropulse.png │ ├── .env ├── requirements.txt └── README.md
🚀 How to Run
uvicorn src.api.main:app --reload
python -m src.consumer.kafka_consumer
🔗 GitHub
👉 repo:
https://github.com/obulareddynew/flight-anomaly-system.git
🏆 What I Learned
- Real-time system design
- Kafka pipelines
- WebSocket architecture
- Cloud service integration
- Debugging production issues
🚀 Future Plans
- ML anomaly detection
- Replay system
- Kubernetes deployment
- Observability tools
💬 Final Thoughts
This project started with:
👉 A simple scroll on social media
👉 A spark from Aiven
👉 And a curiosity to build something real
And it turned into:
💥 A complete real-time system built on cloud infrastructure
🎯 My Goal
- Master real-time systems
- Build production-grade projects
- And yes…
🏆 Win the #AivenFreeTier challenge
🙌 Let’s Connect
If you found this interesting:
- ⭐ Star the repo
- 💬 Share feedback
- 🚀 Build your own version
✨ “Learning by building real systems is the fastest way to grow — and Aiven made that possible.”
Comments
Post a Comment