Remove deprecated backend files and documentation, including Docker configurations, environment variables, and various scripts, to streamline the project structure and eliminate unused components.
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
- HTTP Broadcast funktioniert nicht -> können IP nicht finden
|
||||
- Backend im Unternehmen, Frontend auf GitHub funktioniert nicht -> Frontend hat HTTPS und Backend nur HTTP, self-signed certificate würde Fehler werfen
|
||||
|
||||
---
|
||||
|
||||
[Knowledge Base - [PG Netzwerk] DHCP/DNS-Services: Anfragen und Änderungen von IP-Adressen/DNS (mercedes-benz.com)](https://servicenow.i.mercedes-benz.com/esc?id=kb_article&table=kb_knowledge&sysparm_article=KB0426678)
|
||||
|
||||
Statische IP beantragen
|
||||
Alias Zuordnung (druckerapp.xyz.corpintra.net)
|
||||
|
||||
!!! SSL Zertifikat???
|
||||
-> [Server-Zertifikat - Employee Center (mercedes-benz.com)](https://servicenow.i.mercedes-benz.com/esc?id=sc_cat_item&table=sc_cat_item&sys_id=7ef47a1c1b0d5450c4f43113dd4bcbf5)
|
||||
8€ (wahrscheinlich einmalig)
|
||||
benötigt Anwenderservice
|
||||
[Application Service (Erstellen) - Employee Center (mercedes-benz.com)](https://servicenow.i.mercedes-benz.com/esc?id=sc_cat_item&table=sc_cat_item&sys_id=ab095def1bf68810c4f43113dd4bcb06)
|
||||
|
||||
|
||||
-> [ServiceNow-Berechtigungen - Employee Center (mercedes-benz.com)](https://servicenow.i.mercedes-benz.com/esc?id=sc_cat_item&table=sc_cat_item&sys_id=8d645a30db3dc4501754ccd40596192c)
|
||||
|
||||
Sollten Sie für Ihre Applikation / Ihr Endgerät eine statisch zugewiesene IP Adresse (S-DHCP), einen manuellen IP-Pool (M-DHCP) oder eine entsprechende neue oder angepasste DNS-Zuordnung benötigen, nutzen Sie bitte die nachfolgenden SNOW-Templates (Hinweis zur Nutzung der Ticket-Templates benötigen Sie die **Service Now - Rechte eines "Agent Fulfilers"**. Die Beantragung für diese Rechte ist über das SNOW Employee Service Portal im Social Intranet möglich: [ServiceNow Permissions - Employee Service Center (mercedes-benz.com))](https://servicenow.i.mercedes-benz.com/esc?id=sc_cat_item&table=sc_cat_item&sys_id=8d645a30db3dc4501754ccd40596192c).
|
||||
-> Martin diesbezüglich Fragen, ob er Sie für sich bestellt?
|
||||
|
||||
---
|
||||
|
||||
- Martin Rechte SNOW
|
||||
- Martin Termin Volker Otto
|
||||
|
||||
[Examples · Diagrams (mingrammer.com)](https://diagrams.mingrammer.com/docs/getting-started/examples)
|
||||
|
||||
Hier ist eine Antwort, die ich mit Microsoft Copilot erhalten habe, der weltweit ersten KI-gestützten Antwort-Engine. Wählen Sie diese Option aus, um die vollständige Antwort anzuzeigen, oder probieren Sie sie selbst aus. https://sl.bing.net/iv24ZLcukjk
|
||||
|
||||
- use devcontainer !!!
|
||||
|
||||
https://x.com/tremorlabs/status/1779873516533547064?s=46
|
||||
|
||||
use mix of shadcn ui and tremor.so blocks
|
||||
|
||||
|
||||
Bestellliste:
|
||||
- 1x Switch
|
||||
- 1x wlan access point
|
||||
- 2x Raspberry Pi (4B / 5)
|
||||
(- Xx LAN-Kabel)
|
||||
- Adapter für 3D-Drucker oder Schaltbare Steckdosen
|
||||
|
||||
-> Datensicherung?!?!?!
|
||||
make it a user thing
|
||||
download db copy
|
||||
import/export
|
||||
OR Zugang zu CORP O über Anwendungsservice??
|
||||
|
||||
|
||||
Move TRILLUM to GITHUB WIKI
|
@@ -1,51 +0,0 @@
|
||||
# Aufräumarbeiten MYP-Projekt (19.05.2025)
|
||||
|
||||
## Durchgeführte Änderungen
|
||||
|
||||
### Verzeichnisstruktur
|
||||
|
||||
- Skriptdateien in logische Kategorien reorganisiert:
|
||||
- `scripts/setup/`: Einrichtungsskripte
|
||||
- `scripts/deployment/`: Bereitstellungsskripte für Raspberry Pi
|
||||
- Neue Verzeichnisse erstellt:
|
||||
- `logs/`: Für Fehlerprotokolle und Logdateien
|
||||
- `config/secure/`: Für sensible Konfigurationsdaten
|
||||
|
||||
### Dokumentation
|
||||
|
||||
- Zentrale `Dokumentation.md` aktualisiert und erweitert
|
||||
- Entwicklungsrichtlinien von `CLAUDE.md` nach `docs/Entwicklungsrichtlinien.md` verschoben
|
||||
- README.md korrigiert und Git-Konfliktmarkierungen entfernt
|
||||
|
||||
### Sicherheit
|
||||
|
||||
- Sensible Daten (CREDENTIALS) in `config/secure/` verschoben
|
||||
- `.gitignore` aktualisiert, um sensible Dateien und temporäre Dateien auszuschließen
|
||||
|
||||
### Dateiorganisation
|
||||
|
||||
- Fehlerlogs in `logs/` verschoben
|
||||
- Temporäre Dateien bereinigt
|
||||
- Skript-Dateien in sinnvolle Kategorien einsortiert
|
||||
|
||||
## Projektstruktur nach Aufräumarbeiten
|
||||
|
||||
```
|
||||
Projektarbeit-MYP/
|
||||
├── backend/ # Flask-Backend
|
||||
├── config/
|
||||
│ └── secure/ # Sensible Konfigurationen
|
||||
├── docs/ # Projektdokumentation
|
||||
├── frontend/
|
||||
├── logs/ # Fehlerprotokolle
|
||||
└── scripts/
|
||||
├── deployment/ # Raspberry Pi Deployment
|
||||
└── setup/ # Einrichtungsskripte
|
||||
```
|
||||
|
||||
## Empfehlungen für zukünftige Arbeiten
|
||||
|
||||
- Gemeinsames Datenbankmodell zwischen Backend und Frontend überarbeiten
|
||||
- Weitere Dokumentation der API-Schnittstellen erstellen
|
||||
- Testabdeckung erhöhen
|
||||
- Deployment-Prozess automatisieren
|
@@ -1,59 +0,0 @@
|
||||
# MYP Project Development Guidelines
|
||||
|
||||
## System Architecture
|
||||
|
||||
- **Frontend**:
|
||||
|
||||
- Located in `frontend`
|
||||
- Runs on a Raspberry Pi connected to company network
|
||||
- Has internet access on one interface
|
||||
- Connected via LAN to an offline network
|
||||
- Serves as the user interface
|
||||
- Developed by another apprentice as part of IHK project work
|
||||
- **Backend**:
|
||||
|
||||
- Located in `backend` directory
|
||||
- Flask application running on a separate Raspberry Pi
|
||||
- Connected only to the offline network
|
||||
- Communicates with WiFi smart plugs
|
||||
- Part of my IHK project work for digital networking qualification
|
||||
- **Printers/Smart Plugs**:
|
||||
|
||||
- Printers can only be controlled (on/off) via WiFi smart plugs
|
||||
- No other control mechanisms available
|
||||
- Smart plugs and printers are equivalent in the system context
|
||||
|
||||
## Build/Run Commands
|
||||
|
||||
- Backend: `cd backend && source venv/bin/activate && python app.py`
|
||||
- Frontend: `cd frontend && pnpm dev`
|
||||
- Run tests: `cd backend && python -m unittest development/tests/tests.py`
|
||||
- Run single test: `cd backend && python -m unittest development.tests.tests.MYPBackendTestCase.test_name`
|
||||
- Check jobs manually: `cd backend && source venv/bin/activate && flask check-jobs`
|
||||
- Lint frontend: `cd frontend && pnpm lint`
|
||||
- Format frontend: `cd frontend && npx @biomejs/biome format --write ./src`
|
||||
|
||||
## Code Style
|
||||
|
||||
- **Python Backend**:
|
||||
|
||||
- Use PEP 8 conventions, 4-space indentation
|
||||
- Line width: 100 characters max
|
||||
- Add docstrings to functions and classes
|
||||
- Error handling: Use try/except with specific exceptions
|
||||
- Naming: snake_case for functions/variables, PascalCase for classes
|
||||
- **Frontend (Next.js/TypeScript)**:
|
||||
|
||||
- Use Biome for formatting and linting (line width: 120 chars)
|
||||
- Organize imports automatically with Biome
|
||||
- Use TypeScript types for all code
|
||||
- Use React hooks for state management
|
||||
- Naming: camelCase for functions/variables, PascalCase for components
|
||||
|
||||
## Work Guidelines
|
||||
|
||||
- All changes must be committed to git
|
||||
- Work efficiently and cost-effectively
|
||||
- Don't repeatedly try the same solution if it doesn't work
|
||||
- Create and check notes when encountering issues
|
||||
- Clearly communicate if something is not possible so I can handle it manually
|
@@ -1,175 +0,0 @@
|
||||
# 🏗️ MYP Projektstruktur - Perfektionierte Architektur
|
||||
|
||||
## 📋 Übersicht
|
||||
|
||||
MYP (Manage your Printer) ist ein containerbasiertes Microservice-System mit klarer Trennung zwischen Frontend und Backend.
|
||||
|
||||
## 🗂️ Verzeichnisstruktur
|
||||
|
||||
```
|
||||
Projektarbeit-MYP/
|
||||
├── 🖥️ backend/ # Flask API Server (Port 5000)
|
||||
│ ├── 📁 src/ # Hauptanwendungslogik
|
||||
│ │ ├── 📁 api/ # API Endpunkte
|
||||
│ │ ├── 📁 models/ # Datenmodelle
|
||||
│ │ ├── 📁 services/ # Geschäftslogik
|
||||
│ │ ├── 📁 auth/ # Authentifizierungslogik
|
||||
│ │ └── 📁 utils/ # Hilfsfunktionen
|
||||
│ ├── 📁 tests/ # Unit- und Integrationstests
|
||||
│ ├── 📁 migrations/ # Datenbankmigrationen
|
||||
│ ├── 📁 instance/ # SQLite Datenbank (gitignore)
|
||||
│ ├── 📁 logs/ # Anwendungslogs (gitignore)
|
||||
│ ├── 📁 config/ # Konfigurationsdateien
|
||||
│ ├── 📄 Dockerfile # Backend Container
|
||||
│ ├── 📄 requirements.txt # Python Abhängigkeiten
|
||||
│ ├── 📄 app.py # Flask Anwendung Einstiegspunkt
|
||||
│ └── 📄 .env.example # Umgebungsvariablen Vorlage
|
||||
│
|
||||
├── 🌐 frontend/ # Next.js Web Interface (Port 3000)
|
||||
│ ├── 📁 src/ # Hauptanwendungslogik
|
||||
│ │ ├── 📁 app/ # Next.js App Router
|
||||
│ │ ├── 📁 components/ # React Komponenten
|
||||
│ │ ├── 📁 lib/ # Bibliotheken und Utilities
|
||||
│ │ └── 📁 types/ # TypeScript Typdefinitionen
|
||||
│ ├── 📁 public/ # Statische Assets
|
||||
│ ├── 📁 drizzle/ # Frontend Datenbankschema
|
||||
│ ├── 📁 tests/ # Frontend Tests
|
||||
│ ├── 📄 Dockerfile # Frontend Container
|
||||
│ ├── 📄 package.json # Node.js Abhängigkeiten
|
||||
│ ├── 📄 next.config.mjs # Next.js Konfiguration
|
||||
│ └── 📄 .env.example # Umgebungsvariablen Vorlage
|
||||
│
|
||||
├── 🔄 proxy/ # Caddy Reverse Proxy (Port 80/443)
|
||||
│ ├── 📄 Caddyfile # Proxy Konfiguration
|
||||
│ └── 📄 docker-compose.caddy.yml # Caddy Service Definition
|
||||
│
|
||||
├── 📊 monitoring/ # Überwachung und Logging
|
||||
│ ├── 📁 grafana/ # Dashboards
|
||||
│ ├── 📁 prometheus/ # Metriken
|
||||
│ └── 📄 docker-compose.monitoring.yml
|
||||
│
|
||||
├── 🔧 infrastructure/ # Infrastruktur-Konfiguration
|
||||
│ ├── 📁 scripts/ # Automatisierungsskripte
|
||||
│ │ ├── 📄 start.sh # Linux/MacOS Start
|
||||
│ │ ├── 📄 start.ps1 # Windows Start
|
||||
│ │ ├── 📄 cleanup.sh # Linux/MacOS Bereinigung
|
||||
│ │ └── 📄 cleanup.ps1 # Windows Bereinigung
|
||||
│ ├── 📁 environments/ # Umgebungskonfigurationen
|
||||
│ │ ├── 📄 development.env # Entwicklungsumgebung
|
||||
│ │ ├── 📄 production.env # Produktionsumgebung
|
||||
│ │ └── 📄 testing.env # Testumgebung
|
||||
│ └── 📁 ssl/ # SSL Zertifikate (gitignore)
|
||||
│
|
||||
├── 📚 docs/ # Projektdokumentation
|
||||
│ ├── 📄 API.md # API Dokumentation
|
||||
│ ├── 📄 DEPLOYMENT.md # Deployment Anweisungen
|
||||
│ ├── 📄 DEVELOPMENT.md # Entwicklungsrichtlinien
|
||||
│ └── 📄 ARCHITECTURE.md # Systemarchitektur
|
||||
│
|
||||
├── 🧪 tests/ # Übergreifende Tests
|
||||
│ ├── 📁 integration/ # Integrationstests
|
||||
│ ├── 📁 e2e/ # End-to-End Tests
|
||||
│ └── 📄 docker-compose.test.yml # Test Environment
|
||||
│
|
||||
├── 📄 docker-compose.yml # Hauptkomposition (Prod)
|
||||
├── 📄 docker-compose.dev.yml # Entwicklungsumgebung
|
||||
├── 📄 docker-compose.override.yml # Lokale Overrides
|
||||
├── 📄 .gitignore # Git Ignorierte Dateien
|
||||
├── 📄 .dockerignore # Docker Ignorierte Dateien
|
||||
├── 📄 README.md # Projekt Hauptdokumentation
|
||||
└── 📄 PROJECT_STRUCTURE.md # Diese Strukturdokumentation
|
||||
```
|
||||
|
||||
## 🔌 Service-Kommunikation
|
||||
|
||||
### Interne Container-Kommunikation
|
||||
- **Frontend → Backend**: `http://backend:5000/api`
|
||||
- **Proxy → Frontend**: `http://frontend:3000`
|
||||
- **Proxy → Backend**: `http://backend:5000`
|
||||
|
||||
### Externe Zugriffe
|
||||
- **Web Interface**: `https://localhost` (über Caddy Proxy)
|
||||
- **API Direct**: `http://localhost:5000` (nur Entwicklung)
|
||||
- **Frontend Direct**: `http://localhost:3000` (nur Entwicklung)
|
||||
|
||||
## 🌐 Netzwerk-Architektur
|
||||
|
||||
```
|
||||
Internet/Intranet
|
||||
↓
|
||||
[Caddy Proxy] (80/443)
|
||||
↓
|
||||
┌─────────┬─────────┐
|
||||
↓ ↓ ↓
|
||||
[Frontend] [Backend] [Monitoring]
|
||||
(3000) (5000) (9090/3001)
|
||||
↓ ↓
|
||||
[SQLite] [SQLite]
|
||||
```
|
||||
|
||||
## 🔐 Sicherheitskonzept
|
||||
|
||||
### Umgebungsvariablen
|
||||
- Sensible Daten nur über `.env` Dateien
|
||||
- Produktionsgeheimnisse über sichere Umgebungsvariablen
|
||||
- Keine Geheimnisse in Git-Repository
|
||||
|
||||
### Netzwerksicherheit
|
||||
- Container-isolierte Netzwerke
|
||||
- Nur notwendige Ports exponiert
|
||||
- HTTPS-Verschlüsselung über Caddy
|
||||
- Firewall-kompatible Konfiguration
|
||||
|
||||
### Authentifizierung
|
||||
- JWT-Token für API-Authentifizierung
|
||||
- Session-basierte Frontend-Authentifizierung
|
||||
- OAuth2 Integration vorbereitet
|
||||
|
||||
## 🚀 Deployment-Strategien
|
||||
|
||||
### Entwicklung
|
||||
```bash
|
||||
# Linux/MacOS
|
||||
./infrastructure/scripts/start.sh dev
|
||||
|
||||
# Windows
|
||||
.\infrastructure\scripts\start.ps1 dev
|
||||
```
|
||||
|
||||
### Produktion
|
||||
```bash
|
||||
# Linux/MacOS
|
||||
./infrastructure/scripts/start.sh prod
|
||||
|
||||
# Windows
|
||||
.\infrastructure\scripts\start.ps1 prod
|
||||
```
|
||||
|
||||
## 📦 Container-Optimierungen
|
||||
|
||||
### Multi-Stage Builds
|
||||
- Frontend: Node.js Build → Minimales Runtime Image
|
||||
- Backend: Python Requirements → Optimiertes Laufzeit-Image
|
||||
- Reduzierte Image-Größen und Sicherheitsoberfläche
|
||||
|
||||
### Health Checks
|
||||
- Automatische Gesundheitsprüfungen für alle Services
|
||||
- Graceful Restart bei Fehlern
|
||||
- Monitoring-Integration
|
||||
|
||||
### Volume Management
|
||||
- Persistente Datenbank-Volumes
|
||||
- Log-Rotation und -Management
|
||||
- Backup-freundliche Struktur
|
||||
|
||||
## 🔄 CI/CD Integration
|
||||
|
||||
### Git Hooks
|
||||
- Pre-commit Linting und Testing
|
||||
- Automatische Dependency Updates
|
||||
- Security Scanning
|
||||
|
||||
### Container Registry
|
||||
- Automatisches Image Building
|
||||
- Versionierung über Git Tags
|
||||
- Multi-Architecture Support (x86_64, ARM64)
|
@@ -1,80 +0,0 @@
|
||||
# MYP OAuth Konfigurationsanleitung
|
||||
|
||||
Dieses Dokument beschreibt, wie die OAuth-Konfiguration für das MYP-Projekt eingerichtet wird.
|
||||
|
||||
## Überblick
|
||||
|
||||
Das MYP Frontend verwendet GitHub OAuth zur Authentifizierung. Die Konfiguration erfolgt über
|
||||
Umgebungsvariablen, die in der Datei `/srv/myp-env/github.env` gespeichert werden.
|
||||
|
||||
## Konfiguration mit configure-oauth.sh
|
||||
|
||||
Wir haben ein Skript erstellt, um die OAuth-Konfiguration zu vereinfachen:
|
||||
|
||||
```bash
|
||||
sudo ./configure-oauth.sh
|
||||
```
|
||||
|
||||
Das Skript führt folgende Aktionen aus:
|
||||
|
||||
1. Erfasst die benötigten OAuth-Konfigurationsinformationen interaktiv
|
||||
2. Speichert diese in `/srv/myp-env/github.env`
|
||||
3. Aktualisiert einen laufenden Docker-Container (falls vorhanden)
|
||||
4. Bietet die Option, den Container neu zu starten
|
||||
|
||||
## Benötigte Informationen
|
||||
|
||||
Für die Konfiguration werden folgende Informationen benötigt:
|
||||
|
||||
1. **GitHub-Typ**: GitHub Enterprise (git.i.mercedes-benz.com) oder GitHub.com
|
||||
2. **OAuth Callback URL**: Die URL, zu der GitHub nach der Authentifizierung zurückleitet
|
||||
- Standard für Unternehmensumgebung: `http://m040tbaraspi001.de040.corpintra.net/auth/login/callback`
|
||||
- Standard für lokale Entwicklung: `http://localhost:3000/auth/login/callback`
|
||||
3. **GitHub OAuth Client ID**: Von der GitHub OAuth App-Konfiguration
|
||||
4. **GitHub OAuth Client Secret**: Von der GitHub OAuth App-Konfiguration
|
||||
|
||||
## Konfiguration der GitHub OAuth App
|
||||
|
||||
1. Navigieren Sie zu Ihren GitHub-Einstellungen (Organisationseinstellungen für Enterprise)
|
||||
2. Wählen Sie "OAuth Apps" oder "Developer Settings" > "OAuth Apps"
|
||||
3. Erstellen Sie eine neue OAuth App mit:
|
||||
- **Name**: MYP (Manage Your Printer)
|
||||
- **Homepage URL**: `http://m040tbaraspi001.de040.corpintra.net` (oder Ihre lokale URL)
|
||||
- **Authorization callback URL**: Exakt die URL, die Sie auch im Skript konfigurieren
|
||||
- **Description**: Optional
|
||||
|
||||
## Umgebungsvariablen
|
||||
|
||||
Die folgenden Umgebungsvariablen werden vom Skript konfiguriert:
|
||||
|
||||
```
|
||||
# OAuth Callback URL
|
||||
NEXT_PUBLIC_OAUTH_CALLBACK_URL=http://m040tbaraspi001.de040.corpintra.net/auth/login/callback
|
||||
OAUTH_CALLBACK_URL=http://m040tbaraspi001.de040.corpintra.net/auth/login/callback
|
||||
|
||||
# GitHub OAuth Credentials
|
||||
AUTH_GITHUB_CLIENT_ID=your_client_id
|
||||
AUTH_GITHUB_CLIENT_SECRET=your_client_secret
|
||||
|
||||
# Kompatibilitäts-Variablen
|
||||
OAUTH_CLIENT_ID=your_client_id
|
||||
OAUTH_CLIENT_SECRET=your_client_secret
|
||||
|
||||
# GitHub Server-Konfiguration
|
||||
GITHUB_ENTERPRISE=true
|
||||
GITHUB_DOMAIN=https://git.i.mercedes-benz.com
|
||||
```
|
||||
|
||||
## Deployment mit OAuth-Konfiguration
|
||||
|
||||
Die Deployment-Skripte `raspi-frontend-deploy.sh` sind so konfiguriert, dass sie die OAuth-Konfiguration aus
|
||||
`/srv/myp-env/github.env` laden und dem Container zur Verfügung stellen.
|
||||
|
||||
## Fehlerbehebung
|
||||
|
||||
Falls die OAuth-Authentifizierung nicht funktioniert:
|
||||
|
||||
1. Prüfen Sie, ob die Callback-URL exakt mit der in GitHub konfigurierten URL übereinstimmt
|
||||
2. Stellen Sie sicher, dass der Docker-Container die Umgebungsvariablen korrekt übernimmt
|
||||
3. Überprüfen Sie die Netzwerkerreichbarkeit zwischen dem Frontend und dem GitHub-Server
|
||||
4. Prüfen Sie die Frontend-Logs auf OAuth-bezogene Fehlermeldungen
|
@@ -1,287 +0,0 @@
|
||||
# 🏗️ MYP - Separate Server Architektur
|
||||
|
||||
## Übersicht
|
||||
|
||||
Das MYP-System wurde in **zwei vollständig unabhängige Server** aufgeteilt:
|
||||
|
||||
- **🏭 Backend-Server** (Port 5000): Flask-API für Geschäftslogik und Datenmanagement
|
||||
- **🎨 Frontend-Server** (Port 3000): Next.js-Anwendung für Benutzeroberfläche
|
||||
|
||||
## 🔗 Server-Kommunikation
|
||||
|
||||
```
|
||||
┌─────────────────┐ HTTP/API ┌─────────────────┐
|
||||
│ Frontend │◄───────────────►│ Backend │
|
||||
│ (Next.js) │ │ (Flask) │
|
||||
│ Port: 3000 │ │ Port: 5000 │
|
||||
└─────────────────┘ └─────────────────┘
|
||||
```
|
||||
|
||||
## 🚀 Separate Server starten
|
||||
|
||||
### Backend-Server (unabhängig)
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
./start-backend-server.sh
|
||||
|
||||
# Alternative mit Logs
|
||||
./start-backend-server.sh --logs
|
||||
|
||||
# Vollständige Neuinstallation
|
||||
./start-backend-server.sh --clean
|
||||
```
|
||||
|
||||
**Backend verfügbar unter:**
|
||||
|
||||
- 📡 Backend-API: http://localhost:5000
|
||||
- 🔧 Health-Check: http://localhost:5000/health
|
||||
- 📋 API-Docs: http://localhost:5000/swagger
|
||||
|
||||
### Frontend-Server (unabhängig)
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
./start-frontend-server.sh
|
||||
|
||||
# Alternative mit Logs
|
||||
./start-frontend-server.sh --logs
|
||||
|
||||
# Vollständige Neuinstallation
|
||||
./start-frontend-server.sh --clean
|
||||
```
|
||||
|
||||
**Frontend verfügbar unter:**
|
||||
|
||||
- 🌐 Web-App: http://localhost:3000
|
||||
- 🔧 Health-Check: http://localhost:3000/health
|
||||
- 📦 CDN-Assets: http://localhost:8080
|
||||
|
||||
## ⚙️ Konfiguration
|
||||
|
||||
### Backend-Konfiguration
|
||||
|
||||
**Datei:** `backend/env.backend`
|
||||
|
||||
```bash
|
||||
# Backend-Server
|
||||
PORT=5000
|
||||
BACKEND_URL=http://localhost:5000
|
||||
|
||||
# CORS für Frontend-Zugriff
|
||||
CORS_ORIGINS=http://localhost:3000,https://frontend.myp.local
|
||||
|
||||
# Datenbank
|
||||
DATABASE_PATH=instance/myp.db
|
||||
|
||||
# Cache
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
```
|
||||
|
||||
### Frontend-Konfiguration
|
||||
|
||||
**Datei:** `frontend/env.frontend`
|
||||
|
||||
```bash
|
||||
# Frontend-Server
|
||||
PORT=3000
|
||||
FRONTEND_URL=http://localhost:3000
|
||||
|
||||
# Backend-API Verbindung
|
||||
BACKEND_API_URL=http://localhost:5000/api
|
||||
NEXT_PUBLIC_API_URL=http://localhost:5000/api
|
||||
|
||||
# Cache
|
||||
FRONTEND_REDIS_PORT=6380
|
||||
```
|
||||
|
||||
## 🐋 Docker-Container
|
||||
|
||||
### Backend-Container
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
docker-compose -f docker-compose.backend.yml up -d
|
||||
|
||||
# Services:
|
||||
# - myp-backend-standalone (Port 5000)
|
||||
# - myp-backend-db (PostgreSQL, Port 5432)
|
||||
# - myp-backend-cache (Redis, Port 6379)
|
||||
```
|
||||
|
||||
### Frontend-Container
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
docker-compose -f docker-compose.frontend.yml up -d
|
||||
|
||||
# Services:
|
||||
# - myp-frontend-standalone (Port 3000)
|
||||
# - myp-frontend-cache (Redis, Port 6380)
|
||||
# - myp-frontend-cdn (Nginx, Port 8080)
|
||||
```
|
||||
|
||||
## 🔒 Sicherheit
|
||||
|
||||
### CORS-Konfiguration
|
||||
|
||||
Das Backend ist für **explizite Frontend-Origins** konfiguriert:
|
||||
|
||||
```python
|
||||
# Backend: app.py
|
||||
CORS(app,
|
||||
origins=['http://localhost:3000', 'https://frontend.myp.local'],
|
||||
supports_credentials=True,
|
||||
allow_headers=['Content-Type', 'Authorization', 'X-Requested-With'],
|
||||
methods=['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'])
|
||||
```
|
||||
|
||||
### API-Authentifizierung
|
||||
|
||||
- **JWT-Tokens** für API-Zugriff
|
||||
- **Session-basierte** Authentifizierung für Web-UI
|
||||
- **Separate Secrets** für Frontend und Backend
|
||||
|
||||
## 📊 Monitoring
|
||||
|
||||
### Health-Checks
|
||||
|
||||
**Backend:** GET http://localhost:5000/health
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "healthy",
|
||||
"service": "myp-backend",
|
||||
"database": "connected",
|
||||
"timestamp": "2024-01-15T10:30:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
**Frontend:** GET http://localhost:3000/health
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "healthy",
|
||||
"service": "myp-frontend",
|
||||
"backend": {
|
||||
"url": "http://localhost:5000",
|
||||
"status": "connected"
|
||||
},
|
||||
"timestamp": "2024-01-15T10:30:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Logs verfolgen
|
||||
|
||||
```bash
|
||||
# Backend-Logs
|
||||
cd backend
|
||||
docker-compose -f docker-compose.backend.yml logs -f
|
||||
|
||||
# Frontend-Logs
|
||||
cd frontend
|
||||
docker-compose -f docker-compose.frontend.yml logs -f
|
||||
```
|
||||
|
||||
## 🔧 Troubleshooting
|
||||
|
||||
### Backend startet nicht
|
||||
|
||||
```bash
|
||||
# 1. Prüfe Ports
|
||||
netstat -an | grep 5000
|
||||
|
||||
# 2. Prüfe Backend-Logs
|
||||
cd backend
|
||||
docker-compose -f docker-compose.backend.yml logs backend
|
||||
|
||||
# 3. Datenbank-Migration
|
||||
docker-compose -f docker-compose.backend.yml exec backend flask db upgrade
|
||||
```
|
||||
|
||||
### Frontend kann Backend nicht erreichen
|
||||
|
||||
```bash
|
||||
# 1. Prüfe Backend-Verfügbarkeit
|
||||
curl http://localhost:5000/health
|
||||
|
||||
# 2. Prüfe CORS-Konfiguration
|
||||
curl -H "Origin: http://localhost:3000" \
|
||||
-H "Access-Control-Request-Method: GET" \
|
||||
-H "Access-Control-Request-Headers: Content-Type" \
|
||||
-X OPTIONS http://localhost:5000/api/printers
|
||||
|
||||
# 3. Prüfe Frontend-Umgebungsvariablen
|
||||
cd frontend
|
||||
grep BACKEND env.frontend
|
||||
```
|
||||
|
||||
### Port-Konflikte
|
||||
|
||||
```bash
|
||||
# Standard-Ports ändern
|
||||
# Backend: PORT=5001 in env.backend
|
||||
# Frontend: PORT=3001 in env.frontend
|
||||
|
||||
# Neue URLs in beiden Konfigurationen anpassen
|
||||
```
|
||||
|
||||
## 🌐 Deployment
|
||||
|
||||
### Produktions-Deployment
|
||||
|
||||
```bash
|
||||
# Backend (Server 1)
|
||||
cd backend
|
||||
FLASK_ENV=production ./start-backend-server.sh
|
||||
|
||||
# Frontend (Server 2)
|
||||
cd frontend
|
||||
NODE_ENV=production BACKEND_API_URL=https://api.myp.de ./start-frontend-server.sh
|
||||
```
|
||||
|
||||
### Reverse Proxy (Optional)
|
||||
|
||||
Für Produktion können beide Server hinter einem Reverse Proxy laufen:
|
||||
|
||||
```
|
||||
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
||||
│ Client │────►│ Nginx/Caddy │────►│ Frontend │
|
||||
│ │ │ │ ┌─►│ :3000 │
|
||||
└─────────────┘ │ /api/* ─────┤──┘ └─────────────┘
|
||||
│ │ ┌─►┌─────────────┐
|
||||
│ /api/* ─────┤──┘ │ Backend │
|
||||
└─────────────┘ │ :5000 │
|
||||
└─────────────┘
|
||||
```
|
||||
|
||||
## 📁 Dateistruktur
|
||||
|
||||
```
|
||||
Projektarbeit-MYP/
|
||||
├── backend/ # 🏭 Backend-Server
|
||||
│ ├── docker-compose.backend.yml # Docker-Konfiguration
|
||||
│ ├── start-backend-server.sh # Start-Skript
|
||||
│ ├── env.backend # Umgebungsvariablen
|
||||
│ └── app.py # Flask-Anwendung
|
||||
├── frontend/ # 🎨 Frontend-Server
|
||||
│ ├── docker-compose.frontend.yml # Docker-Konfiguration
|
||||
│ ├── start-frontend-server.sh # Start-Skript
|
||||
│ ├── env.frontend # Umgebungsvariablen
|
||||
│ └── src/ # Next.js-Anwendung
|
||||
└── SEPARATE_SERVERS_GUIDE.md # Diese Dokumentation
|
||||
```
|
||||
|
||||
## ✅ Vorteile der Trennung
|
||||
|
||||
1. **🔄 Unabhängige Skalierung** - Frontend und Backend können getrennt skaliert werden
|
||||
2. **🚀 Separate Deployments** - Updates können unabhängig deployed werden
|
||||
3. **🛡️ Verbesserte Sicherheit** - Klare API-Grenzen und CORS-Kontrolle
|
||||
4. **🔧 Technologie-Flexibilität** - Frontend und Backend können verschiedene Technologien verwenden
|
||||
5. **📊 Besseres Monitoring** - Separate Health-Checks und Logs
|
||||
6. **🏗️ Microservice-Ready** - Vorbereitung für Microservice-Architektur
|
||||
|
||||
---
|
||||
|
||||
**Hinweis:** Die alte gekoppelte Konfiguration ist weiterhin in `docker-compose.yml` verfügbar, wird aber für neue Deployments nicht empfohlen.
|
Reference in New Issue
Block a user