Commit 3761ddbd authored by Patrick Ade's avatar Patrick Ade
Browse files

Refactor README.md to enhance project documentation; update folder structure...

Refactor README.md to enhance project documentation; update folder structure descriptions and key components
parent 356aaaf8
## ToDo # Project Folder Structure and Functions
This document describes the purpose and functionality of the folders within the `web` directory of the project.
---
EINE ENV File und project.toml DAS IST WICHTIG BITTE MACHEN ## **1. `backend`**
- **Purpose**: Contains the Django backend for the project.
- **Key Components**:
- **`app`**: Main application logic, including views, routes, models, and utilities.
- `urls.py`: Defines the URL patterns for the Django application.
- `views.py`: Contains the logic for handling HTTP requests and returning responses.
- `auth.py` and `auth_utils.py`: Handle authentication, including JWT token creation and validation.
- `routes`: Modular route definitions for Ninja API endpoints (e.g., `sensor.py`, `user.py`).
- `schemas`: Defines Pydantic models for request and response validation in Ninja API.
- **`core`**: Project-wide settings and configurations.
- `settings.py`: Django settings file, including database configuration, middleware, and installed apps.
---
## **2. `frontend`**
- **Purpose**: Contains the Vue.js frontend for the project.
- **Key Components**:
- **`src`**: The source code for the frontend application.
- `App.vue`: The root Vue component.
- `router`: Contains route definitions for the frontend.
- `components`: Reusable Vue components (e.g., `NavBar.vue`).
- `views`: Contains page-level components (e.g., `HomeView.vue`, `LoginView.vue`).
- **`public`**: Static assets like images, icons, and the `index.html` file.
Versucht das der Logger geht ---
## **3. `data_generation`**
- **Purpose**: Simulates sensor data and publishes it to an MQTT broker.
- **Key Components**:
- `main.py`: Generates random CO2, temperature, and humidity data and sends it to the MQTT broker.
- **Dependencies**:
- Uses `paho-mqtt` for MQTT communication.
- Reads MAC addresses from a JSON file (e.g., `mac_to_room.json`).
Docker compose in Services/Influxdb und Services/mqtt zu einem dockerfile machen und das über die große docker compose im "Web" ordner starten ---
Streamprocessing die Dockerfile auf uv umstellen und .requirements in .toml file reinmachen (dafür auch entsprechend entfernen)
Recherche ob in yaml files auch dependencies rein können - wenn ja können wir ein einziges Dockerfile machen. !!! Wichtig!!! ## **4. `stream_processing`**
- **Purpose**: Processes real-time data streams from the MQTT broker and writes them to InfluxDB.
- **Key Components**:
- `mQTTClientHandler.py`: Subscribes to MQTT topics, processes incoming messages, and writes data to InfluxDB.
- `utils`: Contains helper modules for InfluxDB integration, logging, and query building.
- `mac_to_room.json`: Maps MAC addresses to room names.
## Hilfreiche Kommandos ---
sudo ss -tulpen | grep 1883 // Wenn der Port 1883 (geht natürlich auch mit anderen) schon benutzt wird, findet man so, welcher Prozess es ihn benutzt
sudo kill 1432 // den Prozess killn
docker compose up // Startet des docker-compose.yaml in dem aktuellen Verzeichnis
## Eventuelle ToDos ## **5. `services`**
dieses projekt anschauen: - **Purpose**: Contains configurations for external services like InfluxDB and MQTT.
https://github.com/influxdata/iot-api-python - **Key Components**:
- `docker-compose.yaml`: Defines Docker services for InfluxDB, MQTT, and possibly other components.
- **Subfolders**:
- `influxdb`: Configuration files for the InfluxDB service.
- `mqtt`: Configuration files for the MQTT broker (e.g., Mosquitto).
Added MQTTX to Docker compose for debuging (http://localhost:8081/) ---
make a new Connection to Localhost (localhost) port should be 1883 for mqtt not entcrypted
than subscribe to the co2/# topic
and debug
Json Format für die Nachrichten ## **6. `Dockerfile` and `docker-compose.yaml`**
{ - **Purpose**: Define the Docker environment for the project.
"metadata":{ - **Key Components**:
"mac-address":"test", - `Dockerfile`: Specifies how to build the Docker image for the application.
"time":"2025-04-10 11:33:21+01" - `docker-compose.yaml`: Orchestrates multiple services (e.g., backend, frontend, InfluxDB, MQTT).
},
"co2":528,
"temp":26.0, 
  "rh":24.2
}
{ ---
"room": "1/121",
"data": [ ## **Summary**
"2025-06-01 10:36:21+00:00": { - **Backend**: Django application for API and business logic.
"co2": "630", - **Frontend**: Vue.js application for the user interface.
"temperature": "35", - **Data Generation**: Simulates sensor data and sends it to the MQTT broker.
"humidity": 35.2 - **Stream Processing**: Processes real-time data and writes it to InfluxDB.
"temperature": 35 - **Services**: Configurations for external services like InfluxDB and MQTT.
}, \ No newline at end of file
"2025-06-01 10:36:21+00:00": {
"co2": "630",
"temperature": "35",
"humidity": 35.2
"temperature": 35
},
"2025-06-01 10:36:21+00:00": {
"co2": "630",
"temperature": "35",
"humidity": 35.2
"temperature": 35
},
"2025-06-01 10:36:21+00:00": {
"co2": "630",
"temperature": "35",
"humidity": 35.2
"temperature": 35
},
]
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment