How peaniz/military-defense-simulation works
Overview of the Project
• This project is a web-based radar and object tracking system that integrates real-time data from an Arduino (via a radar sensor) with a web interface. The system supports two modes – Radar Mode (displaying sensor data) and Tracking Mode (tracking faces or hands via MediaPipe).
• The project includes a FastAPI backend in Python, a frontend built with HTML/CSS/JavaScript, and Arduino firmware (RadarAndFace.ino) for interacting with the sensor hardware.
Main Components
a. Arduino Hardware:
• Represented by the RadarAndFace.ino file, which is responsible for reading sensor data (angle, distance) and receiving coordinate inputs for servo control in Tracking Mode.
b. Python Backend (FastAPI Server):
• Represented by app.py and radar.py. This layer handles API endpoints, WebSocket connections, and serial communication with the Arduino.
• Elements such as the serial port communication (configured to COM port as discussed in the README) and integration with the Arduino.
• This component as "Backend Server (FastAPI)" with a note on its role as the orchestrator between hardware and the web client.
c. Web Frontend (Client Interface):
• Composed of the HTML template (index.html), CSS (styles.css), and several JavaScript files (detection.js, main.js, radar-display.js, radar.js, ui.js, and websocket.js) contained in the static folder.
• This layer is responsible for rendering the user interface, displaying the radar, and presenting tracking data via real-time WebSocket updates.
Relationships and Interactions
• The Arduino communicates sensor data (in Radar Mode) to the Backend Server via a Serial/COM port. In Tracking Mode, the Backend sends coordinate data to the Arduino.
• The FastAPI backend sets up WebSocket connections with the Web Client for real-time data updates (both for radar and tracking information).
• The Web Client fetches the initial HTML/CSS/JS content from the server and maintains a persistent WebSocket connection for dynamic updates.
• Directional flows:
• Arduino → Backend: Sensor data incoming via serial communication.
• Backend → Arduino: Control commands/coordinates to adjust hardware (servos/tracking).
• Web Client: Sends user commands or mode switches back to the Backend (if applicable).
Architectural Patterns and Design Principles
• The project follows a typical client-server model augmented with hardware interfaces.
• Use real-time communication (WebSockets) as a key design pattern for asynchronous updates between the server and the client.
• Separation of concerns: The backend handles hardware and business logic while the frontend is solely focused on the presentation and user interaction.