How dmytrys/u-hub works
Project Type & Purpose
• This is a microservice-based IoT “u-hub” platform. It unifies device telemetry (via MQTT), event‐driven logic (via RabbitMQ), data storage (MongoDB), a GraphQL API (Apollo), a React client, automation jobs, and voice-assistant integrations (Apple HomeKit & Google Home).
Main Components
• Edge Devices (real or fake)—publish telemetry over MQTT
• MQTT Broker (Mosquitto)—receives device messages
• MQTT Listener service—consumes MQTT, repackages as AMQP events
• Message Bus (RabbitMQ)—central AMQP pub/sub
• Microservices (all Node.js/Lerna‐managed):
• apollo—GraphQL API, resolvers, pub/sub, Mongo persistence
• automatic-action—reacts to events to trigger immediate commands
• scheduled-action—runs cron‐style jobs, emits events/commands
• apple-homekit & google-home—voice‐assistant adapters (consume events, send commands)
• client—React SPA talking to Apollo over HTTP
• Database (MongoDB)—stores sensor & action history
• Infrastructure (Docker Compose & Kubernetes manifests)—Ingress‐NGINX, NFS, config maps, deployments
Component Interactions & Data Flows
• Edge Device → MQTT Broker (topic: telemetry)
• MQTT Listener → consumes MQTT → publishes event to RabbitMQ
• RabbitMQ → fan-out events → apollo/pubsub, automatic-action, scheduled-action, homekit/google adapters
• apollo → writes to MongoDB; subscribes to bus for real-time updates → GraphQL subscriptions
• client → issues GraphQL queries/mutations to apollo → displays real-time dashboards
• automatic/scheduled adapters → on trigger → publish “command” events to RabbitMQ →
MQTT Listener → publishes MQTT commands back to devices
• apple-homekit/google-home → expose external API endpoints (ingress) → consume bus events & publish commands
Architectural Patterns & Principles
• Event-driven microservices (AMQP pub/sub)
• Clear separation of concerns: ingestion (MQTT), transformation (listener), domain logic (services), API (GraphQL), UI (React), integrations (adapters)
• Kubernetes deployment per service, with configmaps, services, ingress resources
• Monorepo (Lerna) sharing common libs (amqp.js, logger.js, etc.)