Includes: - Backend services: ingestion (:8001), weather API (:8002), gateway (:8003), billing (:8004) with BTCPay integration - Shared asyncpg pool, TimescaleDB hypertable, Redis, Mosquitto MQTT - React frontend: Dashboard (MapLibre) and Messaging (chat UI) - Bridge daemon for Pi + Meshtastic (Serial/TCP T-Deck support) - Production Docker Compose, Nginx reverse proxy, ops scripts - DEPLOY.md with step-by-step deployment guide
KosmoConnect Backend
This directory contains the cloud backend services for KosmoConnect.
Quick Start
1. Start Infrastructure Services
You need Docker running on your machine.
cd backend
docker-compose up -d
This starts:
- TimescaleDB on port
5432 - Redis on port
6379 - RabbitMQ on port
5672(management UI on15672) - Mosquitto MQTT on port
1883
The first time TimescaleDB starts, it will automatically run the migration in migrations/001_initial_schema.sql.
2. Install Python Dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
3. Run the Services
In terminal 1:
./run-dev.sh ingestion
In terminal 2:
./run-dev.sh api
- API docs: http://localhost:8002/docs
- Ingestion health: http://localhost:8001/health
4. Simulate Data (No Hardware Needed)
In terminal 3:
cd ..
python3 -m venv .venv
source .venv/bin/activate
pip install -r backend/requirements.txt
python3 scripts/simulate-bridge.py --interval 5
This publishes fake environmental readings every 5 seconds. The ingestion service will pick them up and write them to TimescaleDB. You can then query the API:
curl "http://localhost:8002/api/v1/weather/latest"
Service Architecture
| Service | Port | Responsibility |
|---|---|---|
| API | 8002 | REST API for dashboard and web clients |
| Ingestion | 8001 | Subscribes to MQTT, writes sensor data to TimescaleDB |
| Gateway | 8003 | Web-to-mesh message queue, delivery tracking, and subscription enforcement |
| Billing | 8004 | BTCPay Server integration for subscriptions and invoices |
Database Schema
- nodes: Registry of all enviro-nodes and infrastructure nodes
- enviro_readings: Time-series hypertable for sensor data
- mesh_messages: Delivery tracking for gateway messages
- users / subscriptions / allowed_nodes: Subscriber management
Environment Variables
Copy .env.example to .env and customize:
cp .env.example .env
| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
postgresql://kosmo:kosmo_dev_pass@localhost:5432/kosmoconnect |
TimescaleDB connection |
MQTT_HOST |
localhost |
MQTT broker host |
MQTT_PORT |
1883 |
MQTT broker port |
MQTT_TOPIC |
kosmo/ingest/enviro |
Topic for enviro data |