📚 Improved configuration files & documentation 📚
This commit is contained in:
118
backend/docs/DATENBANK_KONFIGURATION.md
Normal file
118
backend/docs/DATENBANK_KONFIGURATION.md
Normal file
@@ -0,0 +1,118 @@
|
||||
# Datenbank-Konfiguration MYP Platform
|
||||
|
||||
## Übersicht
|
||||
|
||||
Die MYP Platform verwendet **ausschließlich** eine SQLite-Datenbank:
|
||||
|
||||
```
|
||||
database/myp.db
|
||||
```
|
||||
|
||||
## Konfiguration
|
||||
|
||||
### Haupt-Konfiguration
|
||||
- **Datei**: `config/settings.py`
|
||||
- **Variable**: `DATABASE_PATH = os.path.join(BASE_DIR, "database", "myp.db")`
|
||||
- **Engine**: SQLite mit WAL-Modus (Write-Ahead Logging)
|
||||
|
||||
### Sichergestellte Konsistenz
|
||||
|
||||
Alle folgenden Dateien wurden korrigiert, um ausschließlich `database/myp.db` zu verwenden:
|
||||
|
||||
#### ✅ Konfigurationsdateien
|
||||
- `config/settings.py` - Haupt-Konfiguration
|
||||
- `config/app_config.py` - Alternative Flask-Konfiguration (korrigiert)
|
||||
|
||||
#### ✅ Model- und Datenbankdateien
|
||||
- `models.py` - Hauptmodelle und Engine-Konfiguration
|
||||
- `database/db_manager.py` - Datenbank-Manager
|
||||
|
||||
#### ✅ Utilities und Tools
|
||||
- `utils/migrate_db.py` - Datenbank-Migration (Legacy-Fallbacks entfernt)
|
||||
- `utils/quick_fix.py` - Schnelle Reparatur-Tools (korrigiert)
|
||||
- `utils/debug_drucker_erkennung.py` - Debug-Tools (korrigiert)
|
||||
- `utils/database_utils.py` - Backup und Wartung
|
||||
- `utils/database_cleanup.py` - Cleanup-Manager
|
||||
- `utils/database_schema_migration.py` - Schema-Migration
|
||||
|
||||
### Entfernte/Korrigierte Inkonsistenzen
|
||||
|
||||
#### 🗑️ Gelöschte Dateien
|
||||
- `database/production.db` (leer, 0KB) - entfernt
|
||||
|
||||
#### 🔧 Korrigierte Fallbacks
|
||||
- **Entfernt**: Referenzen zu `app.db`, `database.db`, `data/myp_platform.db`
|
||||
- **Korrigiert**: Tabellennamen von `printer` zu `printers`
|
||||
- **Vereinheitlicht**: Alle Import-Pfade verwenden `config.settings.DATABASE_PATH`
|
||||
|
||||
## Verwendung
|
||||
|
||||
### Datenbank initialisieren
|
||||
```python
|
||||
from models import init_db
|
||||
init_db()
|
||||
```
|
||||
|
||||
### Session verwenden
|
||||
```python
|
||||
from models import get_cached_session
|
||||
|
||||
with get_cached_session() as session:
|
||||
# Datenbankoperationen
|
||||
pass
|
||||
```
|
||||
|
||||
### Backup erstellen
|
||||
```python
|
||||
from utils.database_utils import DatabaseBackupManager
|
||||
|
||||
backup_manager = DatabaseBackupManager()
|
||||
backup_manager.create_backup()
|
||||
```
|
||||
|
||||
## Optimierungen
|
||||
|
||||
Die Datenbank ist für Produktionsumgebung optimiert:
|
||||
|
||||
- **WAL-Modus**: Write-Ahead Logging für bessere Performance
|
||||
- **Connection Pooling**: Optimierte Verbindungsverwaltung
|
||||
- **Caching**: Intelligent caching system für häufige Abfragen
|
||||
- **Auto-Vacuum**: Automatische Speicherbereinigung
|
||||
- **Indizierung**: Optimierte Indizes für bessere Performance
|
||||
|
||||
## Wartung
|
||||
|
||||
### Automatische Wartung
|
||||
- WAL-Checkpoints alle 1000 Seiten
|
||||
- Incremental Vacuum alle 60 Minuten
|
||||
- Statistik-Updates alle 30 Minuten
|
||||
|
||||
### Manuelle Wartung
|
||||
```bash
|
||||
# Migration ausführen
|
||||
python utils/migrate_db.py
|
||||
|
||||
# Schnelle Reparatur
|
||||
python utils/quick_fix.py
|
||||
|
||||
# Diagnose
|
||||
python utils/debug_drucker_erkennung.py
|
||||
```
|
||||
|
||||
## Wichtige Hinweise
|
||||
|
||||
⚠️ **NUR `database/myp.db` verwenden!**
|
||||
|
||||
- Keine anderen Datenbankdateien verwenden
|
||||
- Alle Tools und Scripts sind auf diese Datei konfiguriert
|
||||
- Bei Problemen: Backup aus `database/backups/` verwenden
|
||||
|
||||
🔒 **Backup-Strategie**
|
||||
- Automatische Backups in `database/backups/`
|
||||
- Vor größeren Operationen manuelles Backup erstellen
|
||||
- WAL- und SHM-Dateien gehören zur Datenbank (nicht löschen!)
|
||||
|
||||
📊 **Monitoring**
|
||||
- Log-Dateien in `logs/app/`
|
||||
- Performance-Monitoring via `utils/database_utils.py`
|
||||
- Health-Checks über API-Endpunkte verfügbar
|
119
backend/docs/WINDOWS_INSTALLATION.md
Normal file
119
backend/docs/WINDOWS_INSTALLATION.md
Normal file
@@ -0,0 +1,119 @@
|
||||
# MYP Platform - Windows Installation
|
||||
|
||||
## Überblick
|
||||
Das MYP (Multi-User-Print) System ist ein Flask-basiertes Backend für Druckerverwaltung, das vollständig auf Windows kompatibel ist.
|
||||
|
||||
## Systemanforderungen
|
||||
- Windows 10/11
|
||||
- Python 3.8+
|
||||
- Git (optional)
|
||||
- Internetverbindung für Paketinstallation
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Python-Abhängigkeiten installieren
|
||||
```powershell
|
||||
# Im Projektverzeichnis
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 2. Datenbank initialisieren
|
||||
```powershell
|
||||
python -c "from models import init_database, create_initial_admin; init_database(); create_initial_admin()"
|
||||
```
|
||||
|
||||
### 3. Anwendung starten
|
||||
```powershell
|
||||
python app.py
|
||||
```
|
||||
|
||||
## Automatischer Start (Windows Service)
|
||||
|
||||
### Service-Wrapper erstellen
|
||||
Das System kann als Windows-Service installiert werden.
|
||||
|
||||
### PowerShell-Skript für automatischen Start
|
||||
```powershell
|
||||
# start-myp.ps1
|
||||
$env:FLASK_ENV = "production"
|
||||
$env:FLASK_APP = "app.py"
|
||||
python app.py
|
||||
```
|
||||
|
||||
## Verfügbare Endpunkte
|
||||
- **Frontend**: http://localhost:5000
|
||||
- **API**: http://localhost:5000/api/
|
||||
- **Admin**: http://localhost:5000/admin
|
||||
|
||||
## Standard-Login
|
||||
- **Benutzername**: admin@admin.de
|
||||
- **Passwort**: admin
|
||||
|
||||
## Konfiguration
|
||||
|
||||
### Ports anpassen
|
||||
In `app.py` am Ende der Datei:
|
||||
```python
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000, debug=False)
|
||||
```
|
||||
|
||||
### SSL/HTTPS aktivieren
|
||||
```python
|
||||
# SSL-Kontext für HTTPS
|
||||
ssl_context = ('cert.pem', 'key.pem')
|
||||
app.run(host="0.0.0.0", port=443, ssl_context=ssl_context)
|
||||
```
|
||||
|
||||
## Fehlerbehebung
|
||||
|
||||
### Port bereits in Verwendung
|
||||
```powershell
|
||||
# Prozess finden und beenden
|
||||
netstat -ano | findstr :5000
|
||||
taskkill /PID [PID] /F
|
||||
```
|
||||
|
||||
### Python-Module fehlen
|
||||
```powershell
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt --force-reinstall
|
||||
```
|
||||
|
||||
### Datenbankfehler
|
||||
```powershell
|
||||
# Datenbank zurücksetzen
|
||||
del database\myp.db
|
||||
python -c "from models import init_database, create_initial_admin; init_database(); create_initial_admin()"
|
||||
```
|
||||
|
||||
## Entwicklungsmodus
|
||||
```powershell
|
||||
$env:FLASK_ENV = "development"
|
||||
$env:FLASK_DEBUG = "1"
|
||||
python app.py
|
||||
```
|
||||
|
||||
## Logs
|
||||
- **Anwendung**: `logs/app/`
|
||||
- **Authentifizierung**: `logs/auth/`
|
||||
- **Fehler**: `logs/errors/`
|
||||
- **Jobs**: `logs/jobs/`
|
||||
|
||||
## Windows-spezifische Features
|
||||
- Automatische Windows-Kompatibilitätsfixes
|
||||
- WMI-Integration für Systemüberwachung
|
||||
- Windows-Event-Log-Integration
|
||||
- Windows-Service-Support
|
||||
|
||||
## Sicherheit
|
||||
- CSRF-Schutz aktiviert
|
||||
- Rate-Limiting implementiert
|
||||
- Sichere Session-Verwaltung
|
||||
- SQL-Injection-Schutz
|
||||
|
||||
## Performance-Optimierung
|
||||
- SQLite-Optimierungen für Windows
|
||||
- Caching-Strategien
|
||||
- Asynchrone Task-Verarbeitung
|
||||
- Memory-Management
|
Reference in New Issue
Block a user