A fully simulated, microservice-based digital twin of an Environmental Control and Life Support System (ECLSS) designed for isolated habitats. It simulates a central event bus, autonomous power management with dynamic load shedding, critical life support subsystems, and a real-time monitoring dashboard.
- Event-Driven Backbone: Utilizes NATS (or RabbitMQ) for high-throughput pub/sub messaging across all habitat modules.
- Autonomous Grid Controller: A Go-based power manager that simulates solar array insolation drops (like Martian dust storms) and battery bank states.
- Priority Load Shedding: Critical logic that automatically decides which modules are cut when power is low via a priority queue.
- Air Revitalization (Priority 1): A Python service simulating Sabatier reactors (combining CO2 and H2 into water and methane) and electrolysis, requesting 1500W of grid power.
- Water Recovery (Priority 2): A Python service handling cabin humidity condensation and urine processing. It requests 2000W of power but can be safely paused for 48 hours during power shortages.
- Habitat Dashboard: A React and TypeScript interface featuring live resource gauges, a scrolling event log of autonomous decisions, and manual system overrides.
- Visual Power Routing: Uses
react-flow-rendererto display a node-based graph of power flowing to active modules.
The digital twin mimics physical isolation by containerizing distinct systems:
- Event Bus: The central nervous system handling telemetry and requests.
- Power Manager (Go): The high-availability grid controller.
- Air Module (Python): O2 generation and CO2 scrubbing.
- Water Module (Python): Brine and humidity processing.
- Central Terminal (React): The mission control dashboard connecting to the event stream via WebSockets.
- Core Logic: Go 1.22, Python 3.12
- Frontend UI: React 18, TypeScript 5, Vite 5, ReactFlow 11, WebSockets
- Message Broker: NATS 2.10
- Infrastructure & Deployment: Docker, Docker Compose, Kubernetes (K8s), GitHub Actions
| Service | Host Port | Description |
|---|---|---|
| Central Terminal | 3001 | React dashboard (nginx) |
| NATS Client | 4222 | Event bus client connections |
| NATS Monitor | 8222 | HTTP monitoring (/varz) |
| Power Manager | 8081 | Health endpoint (/healthz) |
| WebSocket Bridge | 9090 | NATS → browser proxy |
- Docker and Docker Compose installed.
- (Optional) A Kubernetes environment to utilize the provided K8s manifests.
- Clone the repository:
git clone https://github.com/mtepenner/eclss-digital-twin.git cd eclss-digital-twin - Boot the entire simulated base locally using Docker Compose:
Or use the Makefile:
docker compose up --build -d
make up # build & start make logs # stream logs make test # run Go unit tests make down # tear down
Once the cluster is initialized:
- Navigate to the Central Terminal in your browser at
http://localhost:3001. - Monitor the Resource Gauges for real-time levels of O2, CO2, Clean Water, and Battery percentage.
- Watch the Power Grid Graph to see dynamic allocations. Try triggering a simulated solar drop to watch the load shedding logic in action.
- Monitor the Event Log to understand the autonomous grid decisions being made.
- Use the System Overrides to manually force-restart modules that were killed by the power manager.
Contributions are highly encouraged. When updating the autonomous logic, please ensure that your changes pass the unit tests for the power shedding logic defined in .github/workflows/test-load-balancer.yml.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/NewSubsystem) - Commit your Changes (
git commit -m 'Add hydroponics module') - Push to the Branch (
git push origin feature/NewSubsystem) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.