How nguyenminhduc163/fire-guard-be works
Project Type Analysis
This is a backend service for a Smart Fire Alarm System with IoT integration, following a clear MVC-like architecture pattern with additional service layers.
Main Components
A. External Interfaces:
• IoT Devices (Fire Sensors)
• Mobile/Web Clients
• Firebase (for notifications)
• Email Service
B. Core Application Layers:
• API Gateway Layer (Express.js Routes)
• Authentication Layer
• Controller Layer
• Service Layer
• Data Access Layer
• Database (PostgreSQL)
[External Clients/Devices] (Top)
• ↓
[API Gateway/Routes Layer]
• ↓
[Authentication Middleware]
• ↓
[Controllers]
• ↓
[Services]
• ↓
[Data Models]
• ↓
[Database] (Bottom)
Key Relationships to Highlight
a) Data Flow Paths:
• IoT Sensor Data Path:
Sensors → iotStatusSave.router → iotStatusSave.controller → iotStatusSave.service → Database
• Emergency Alerts Path:
emergency.router → emergency.controller → emergency.service → notifications.service → Firebase/Email
b) Authentication Flow:
• auth.router → auth.controller → token.service
• authMiddleware interaction with protected routes
Specific Components to Detail
Core Features:
• Sensor Data Management
• Emergency Detection & Alerts
• User Management
• Family Notifications
• Guides & News System
• Historical Data Tracking
Support Systems:
• Logging System
• Response Handling
• Input Validation
• Error Management
• Client Layer |
• Security Layer |
• Business Layer |
• Data Layer |
• External Services |
Remember to:
• Keep components properly grouped
• Clear data flow directions
• Async operations
• Critical security checkpoints
• Document all external dependencies
• Monitoring and logging points