Project Locus is a complete, event-driven backend system designed to track a fleet of vehicles in real-time and generate alerts when they enter or exit user-defined geographic boundaries (geofences). The system is built using a modern microservices architecture, is fully containerized with Docker, and is deployed on AWS. This project demonstrates a deep understanding of Go, concurrency, real-time messaging with MQTT, REST API design, and cloud infrastructure management.
The system consists of several independent Go services that communicate asynchronously via an MQTT message broker and a shared PostgreSQL database.
Youtube Demo: LINK
- Language: Go
- Messaging: MQTT (Eclipse Mosquitto Broker)
- Database: PostgreSQL with the PostGIS extension for geospatial queries.
- API: RESTful API built with the
chirouter. - Infrastructure: Docker, Docker Compose
- Cloud Provider: Amazon Web Services (AWS)
- Compute: EC2 (
t2.micro) - Networking: VPC, Security Groups
- Compute: EC2 (
- Real-Time Location Ingestion: The
location-servicesubscribes to MQTT topics and persists vehicle location data to the database. - Dynamic Geofence Management: A REST API (
api-service) allows for creating, viewing, and deleting polygonal geofences. - Stateful Event Engine: The
geofence-servicetracks the state of each vehicle, using PostGIS to perform efficient geospatial calculations and detect when a vehicle enters or exits a geofence. - Event-Driven Alerts: Generates new MQTT messages on a separate topic (
locus/geofence/events) for every detected enter/exit event. - Scalable Simulation: The
vehicle-simulatoruses goroutines to simulate a configurable number of vehicles concurrently. - Cloud Deployed: The entire backend stack is containerized and deployed to an AWS EC2 instance.
- Prerequisites: Go, Docker, Docker Compose installed.
- Clone the repository:
git clone ... - Create a
.envfile from the project root (see.env.exampleif available). - Start the infrastructure:
docker-compose up -d - Run the services in separate terminals:
go run ./cmd/api-service/main.go go run ./cmd/location-service/main.go go run ./cmd/geofence-service/main.go
- Create a geofence (see API Usage section).
- Run the simulator:
go run ./cmd/vehicle-simulator/main.go
The application is deployed on an EC2 instance and managed via Docker Compose.
- Set up an EC2 instance with Docker, Docker Compose, and Git installed.
- Configure the security group to allow inbound traffic on ports 22 (SSH), 80 (HTTP), and 1883 (MQTT).
- Clone the repository onto the instance.
- Create the
.envfile on the server. - Run the backend stack:
sudo docker-compose -f docker-compose.deploy.yml up -d - To test, run the vehicle simulator from a local machine with the
MQTT_BROKER_HOSTenvironment variable set to the EC2 instance's public IP.
- Endpoint:
POST /api/v1/geofences - Method:
POST - Body (raw JSON):
{ "type": "Feature", "properties": { "name": "downtown-la" }, "geometry": { "type": "Polygon", "coordinates": [ [ [-118.25, 34.04], [-118.23, 34.04], [-118.23, 34.06], [-118.25, 34.06], [-118.25, 34.04] ] ] } }
- Endpoint:
GET /api/v1/geofences - Method:
GET - Returns: A JSON array of all geofences in the database.