How harnan01/e19-3yp-automated-grass-cutter works
Project type and purpose
• This is a full-stack IoT application for an Automated Grass Cutter.
• It consists of three major layers:
a. A mobile frontend (React Native) for user interaction
b. A Java Spring Boot backend (REST API, security, persistence, MQTT integration)
c. Embedded firmware on Arduino/ESP32 devices controlling the mower hardware
File structure to extract architectural components
• Top level directories:
• Frontend – React Native app (screens, API wrapper)
• Backend – Maven-based Spring Boot service (controllers, services, repositories, MQTT config, Cognito security)
• Hardware – Two PlatformIO projects (Arduino and ESP32 firmware)
• docs – Static site assets and instructions
• Key backend packages:
• com.example.grasscutter.MQTT – MQTTConfig for broker integration
• com.example.grasscutter.MobileApplication.User – AWS Cognito setup, controllers, DTOs, services, repositories
• com.example.grasscutter.MobileApplication.Device – device management REST endpoints, authentication, persistence
README for additional context
• High-level goal: fully automated lawn mowing
• Implied use of cloud services for user auth, message brokering, and data storage
Main components
a. Mobile App (React Native)
• Screens: Login/SignUp, AddDevice, Home, Manual/Auto control
• Connects over HTTPS to Backend REST API
b. Backend Service (Spring Boot)
• REST API Layer (DeviceController, UserController)
• Service Layer (UserService, DeviceAuthenticationService)
• Persistence Layer (UserRepository, DeviceRepository → relational DB)
• Security Module (AWS Cognito integration via SecurityConfig, CognitoConfig)
• Messaging Module (MQTTConfig → publishes commands, subscribes to telemetry)
c. Cloud Services
• AWS Cognito (user authentication & federation)
• MQTT Broker (e.g., Mosquitto or cloud-hosted EMQX)
d. Database
• Relational DB (PostgreSQL/MySQL/H2 – as configured in application.yml)
e. Hardware Devices
• ESP32 / Arduino microcontrollers
• Firmware subscribes to MQTT topics for commands, publishes sensor data/telemetry
f. Documentation Site
• Static docs (docs folder) served separately (e.g., GitHub Pages)
Relationships and interactions
1. User opens the Mobile App → authenticates via AWS Cognito (App ↔ Cognito).
2. Upon login, Mobile App calls Backend REST endpoints (HTTPS).
3. Backend validates JWT tokens issued by Cognito, loads user/device data from the DB.
4. For manual or scheduled cut commands, Backend publishes MQTT messages to device topics.
5. Devices (ESP32/Arduino) subscribed to those topics receive commands, actuate hardware, and send telemetry back on another MQTT topic.
6. Backend subscribes to telemetry topics, processes data (e.g., angle/distance readings), persists relevant events to the DB.
7. Mobile App may poll or receive push-style updates (via REST or a real-time channel) to display device status.
Architectural patterns and design principles
• Layered MVC in the backend (Controller → Service → Repository)
• Message broker pattern for decoupled communication between backend and devices
• Externalized configuration (application.yml, PlatformIO ini files)
• Single-page app structure in React Native (screens, API module)
• Clear separation of concerns: Auth, Device management, Messaging