🎉 Renamed IHK_Projektdokumentation/Ausarbeitungsprozess/Dokumentation.md to IHK_Projektdokumentation/Dokumentation_Final_Markdown/Dokumentation.md

This commit is contained in:
Till Tomczak 2025-06-03 14:09:31 +02:00
parent 4149aa7cd4
commit 0b4c88f91c
13 changed files with 532 additions and 5 deletions

View File

@ -0,0 +1 @@
hier entsteht die finale dokumentation im markdown format. manuelle übertragung in finales abzugebendes word dokument durch mich persönlich

View File

@ -0,0 +1,40 @@
torben und ich haben zusammen gearbeitet, nicht getrennt; ich habe ihn offiziell ergänzt im nachhinein, sein projekt war eine art prototyp.
unsere 3d drucker in der tba sind leider alles andere als modern, deswegen mussten wir den kompromiss der alleinigen fernsteuerung der steckdosen schließen. kein direkter datenaustausch ist zu den 3d druckern möglich aufgrund mangelnder Anschlüsse und fehlender konnektivität.
→ screenshots & email verkehr beilegen;
→ sag zeig auf, was du investiert hast
Projektumfang und -Abgrenzung = kein Fokus auf Daten- und Prozessanalyse sondern auf praktische Umsetzung
Sprint 1:
erster Sprint = Aufarbeitung des bestehenden Prototypen, ansatzpunkte und rahmendefinition etc etc
Sprint 2: rudimentärer Aufbau,
Umsetzung erforderte interne Beantragung vonAdmin Rechten womit ich gewissermaßen zu kämpfen hatte, Auswahl der Systeme, und dry run der Funktionalität, Prüfung der Machbarkeit (wireshark Reverse engineering exzess)
Sprint 3: komplett fehlgeschlagener Versuch, das Backend mit dem Frontend zu verknüpfen, selbst signierte und intern genehmigte Zertifikate des Frontends wurden aus Versehen gelöscht, musste mich auch erst mit github corporate oauth und npm vertraut machen etc
sprint 4: ursprünglich geplant für den Feinschliff, nun umfunktioniert zur Entwicklung einer full stack Notlösung weil mir im übertragenen Sinne der Arsch brannte.
Sprint 5: ursprünglich geplant für die Schulung, jetzt umfunktioniert zur Fehlerbehebung; eigentlich ging der Sprint 4 einfach weiter bis zum Schluss weil ich nicht fertig wurde.
ein raspberry 5 wurde gewählt kein raspberry 4, weil das frontend doch aufwendiger zu rendern war als gedacht; 128 gb zudem damit nicht ansatzweise sorge besteht für Datenbankspeicher+ anfertigung von backups; zudem braucht offline Installation des frontends mehr Speicher als ursprünglich angedacht.
ich hab KEIN touch Display installiert, die nutzung von touch im kiosk modus wurde komplett halluziniert
stattdessen aber habe ich einen serverschrank hinzu bestellt (Mercedes intern bestellt), privat dann weil ich die Geduld verloren habe mit internen bestellprozessen habe ich noch Lüfter und Kabelkanäle (fürs auge) gekauft - nix wahnsinnig funktionales oder sonderlich notwendiges, vielmehr aus dem Bedürfnis heraus mein Projekt so hochwertig wie möglich abzuliefern.
torben und ich dürfen nicht auftreten als hätten wir das ganze in Absprache zusammen oder parallel zeitgleich entwickelt, da Torben früher ausgelernt hat als ich und ich nicht vor der Zulassung bzw Genehmigung der IHK an dem Projekt arbeiten hätte dürfen.
verwendung von git erwähnen weil zentral für vorgehensweise als entwickler
ganz am anfang gab es folgende komplikationen:
Komplikationen:
Netzwerkanbindung
Ermitteln der Schnittstellen der Drucker
Auswahl der Anbindung, Entwickeln eines Netzwerkkonzeptes
Beschaffung der Hardware (beschränkte Auswahlmöglichkeiten)
Welches Betriebssystem? OpenSuse, NixOS, Debian
Frontend verstehen lernen
Netzwerk einrichten, Frontend anbinden

View File

