# Developer Guide: UniBBW_Boomerang

This guide provides an overview of the application's architecture, main components, and instructions for future modification and development.

## 1. Application Overview
- **Frontend:** HTML/CSS/JS (Three.js, Bootstrap) served from `backend/app/static` and `backend/app/templates` via Flask.
- **Backend:** Python Flask app in `backend/app/`, providing API endpoints, business logic, and email handling.
- **Data:** Materials, printers, and qualities are stored in CSV files in `backend/app/daten/`.

## 2. Main Components
- `main.py`: Flask entry point, configures app, loads resources, registers blueprints.
- `api/`: Contains API endpoints for calculations, uploads, and routes.
- `services/`: Business logic (calculation, validation, STL processing, data management).
- `models/`: Data models for printers, materials, qualities, parts, and orders.
- `ausnahmen/`: Custom exception handling.
- `send_email.py`: Handles contact form email sending.
- `static/`: All static assets (CSS, JS, images, PDFs).
- `templates/`: HTML templates (mainly `index.html`).

## 3. How the App Works
1. User opens the web interface (served by Flask).
2. User uploads an STL file, selects material/printer/quality, and requests a cost calculation.
3. The backend processes the STL, calculates the cost, and returns the result.
4. The user can send a contact form, which triggers an email (if configured).

## 4. Modifying Data (Materials, Printers, Qualities)
- Edit the CSV files in `backend/app/daten/`:
  - `materialien.csv` (materials)
  - `drucker.csv` (printers)
  - `qualitaeten.csv` (qualities)
- After editing, restart the backend for changes to take effect.

## 5. Development & Testing
- To run the backend (from the project root, where the `app` folder is):
  > **Important:** Always run from the project root (not inside the `app` folder) or you will get import errors.
  ```bash
  python -m app.main
  ```
- Main routes:
  - `/` : Main web interface
  - `/api/calculate` : Cost calculation (POST)
  - `/api/upload_stl` : STL upload (POST)
  - `/send_email` : Contact form (POST)
- Static files are served from `static/`, templates from `templates/`.

## 6. Configuration
- Sensitive data (email credentials, receiver) is stored in `.env` in the project root. See README for details.

## 7. Glossary (optional)
- **Blueprint:** Flask's way to organize routes and logic into reusable modules.
- **STL:** File format for 3D models.
- **App Password:** Google-generated password for secure app access (see README).

---
For further questions, check the code comments or contact the project maintainer.
