How viettrung1404/dut.smarthomesystem works
This is a smart-home application: users manage homes, rooms and devices, issue commands, configure automations, and receive AI chat and suggestions through the mobile app and backend. Device commands reach hardware over MQTT; scheduled or state-triggered automations can also issue commands. Face verification, security, energy, and suggestion features are separate product branches. The excerpts confirm selected API and execution flows; wiring for unsampled modules is shown only where supported by their documented roles or direct imports.
Main entry points: api.ts API client · core.py PostgreSQL · controller.py Devices API · mqtt_client.py MQTT client
Components 25
Mobile client
- Mobile app
mobile/app/(tabs)/index.tsx - API client
mobile/services/api.ts
Backend product APIs
- Homes API
backend/src/apis/homes/controller.py - Rooms API
backend/src/apis/rooms/controller.py - Devices API
backend/src/apis/devices/controller.py - Authentication API
backend/src/apis/auth/controller.py - Automations API
backend/src/apis/automations/controller.py - Security API
backend/src/apis/security/controller.py - Energy API
backend/src/apis/energy - Face API
backend/src/apis/face/controller.py
AI and insights
- Smart-home chat
backend/src/apis/ai_chat/controller.py - Suggestions API
backend/src/apis/suggestions/controller.py - Chat forwarding
backend/src/apis/ai_chat/service.py - AI chat endpoint
ai-server/app/api/chat_routes.py - Smart-home agent
ai-server/app/agent/agent.py - Conversation memory
ai-server/app/memory/memory_store.py - Ollama client
ai-server/app/llm/ollama_client.py
Device runtime
- Automation engine
backend/src/automation/engine.py - MQTT client
backend/src/mqtt_client.py - Face recognition
backend/src/apis/face/service.py
Persistence
- PostgreSQL
backend/src/database/core.py
Other components
- Resident
- Ollama service
- MQTT broker
- IoT device
Iot/iot_client.py
Connections 34
- Resident → Mobile app: uses
- Mobile app → API client: requests data
- API client → Authentication API: calls
- API client → Homes API: calls
- API client → Rooms API: calls
- API client → Devices API: calls
- API client → Automations API: calls
- API client → Security API: calls
- API client → Energy API: calls
- API client → Face API: calls
- API client → Smart-home chat: calls
- API client → Suggestions API: calls
- Smart-home chat → Chat forwarding: forwards chat
- Chat forwarding → AI chat endpoint: sends request
- AI chat endpoint → Smart-home agent: dispatches
- Smart-home agent → Conversation memory: reads and writes
- Smart-home agent → Ollama client: requests completion
- Ollama client → Ollama service: calls
- Smart-home chat → Devices API: sends commands
- Devices API → MQTT client: publishes command
- Face API → Face recognition: verifies face
- Face API → MQTT client: publishes unlock
- Automation engine → PostgreSQL: reads and updates
- Automation engine → MQTT client: publishes action
- MQTT client → MQTT broker: publishes
- IoT device → MQTT broker: exchanges messages
- Homes API → PostgreSQL: reads and writes
- Rooms API → PostgreSQL: reads and writes
- Devices API → PostgreSQL: reads and writes
- Authentication API → PostgreSQL: reads and writes
- Automations API → PostgreSQL: reads and writes
- Security API → PostgreSQL: reads and writes
- Energy API → PostgreSQL: reads and writes
- Suggestions API → PostgreSQL: reads and writes