@ -0,0 +1,79 @@
# Raspberry Pi Deployment Guide
## Prerequisites
- Raspberry Pi 4 (recommended) or 3B+
- Raspbian OS (latest)
- Python 3.7+
- nginx (optional, for production)
## Quick Start
1. **Clone the repository**
```bash
git clone <repository-url> /home/pi/myp-platform
cd /home/pi/myp-platform
```
2. **Install dependencies**
```bash
sudo apt-get update
sudo apt-get install python3-pip python3-venv nginx
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
3. **Run deployment script**
```bash
python deploy_raspberry_pi.py
```
4. **Start the application**
```bash
python run_optimized.py
```
## Production Deployment
1. **Install as systemd service**
```bash
sudo cp myp-platform.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable myp-platform
sudo systemctl start myp-platform
```
2. **Configure nginx (optional)**
```bash
sudo cp nginx-myp-platform.conf /etc/nginx/sites-available/myp-platform
sudo ln -s /etc/nginx/sites-available/myp-platform /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```
## Performance Tips
1. **Use a fast SD card** (Class 10 or better)
2. **Enable swap** if you have less than 4GB RAM
3. **Use nginx** for serving static files
4. **Monitor temperature** and use cooling if needed
5. **Disable unnecessary services** to free up resources
## Monitoring
Check application status:
```bash
sudo systemctl status myp-platform
```
View logs:
```bash
sudo journalctl -u myp-platform -f
```
## Troubleshooting
- If the app doesn't start, check logs with `journalctl`
- Ensure all Python dependencies are installed
- Check that port 5000 is not in use
- Verify file permissions in the app directory

View File

@ -0,0 +1,73 @@
"""
Optimized configuration for Raspberry Pi deployment
"""
import os
class OptimizedConfig:
"""Configuration for performance-optimized deployment on Raspberry Pi"""
# Performance optimization flags
OPTIMIZED_MODE = True
USE_MINIFIED_ASSETS = True
DISABLE_ANIMATIONS = True
LIMIT_GLASSMORPHISM = True
# Flask performance settings
DEBUG = False
TESTING = False
SEND_FILE_MAX_AGE_DEFAULT = 31536000 # 1 year cache for static files
# Template settings
TEMPLATES_AUTO_RELOAD = False
EXPLAIN_TEMPLATE_LOADING = False
# Session configuration
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = 'Lax'
# Performance optimizations
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max upload
JSON_SORT_KEYS = False
JSONIFY_PRETTYPRINT_REGULAR = False
# Database optimizations
SQLALCHEMY_ECHO = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ENGINE_OPTIONS = {
'pool_size': 5,
'pool_recycle': 3600,
'pool_pre_ping': True,
'connect_args': {
'check_same_thread': False
}
}
# Cache configuration
CACHE_TYPE = 'simple'
CACHE_DEFAULT_TIMEOUT = 300
CACHE_KEY_PREFIX = 'myp_'
# Static file caching headers
SEND_FILE_MAX_AGE_DEFAULT = 31536000 # 1 year
@staticmethod
def init_app(app):
"""Initialize application with optimized settings"""
# Set optimized template
app.jinja_env.globals['optimized_mode'] = True
app.jinja_env.globals['base_template'] = 'base-optimized.html'
# Add cache headers for static files
@app.after_request
def add_cache_headers(response):
if 'static' in response.headers.get('Location', ''):
response.headers['Cache-Control'] = 'public, max-age=31536000'
response.headers['Vary'] = 'Accept-Encoding'
return response
# Disable unnecessary features
app.config['EXPLAIN_TEMPLATE_LOADING'] = False
app.config['TEMPLATES_AUTO_RELOAD'] = False
print("🚀 Running in OPTIMIZED mode for Raspberry Pi")

View File

@ -0,0 +1,252 @@
"""
Deployment script for Raspberry Pi
Configures the application for optimal performance on resource-constrained devices
"""
import os
import sys
import subprocess
from pathlib import Path
def setup_optimized_environment():
"""Set up environment variables for optimized mode"""
print("Setting up optimized environment for Raspberry Pi...")
# Set environment variables
os.environ['FLASK_ENV'] = 'production'
os.environ['OPTIMIZED_MODE'] = 'true'
os.environ['FLASK_DEBUG'] = '0'
os.environ['PYTHONOPTIMIZE'] = '2' # Remove docstrings and enable optimizations
print("[OK] Environment variables set")
def build_optimized_assets():
"""Build optimized CSS assets"""
print("Building optimized assets...")
# Check if build script exists
build_script = 'build-optimized.bat' if sys.platform == 'win32' else './build-optimized.sh'
if Path(build_script).exists():
try:
subprocess.run([build_script], check=True, shell=True)
print("[OK] Optimized assets built successfully")
except subprocess.CalledProcessError as e:
print(f"[WARNING] Asset build failed: {e}")
else:
print("[WARNING] Build script not found, skipping asset build")
def create_app_runner():
"""Create optimized app runner"""
runner_content = '''#!/usr/bin/env python3
"""
Optimized MYP Platform runner for Raspberry Pi
"""
import os
os.environ['OPTIMIZED_MODE'] = 'true'
os.environ['FLASK_ENV'] = 'production'
from app import create_app
from config_optimized import OptimizedConfig
# Create app with optimized config
app = create_app(OptimizedConfig)
if __name__ == '__main__':
# Run with optimized settings
app.run(
host='0.0.0.0', # Allow external connections
port=5000,
debug=False,
use_reloader=False, # Disable reloader for performance
threaded=True, # Enable threading for better performance
processes=1 # Single process to save memory
)
'''
with open('run_optimized.py', 'w') as f:
f.write(runner_content)
print("[OK] Created run_optimized.py")
def create_systemd_service():
"""Create systemd service file for auto-start"""
service_content = '''[Unit]
Description=MYP Platform Optimized for Raspberry Pi
After=network.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/myp-platform
Environment="PATH=/home/pi/.local/bin:/usr/local/bin:/usr/bin:/bin"
Environment="OPTIMIZED_MODE=true"
Environment="FLASK_ENV=production"
ExecStart=/usr/bin/python3 /home/pi/myp-platform/run_optimized.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
'''
with open('myp-platform.service', 'w') as f:
f.write(service_content)
print("[OK] Created systemd service file: myp-platform.service")
print(" To install: sudo cp myp-platform.service /etc/systemd/system/")
print(" To enable: sudo systemctl enable myp-platform.service")
print(" To start: sudo systemctl start myp-platform.service")
def create_nginx_config():
"""Create nginx configuration for reverse proxy"""
nginx_content = '''server {
listen 80;
server_name _;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
# Static file caching
location /static {
alias /home/pi/myp-platform/static;
expires 1y;
add_header Cache-Control "public, immutable";
add_header Vary "Accept-Encoding";
}
# Proxy to Flask app
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
}
'''
with open('nginx-myp-platform.conf', 'w') as f:
f.write(nginx_content)
print("[OK] Created nginx configuration: nginx-myp-platform.conf")
print(" To install: sudo cp nginx-myp-platform.conf /etc/nginx/sites-available/myp-platform")
print(" To enable: sudo ln -s /etc/nginx/sites-available/myp-platform /etc/nginx/sites-enabled/")
print(" To reload: sudo nginx -s reload")
def create_deployment_readme():
"""Create deployment instructions"""
readme_content = '''# Raspberry Pi Deployment Guide
## Prerequisites
- Raspberry Pi 4 (recommended) or 3B+
- Raspbian OS (latest)
- Python 3.7+
- nginx (optional, for production)
## Quick Start
1. **Clone the repository**
```bash
git clone <repository-url> /home/pi/myp-platform
cd /home/pi/myp-platform
```
2. **Install dependencies**
```bash
sudo apt-get update
sudo apt-get install python3-pip python3-venv nginx
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
3. **Run deployment script**
```bash
python deploy_raspberry_pi.py
```
4. **Start the application**
```bash
python run_optimized.py
```
## Production Deployment
1. **Install as systemd service**
```bash
sudo cp myp-platform.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable myp-platform
sudo systemctl start myp-platform
```
2. **Configure nginx (optional)**
```bash
sudo cp nginx-myp-platform.conf /etc/nginx/sites-available/myp-platform
sudo ln -s /etc/nginx/sites-available/myp-platform /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```
## Performance Tips
1. **Use a fast SD card** (Class 10 or better)
2. **Enable swap** if you have less than 4GB RAM
3. **Use nginx** for serving static files
4. **Monitor temperature** and use cooling if needed
5. **Disable unnecessary services** to free up resources
## Monitoring
Check application status:
```bash
sudo systemctl status myp-platform
```
View logs:
```bash
sudo journalctl -u myp-platform -f
```
## Troubleshooting
- If the app doesn't start, check logs with `journalctl`
- Ensure all Python dependencies are installed
- Check that port 5000 is not in use
- Verify file permissions in the app directory
'''
with open('RASPBERRY_PI_DEPLOYMENT.md', 'w') as f:
f.write(readme_content)
print("[OK] Created deployment guide: RASPBERRY_PI_DEPLOYMENT.md")
def main():
"""Main deployment function"""
print("Raspberry Pi Deployment Setup")
print("================================\n")
# Run all setup steps
setup_optimized_environment()
build_optimized_assets()
create_app_runner()
create_systemd_service()
create_nginx_config()
create_deployment_readme()
print("\n[OK] Deployment setup complete!")
print("\nNext steps:")
print("1. Review RASPBERRY_PI_DEPLOYMENT.md for detailed instructions")
print("2. Test with: python run_optimized.py")
print("3. Deploy as service for production use")
if __name__ == '__main__':
main()

View File

@ -0,0 +1,17 @@
[Unit]
Description=MYP Platform Optimized for Raspberry Pi
After=network.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/myp-platform
Environment="PATH=/home/pi/.local/bin:/usr/local/bin:/usr/bin:/bin"
Environment="OPTIMIZED_MODE=true"
Environment="FLASK_ENV=production"
ExecStart=/usr/bin/python3 /home/pi/myp-platform/run_optimized.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,32 @@
server {
listen 80;
server_name _;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
# Static file caching
location /static {
alias /home/pi/myp-platform/static;
expires 1y;
add_header Cache-Control "public, immutable";
add_header Vary "Accept-Encoding";
}
# Proxy to Flask app
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
}

24
backend/run_optimized.py Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
"""
Optimized MYP Platform runner for Raspberry Pi
"""
import os
os.environ['OPTIMIZED_MODE'] = 'true'
os.environ['FLASK_ENV'] = 'production'
from app import create_app
from config_optimized import OptimizedConfig
# Create app with optimized config
app = create_app(OptimizedConfig)
if __name__ == '__main__':
# Run with optimized settings
app.run(
host='0.0.0.0', # Allow external connections
port=5000,
debug=False,
use_reloader=False, # Disable reloader for performance
threaded=True, # Enable threading for better performance
processes=1 # Single process to save memory
)

View File

@ -1695,16 +1695,25 @@ EOF
# =========================== ROBUSTE SSL-ZERTIFIKATE INSTALLATION ===========================
install_ssl_certificates() {
log "=== ROBUSTE SSL-ZERTIFIKATE KONFIGURATION ==="
log "=== TIMEOUT-GESICHERTE SSL-ZERTIFIKATE KONFIGURATION ==="
progress "Installiere SSL-Grundkomponenten..."
apt_install_retry ca-certificates openssl
progress "Aktualisiere CA-Zertifikate..."
retry_command "update-ca-certificates" "CA-Zertifikate Update"
progress "Aktualisiere CA-Zertifikate (timeout-gesichert)..."
if timeout 30 update-ca-certificates >/dev/null 2>&1; then
success "✅ CA-Zertifikate erfolgreich aktualisiert"
else
warning "⚠️ CA-Zertifikate Update fehlgeschlagen oder Timeout"
debug "Erste CA-Update Timeout - System läuft mit bestehenden Zertifikaten"
fi
# SSL-Verzeichnisse sicherstellen
mkdir -p /usr/local/share/ca-certificates/myp
if mkdir -p /usr/local/share/ca-certificates/myp 2>/dev/null; then
debug "SSL-Verzeichnis erstellt: /usr/local/share/ca-certificates/myp"
else
warning "⚠️ SSL-Verzeichnis konnte nicht erstellt werden"
fi
# Mercedes Corporate Zertifikate (timeout-gesichert)
if [ -d "$CURRENT_DIR/certs/mercedes" ] && [ "$(ls -A $CURRENT_DIR/certs/mercedes 2>/dev/null)" ]; then

File diff suppressed because one or more lines are too long