Skip to content

Ashish-Reddy-T/GreenLane

Repository files navigation

GreenLane βš‘πŸš—

A distributed, high-frequency energy negotiation engine for autonomous EV fleets using event-driven architecture.

Status: βœ… Steel Thread Prototype Complete
Demo Ready: Full end-to-end data flow implemented

What Is This?

GreenLane solves the "Thundering Herd" problem for autonomous EV fleets competing for limited charging infrastructure. It demonstrates production-grade distributed systems patterns:

  • High-throughput ingestion (5k+ events/sec)
  • Geospatial indexing (Redis GEO commands)
  • Event-driven architecture (Kafka/Redpanda)
  • Time-series analytics (TimescaleDB hypertables)
  • Real-time monitoring (Live Ops CLI)

Quick Start

Option 1: Automated Setup

./quickstart.sh

Option 2: Manual Setup

Prerequisites

  • Docker & Docker Compose
  • Go 1.23+ (install)
  • Rust (install)
  • Python 3.10+
  • Protocol Buffers compiler (brew install protobuf)

Start Services

# 1. Start infrastructure (Redis, Redpanda, TimescaleDB)
make up

# 2. Generate protobuf code
make proto
cd simulator && ./generate_proto.sh && cd ..

# 3. Install Python dependencies
cd simulator && pip3 install -r requirements.txt && cd ..

# 4. Run the steel thread (open 5 terminals):
# Terminal 1:
make dev-mock-grid

# Terminal 2:
make dev-ingestion

# Terminal 3:
cd services/pricing-worker && RUST_LOG=info cargo run --release

# Terminal 4:
make dev-cli

# Terminal 5:
make dev-simulator

What You'll See

Live Ops CLI Output

╔═══════════════════════════════════════════════════════════════╗
β•‘                    πŸš— GreenLane Live Ops CLI                  β•‘
β•‘                   Real-Time Fleet Monitoring                  β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

[20:15:32] 🟒 CAR-001    | Battery:  85.3% | Location: (40.7234, -73.9876) | Speed: 45.2 km/h
[20:15:32] 🟑 CAR-002    | Battery:  42.7% | Location: (40.7456, -73.9654) | Speed: 23.1 km/h
[20:15:32] πŸ”΄ CAR-003    | Battery:  12.1% | Location: (40.7123, -73.9987) | Speed:  8.3 km/h ⚠️  CRITICAL BATTERY!

Access Points

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  gRPC Stream   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   GEOADD    β”Œβ”€β”€β”€β”€β”€β”€β”€β”
β”‚ EV Fleet    │───────────────>β”‚  Ingestion   │────────────>β”‚ Redis β”‚
β”‚ (Simulator) β”‚  Auth Token    β”‚  Service(Go) β”‚   HSET      β”‚  GEO  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜             β””β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚ Emit Event
                                      β–Ό
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚   Redpanda     β”‚
                              β”‚ (Kafka API)    β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚ Consume
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό                 β–Ό                 β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Pricing      β”‚  β”‚ Live Ops     β”‚  β”‚ Future:  β”‚
            β”‚ Worker(Rust) β”‚  β”‚ CLI (Go)     β”‚  β”‚Dashboard β”‚
            β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ HTTP GET                    
                   β–Ό                             
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   
         β”‚ Mock Grid        β”‚                   
         β”‚ Service (Go)     β”‚                   
         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   
                β”‚ Write                          
                β–Ό                                
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   
         β”‚  TimescaleDB     β”‚                   
         β”‚ (Time-Series)    β”‚                   
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   

Project Structure

greenLane/
β”œβ”€β”€ Makefile                    # Control center (make up, make down, make logs)
β”œβ”€β”€ quickstart.sh               # Automated setup script
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ SETUP.md                    # Detailed installation guide
β”œβ”€β”€ TESTING.md                  # End-to-end testing walkthrough
β”œβ”€β”€ ARCHITECTURE.md             # Deep dive into system design
β”œβ”€β”€ PROJECT_SUMMARY.md          # Executive summary
β”œβ”€β”€ deploy/
β”‚   β”œβ”€β”€ docker-compose.yml      # All infrastructure (Redis, Redpanda, TimescaleDB)
β”‚   └── init-db.sql             # TimescaleDB schema initialization
β”œβ”€β”€ proto/
β”‚   └── fleet.proto             # gRPC service + message definitions
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ ingestion/              # Go gRPC server (port 50051)
β”‚   β”œβ”€β”€ pricing-worker/         # Rust Kafka consumer
β”‚   └── mock-grid/              # Go HTTP server (port 8081)
β”œβ”€β”€ simulator/                  # Python gRPC client (fleet simulation)
β”œβ”€β”€ cli/                        # Live Ops monitoring tool
└── scripts/
    └── generate-proto.sh       # Protobuf code generation

Verification

Check Data Flow

# 1. Verify Redis geospatial data
docker exec -it greenlane-redis redis-cli GEORADIUS fleet:locations -73.9876 40.7234 10 km WITHCOORD

# 2. Verify Redpanda events
open http://localhost:8080

# 3. Query TimescaleDB
docker exec -it greenlane-timescaledb psql -U greenlane -d greenlane -c "SELECT * FROM charging_sessions ORDER BY time DESC LIMIT 5;"

# 4. Check service status
make status

Documentation

Makefile Commands

make help           # Show all available commands
make up             # Start infrastructure
make down           # Stop all services
make logs           # View logs from all containers
make proto          # Generate protobuf code
make build-all      # Build all services
make clean          # WARNING: Remove all data
make status         # Show container status

Key Engineering Concepts

  • gRPC Bidirectional Streaming - Real-time, full-duplex communication
  • Event Sourcing - Kafka/Redpanda as source of truth
  • Geospatial Indexing - Redis GEO commands for proximity queries
  • Time-Series Optimization - TimescaleDB hypertables for temporal data
  • Microservices Decoupling - Independent services communicating via events
  • Observability - Redpanda Console + Live Ops CLI for debugging

Roadmap

Phase 1: Steel Thread (COMPLETE)

  • gRPC telemetry ingestion
  • Redis geospatial storage
  • Redpanda event streaming
  • Rust pricing worker
  • TimescaleDB persistence
  • Live Ops CLI

Phase 2: Atomic Booking Engine

  • Lua script for slot reservation
  • Redis distributed locking
  • Booking expiration (TTL)

Phase 3: Real-Time Dashboard

  • WebSocket hub
  • React + Deck.gl frontend
  • Map visualization

Phase 4: Production Hardening

  • mTLS authentication
  • Prometheus metrics
  • Grafana dashboards
  • Kubernetes deployment

License

MIT License


Built with ⚑. Brought to you by Ashish Reddy Tummuri

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published