How winc-link/hummingbird works
Main Components
• HummingBird Core Service: This is the backend implemented in Go (located in cmd/hummingbird-core and under internal/hummingbird). It encapsulates business logic for device management, product management, alert centers, rule engines, and more.
• HummingBird UI: Found in cmd/hummingbird-ui and its build directory, this is the frontend (likely a web SPA) that communicates with the backend.
• Data Storage Layer: The platform supports multiple databases. The use of SQLite and LevelDB is emphasized, with alternatives such as MySQL and TDengine available. The infrastructure directories for MySQL and SQLite (internal/hummingbird/core/infrastructure and manifest/sql) illustrate that storage is pluggable.
• API & Communication Components: There is a rich set of HTTP controllers (gateway, openapi, websocket) and RPC servers (driverserver) that handle client requests, real-time communication, and external integrations.
• Messaging & Device Communication Layer: The presence of MQTT clients, messaging packages, and driver-related modules (internal/pkg/messaging; internal/tools/mqttclient) suggests a messaging subsystem for handling device communication.
• Containers & Dependency Injection: The “container” directories (both under internal/hummingbird and internal/pkg/di) denote that the system uses DI patterns and service containers to manage component interactions.
• Auxiliary Tools: Dockerfiles and Docker Compose files (in the manifest/docker directory) indicate containerized deployment, and utilities like cron jobs (internal/pkg/crontab) and logging, configuration, and error handling play key roles.
Relationships & Interactions
• Clients (web browsers, mobile mini-apps, and possibly external systems) interact with the HummingBird UI.
• The UI communicates with the HummingBird Core via HTTP/WS APIs provided by distinct gateway and openapi controllers.
• The Core service orchestrates business logic by invoking various application modules (e.g., deviceapp, driverapp, alertcentreapp) which in turn depend on lower level domain models and interfaces.
• Through the infrastructure and container layers, the business logic interacts with persistent storage via configurations that allow switching between SQLite/LevelDB and MySQL/TDengine.
• The messaging/mqtt layers facilitate bidirectional communication between devices and the platform.
• An RPC server component manages inter-service or driver-specific requests.
• All components are developed in Go, orchestrated and deployed as Docker containers (with deployment details in manifest/docker).
Architectural Patterns & Design Principles
• Layered Architecture: Clear separation between controllers (HTTP/RPC), application/business logic, infrastructure (databases, messaging), and domain models.
• Dependency Injection & Inversion of Control: Use of container directories indicates that dependencies are injected to promote loose coupling.
• Pluggability: Database and messaging interfaces are designed to support multiple implementations (e.g., SQLite vs. MySQL, LevelDB vs. TDengine), which is central to the platform’s flexibility.