Real-Time Location Tracker is a modular event-driven system that continuously tracks user locations from a frontend app, streams the data to a Go backend, and publishes it to Kafka for real-time processing. Custom Kafka consumers handle features like geo-fencing alerts, proximity detection, and location logging, making it ideal for learning Kafka, Go, and real-time architectures.
The project is built to learn kafka.
This is a initial version.
I have built a simple extension for location logging.
In the future, based on circumstances i may continue to build it.
I have used both fiber and gin since it was build on different timings. And i was learning.
If you are locally running the project use docker.
- Real-time location tracking from frontend
- Backend API with Go Fiber to receive & validate dataQ
- Kafka integration using
segmentio/kafka-go - Plug-and-play Kafka consumers:
- Geo-fencing alerts
- Meetup proximity detection
- Location logging to file
- Real-time updates to frontend via SSE
- auth :3001
- client:5173
- gateway:8080
- server:5000
- geo-fencer:3002
- alert:3003
Most preferred way. Since the docker-compose.yml is perfectly composed.
docker compose up -dThis project uses Devbox to manage development dependencies and ensure a consistent environment across different machines.
curl -fsSL https://get.jetpack.io/devbox | bashdevbox shellThis automatically installs and configures all required tools:
- Go (latest)
- Node.js 20
- Kubernetes tools (kubectl, kind, k9s, helm, kustomize)
- Task runner (go-task)
- Other utilities (gh, jq, yq, envsubst)
Once in the devbox shell, you can use task commands (see Taskfile section below) for Kubernetes operations.
The project uses Task to automate common operations. Taskfile provides convenient shortcuts for Kubernetes management.
Task is automatically installed when you enter the devbox shell. If not using devbox:
# macOS
brew install go-task/tap/go-task
# Linux
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
# Or via npm
npm install -g @task/cliKind Cluster:
task kind:create-cluster # Create Kubernetes cluster
task kind:enable-loadbalancer # Enable LoadBalancer (keep running)
task kind:delete-cluster # Delete clusterKubernetes Resources:
task k8s:apply-all # Apply all resources
task k8s:delete-all # Delete all resources
task k8s:apply-namespace # Create namespace
task k8s:apply-secrets # Apply secrets
task k8s:apply-configmap # Apply ConfigMap
task k8s:apply-databases # Apply PostgreSQL & Kafka
task k8s:apply-services # Apply services
task k8s:apply-deployments # Apply deploymentsStatus & Debugging:
task k8s:get-all # Show all resources
task k8s:get-pods # List pods
task k8s:get-services # List services
task k8s:logs POD=gateway-xxx # Stream pod logsPort Forwarding:
task k8s:port-forward-gateway # Forward gateway (8080)
task k8s:port-forward-auth # Forward auth service
task k8s:port-forward-server # Forward server serviceSee taskfile.yaml for all available commands.
Need to change the docker-compose.yml and .env files to suit running the code locally.
git clone https://github.com/jsndz/safetrace
cd safetracecd cmd/server
go run main.goEach consumer can be run independently. For example:
cd location_logger
go run main.gocd geo-fencer
go run cmd/server/main.gocd alert
go run cmd/server/main.gocd auth
go run cmd/server/main.gocd client
npm install
npm run devThe project uses Kind (Kubernetes in Docker) for local Kubernetes development. Configuration is managed via Taskfile and Devbox.
- Docker installed and running
- Devbox shell (recommended) or manually install: kind, kubectl
-
Enter Devbox shell (recommended):
devbox shell
-
Create Kind cluster:
task kind:create-cluster
This creates a 3-node cluster (1 control-plane, 2 workers) as configured in
kind-config.yaml. -
Enable LoadBalancer support:
task kind:enable-loadbalancer
This runs
cloud-provider-kindto enable LoadBalancer services in KinD.Important: Keep this process running (or run in background). This is required for LoadBalancer services.
-
Apply all Kubernetes resources:
task k8s:apply-all
This creates:
- Namespace:
safetrace - Secrets and ConfigMaps
- PostgreSQL databases (for auth and geo-fencer services)
- Kafka (StatefulSet with persistent storage)
- All microservices (gateway, auth, server, geo-fencer, alert, logger)
- Services for internal communication
- Namespace:
-
Verify deployment:
task k8s:get-all # Or check specific resources: task k8s:get-pods task k8s:get-servicesWait for all pods to be in
Runningstate:kubectl get pods -n safetrace -w
-
Access the services:
Option A: Port Forward Gateway
task k8s:port-forward-gateway
Then access at
http://localhost:8080Option B: Use LoadBalancer (if LoadBalancer provider is running)
kubectl get svc -n safetrace # Gateway service should have an external IP
Deployment Management:
# Restart a deployment
task k8s:rollout-restart DEPLOYMENT=gateway
# Check rollout status
task k8s:rollout-status DEPLOYMENT=gatewayView Logs:
# Get pod name first
task k8s:get-pods
# Stream logs
task k8s:logs POD=gateway-xxx-xxxPort Forwarding:
task k8s:port-forward-gateway # Gateway on :8080
task k8s:port-forward-auth # Auth on :8081
task k8s:port-forward-server # Server on :8082# Delete all Kubernetes resources
task k8s:delete-all
# Delete the Kind cluster
task kind:delete-clusterPods not starting:
# Check pod status and events
task k8s:describe RESOURCE_TYPE=pod RESOURCE_NAME=<pod-name>
# View logs
task k8s:logs POD=<pod-name>
# Check all resources
task k8s:get-allServices not accessible:
- Ensure LoadBalancer provider is running:
task kind:enable-loadbalancer - Check service endpoints:
kubectl get endpoints -n safetrace - Verify service selectors match pod labels
Database connection issues:
- Wait for PostgreSQL pods to be ready
- Check database credentials in secrets:
kubectl get secrets -n safetrace - Verify ConfigMaps:
kubectl get configmaps -n safetrace
Kafka not working:
- Ensure Kafka StatefulSet is ready:
kubectl get statefulset -n safetrace - Check Kafka service:
kubectl get svc kafka-service -n safetrace - View Kafka pod logs:
task k8s:logs POD=kafka-0
If you prefer Minikube instead of Kind:
-
Start Minikube:
minikube start
-
Enable Ingress:
minikube addons enable ingress -
Deploy resources:
task k8s:apply-all
-
Start Minikube tunnel (for LoadBalancer services):
minikube tunnel
-
Access via Ingress (if configured):
- Edit
/etc/hosts:127.0.0.1 safetrace.local - Access:
http://safetrace.local
- Edit
| Extension | Description |
|---|---|
| Geo-Fence Checker | Sends alert if user exits allowed area |
| Location Logger | Stores location history in file |
location– main topic for location updatesalerts– triggered by consumers like GeoFence
- Frontend: React + Vite
- Backend: Go + Fiber + Kafka producer
- Messaging: Apache Kafka (via
kafka-go) - DB: Postgres
- Notification: SSE
- Kafka producer-consumer pattern
- Event-driven architecture
- Real-time geospatial data processing
- Modular backend service design in Go
- kafka lets you have multiple consumers
- make the consumers scale horizontally by increasing partitions and consumers
- Each consumer can be grouped if all consumers in a single group queue different group pub-sub
- high throughput
- rewinding option is available
- SSE
Pull requests welcome. Fork the repo, create a new branch, and submit a PR.
Built by jsndz



