AlertCircle is a real-time, location-based alert system that allows users to report several sightings — such as officers issuing tickets — and instantly notify others nearby. Designed for community-driven awareness, it leverages Apache Kafka, Spark, MongoDB, Airflow, and AWS to deliver alerts, with live map, and a notification feed.
- ⚡ Real-time stream processing using Apache Kafka and Spark
- 🌍 Location-based enrichment with MongoDB geospatial queries
- ⏱️ Airflow DAG running every minute to simulate active users
- 💾 Amazon S3 integration for archiving enriched alerts
- 🗺️ Streamlit dashboard for live map and alert feed
- ☁️ Hybrid architecture with EC2 and local services
AlertCircle/
│
├── airflow/ # Airflow DAGs
└── update_user_locations.py
│ └── dags/
│ └── update_user_locations_dag.py
│
├── kafka/ # Kafka producers and consumers
│ └── user_report_simulator.py
│ └── enriched_alerts_to_mongo.py
│
├── spark/ # Spark structured streaming job
│ └── process_alerts_stream.py
│
├── streamlit_app/ # Streamlit real-time dashboard
│ └── streamlit_live_map_app.py
│
├── requirements.txt
├── README.md
└── .gitignore
- Simulated users send alerts every 10 seconds
- Published to Kafka topic:
raw_alerts
- Consumes
raw_alerts - Enriches alerts with nearby users from MongoDB within 500 meters from the alert point
- Publishes to:
- Kafka topic:
enriched_alerts - S3 bucket:
enriched-alerts
- Kafka topic:
- Runs every 1 minute
- Simulates active users and locations
- Writes to MongoDB:
latest_user_location(TTL = 5 minutes)
- Consumes from
enriched_alerts - Writes to MongoDB:
alerts_live(TTL = 10 minutes)
- Connects to
alerts_liveMongoDB collection - Shows:
- Real-time alert map for visualize
- Live notification feed for users notifications simulation
If you're deploying the backend infrastructure on an EC2 instance, you can use Docker Compose for setup.
Make sure your EC2 has:
- Docker installed
- Docker Compose installed
- The
docker-compose.yamlfile cloned in the project root
cd alertcircle
docker compose up -dThis will start:
- Kafka & Zookeeper
- MongoDB
- Airflow (webserver + scheduler + PostgreSQL)
dev_envcontainer for development
✅ After the containers are running:
- Airflow UI will be accessible via
http://<your-ec2-public-ip>:8082 - MongoDB and Kafka will be available to local services (ensure security group allows connections)
MongoDB collections and indexes must be created before the system can function properly.
A Mongo shell script is provided to create:
- The
AlertCircleProjectdatabase - Two collections:
alerts_liveandlatest_user_location - All required indexes:
- TTL indexes for automatic cleanup
- 2dsphere geospatial indexes
- Optional compound indexes for performance
The script is called init_alertcircle_db.js and is located in the root of this repository.
From inside your EC2 or Mongo shell:
mongo < init_alertcircle_db.js- Python 3.10+
- Kafka + Zookeeper running
- MongoDB running
- AWS credentials if writing to S3
pip install -r requirements.txtpython kafka/user_report_simulator.pypython spark/process_alerts_stream.pypython kafka/enriched_alerts_to_mongo.pystreamlit run streamlit_app/streamlit_live_map_app.py✅ Airflow is already running on EC2 and updating user locations every minute.
Due to local hardware limitations, this system uses a hybrid deployment model:
- EC2 instance hosts:
- MongoDB
- Apache Airflow (scheduling DAG)
- Kafka & Zookeeper
- Local machine runs:
- Spark job for stream processing
- Kafka producers and consumers
- Streamlit live dashboard
- Developing a mobile app based on this project as a backend
- Setting up fully on EC2 with Docker
- Expanding alerts options to additional types such as parking inspector
- User authentication & notification preferences
- Historical data analytics with AWS Athena/ETL to a DWH -> BI Tool for dashboards
- Adding tests, error handling, logs, failure plans
Maintained by Nivshitz
For feedback, questions or collaboration – feel free to reach out!
🛡️ Built as a final project for the Cloud & Big Data Engineering course @ Naya College

