🎉 Added 'backend/ANTI_HAENGE_OPTIMIERUNGEN.md', updated 'backend/CLAUDE.md' and 'backend/setup.sh'. Also added 'backend/test-setup.sh'. Ignored 'IHK_Projektdokumentation/~$kumentation.docx'.

This commit is contained in:
2025-06-04 06:51:14 +02:00
parent 61b1cced0d
commit 14e239091f
4 changed files with 304 additions and 349 deletions

View File

@@ -2,6 +2,69 @@
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
SYSTEM INSTRUCTIONS
ROLE
- High-intelligence Project Code Developer (no Windows testing)
CONDUCT
- Solve every task immediately; no delegation or delay
- Follow project structure exactly
- Write all code, comments, UI texts and docs exclusively in formal German
ROADMAP
- Update dynamically with every change
- Document all adjustments clearly
DOCUMENTATION
- Comprehensive internal docs (docstrings, inline comments)
- Separate external project documentation file
ERROR HANDLING
- Log description, root cause, fix and prevention for each error
- Maintain error log and adapt future work accordingly
CASCADE ANALYSIS
- Before any change list all impacted modules, functions, classes and endpoints
- Update and validate each to preserve integrity
- Prevent endpoint errors, broken interfaces and side effects
SELF-VERIFICATION
- After each major step run checklist
- Functional correctness
- Referential & structural integrity
- Complete documentation
- Cascade consistency
QUALITY
- Deliver production-grade output unless explicitly told otherwise
- Ensure flawless functionality, structural cohesion and full documentation
FILES
- Auto-store all *.md files in DOCS; exception: README.md at root
ENVIRONMENT
- Operating system Windows PC
ACTION
- Fix issues as fast as possible
- Never delegate to the user
- Perform all feasible tasks autonomously
DO NOT CREATE WINDOWS SPECIFIC FILES. WE DO NOT DEVELOP FOR WINDOWS UNLESS SPECIFICALLY TOLD OTHERWISE
## Project Overview
MYP (Manage Your Printers) is a comprehensive 3D printer management system for Mercedes-Benz, designed to run on Debian/Linux systems (especially Raspberry Pi) in HTTPS kiosk mode. The system manages printer scheduling, user authentication, job queuing, and smart plug integration with TP-Link Tapo devices.
@@ -9,6 +72,7 @@ MYP (Manage Your Printers) is a comprehensive 3D printer management system for M
## Essential Commands
### Development
```bash
# Install dependencies
pip install -r requirements.txt --break-system-packages
@@ -26,6 +90,7 @@ sudo python app.py
```
### Testing & Validation
```bash
# Lint Python code
flake8 .
@@ -44,6 +109,7 @@ python -c "from models import init_database; init_database()"
```
### Deployment & Services
```bash
# Full installation (use setup.sh)
sudo ./setup.sh
@@ -59,6 +125,7 @@ tail -f logs/app/app.log
```
### Database Operations
```bash
# Initialize database
python -c "from models import init_database; init_database()"
@@ -73,6 +140,7 @@ python utils/database_cleanup.py
## Architecture Overview
### Core Structure
The application follows a Flask blueprint architecture with clear separation of concerns:
- **app.py**: Main application entry point with HTTPS configuration and optimizations for Raspberry Pi
@@ -89,22 +157,23 @@ The application follows a Flask blueprint architecture with clear separation of
### Key Design Patterns
1. **Database Sessions**: Uses scoped sessions with proper cleanup
```python
with get_db_session() as session:
# Database operations
```
2. **Permission System**: Role-based with specific permissions
- Decorators: `@login_required`, `@admin_required`, `@permission_required`
- Permissions: `can_manage_printers`, `can_approve_jobs`, etc.
3. **Conflict Management**: Smart printer assignment based on:
- Availability windows
- Priority levels (urgent, high, normal, low)
- Job duration compatibility
- Real-time conflict detection
4. **Logging Strategy**: Modular logging with separate files per component
```python
from utils.logging_config import get_logger
logger = get_logger("component_name")
@@ -128,17 +197,18 @@ The application follows a Flask blueprint architecture with clear separation of
### Performance Optimizations
1. **Raspberry Pi Specific**:
- Reduced animations and glassmorphism effects
- Minified assets with gzip compression
- Optimized SQLite settings for SD cards
- Memory-efficient session handling
2. **Caching Strategy**:
- Static file caching (1 year)
- Database query caching
- Session-based caching for expensive operations
3. **Database Optimizations**:
- WAL mode for concurrent access
- Proper indexing on foreign keys
- Connection pooling with StaticPool
@@ -146,17 +216,18 @@ The application follows a Flask blueprint architecture with clear separation of
### Integration Points
1. **TP-Link Tapo Smart Plugs**:
1. **TP-Link Tapo Smart Plugs**:
- PyP100 library for device control
- Status monitoring and scheduling
- Automatic power management
2. **Email Notifications**:
- Guest request notifications
- Job completion alerts
- System status updates
3. **File Uploads**:
- Support for STL, OBJ, 3MF, AMF, GCODE
- Secure file handling with validation
- Organized storage in uploads/ directory
@@ -167,9 +238,9 @@ When adding new features:
1. **New Blueprint**: Create in `blueprints/`, register in `app.py`
2. **Database Model**: Add to `models.py`, create migration if needed
3. **Frontend Assets**:
3. **Frontend Assets**:
- CSS in `static/css/components.css`
- JavaScript in `static/js/`
- JavaScript in `static/js/`
- Run `npm run build:css` after CSS changes
4. **Logging**: Use `get_logger("component_name")` for consistent logging
5. **Permissions**: Add new permissions to `UserPermission` model
@@ -180,4 +251,4 @@ When adding new features:
- Use `--debug` flag for development server
- Database locked errors: Check for WAL files (`*.db-wal`, `*.db-shm`)
- SSL issues: Regenerate certificates with `utils/ssl_config.py`
- Performance issues: Check `/api/stats` endpoint for metrics
- Performance issues: Check `/api/stats` endpoint for metrics