How shohinsan/mortesense works
Main Components
• Frontend – A React application (written in TypeScript with Tailwind CSS) that serves as the customer-facing web portal. It includes components for authentication, dashboard pages (alerts, history, settings, etc.), and uses contexts and hooks for state management.
• Backend – A Flask-based API written in Python. It contains routes (alerts, auth, device management, Twilio integration, and user management), a structured “src” folder for the application logic, and uses a virtual environment. It handles RESTful communications, processes data, and serves as the business logic layer.
• Database & Caching – A MySQL database for storing users, sensor data, and similar records. A Redis server is also employed (likely for caching or fast data handling).
• Hardware – A Raspberry Pi Pico W with a connected microwave motion sensor. The “hardware” folder (with files such as main.py and setup_server.py) likely deals with sensor interfacing, processing sensor events, and might communicate with the backend.
• External Integrations – Twilio API (for messaging/notifications), AWS (for deployment/storage via RDS or other AWS services), and API testing via Postman.
Relationships and Interactions Between Components
• User requests and interactions (for login, sensor data viewing, account management, etc.) originate at the Frontend.
• The Backend processes requests (authentication, sensor alerts, etc.), then interacts with the MySQL database to read/write data and with Redis for caching or sessions.
• The Hardware sensor module (running on the Pico W) detects motion events and sends data (possibly via network calls or designated API endpoints) to the Backend.
• Twilio and potentially AWS are integrated by the Backend to deliver notifications or support deployment/infrastructure needs.
Important Architectural Patterns and Design Principles
• Separation of Concerns: A clear decoupling between the frontend UI, the backend business logic, and the hardware layer.
• Client–Server Architecture: The client (frontend) remains responsible for the user experience while the backend handles data processing and API management.
• Modular Organization: The directory structure (frontend, backend, hardware) suggests that each component is independently developed and maintained.
• Integration with External Services: The backend connects to Twilio for SMS/notification purposes and leverages AWS and Redis for scalability and performance.
Relevant Technologies and Frameworks
• Frontend: React, TypeScript, Tailwind CSS, React Router.
• Backend: Python with Flask, SQLAlchemy (implied by the models and usage of Flask extensions), Alembic for migrations, and integration with MySQL and Redis.
• Hardware: Python scripts running on Raspberry Pi Pico W, interfacing with a microwave motion sensor.
• External Services: Twilio API, AWS (RDS or storage), and Postman for API validation.
• Use clear labels for each component (e.g., “React Frontend,” “Flask API Server,” “MySQL Database,” “Redis Cache,” “Raspberry Pi Pico W – Sensor Module,” “Twilio API”).
• Optionally, add brief notes on technologies used (e.g., “Flask (Python) for REST API,” “React (TypeScript) for UI”) near each component.