23-01-2026

This commit is contained in:
Kevin Adametz 2026-01-23 17:35:23 +01:00
parent a939cd51ef
commit a8b395e20d
248 changed files with 29342 additions and 4805 deletions

266
CLAUDE.md
View file

@ -1,187 +1,161 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Projekt-Übersicht
## Project Overview
**mivita.care** - Laravel 11 CRM für Netzwerk-Marketing (MLM) mit E-Commerce, Provisionsberechnung, DHL-Versand und Multi-Tenancy.
This is a Laravel 11 business e-commerce application called "mivita.care" that handles multi-level marketing structures, product sales, payments, and DHL shipping integration. The application supports multi-tenancy through domain resolution and includes comprehensive business analytics and commission calculations.
## Tech Stack
| Komponente | Technologie |
|------------|-------------|
| Framework | Laravel 11 (Classic MVC) |
| Frontend | Bootstrap 4 (Appwork Theme), Blade Templates |
| Auth | Laravel Passport (OAuth2/API) |
| Database | MySQL 8 |
| Data Tables | Yajra Datatables |
| Testing | Pest PHP |
| Queue | Laravel Horizon + Redis |
| PDF | barryvdh/laravel-dompdf |
| Slugs | Eloquent-Sluggable |
| Forms | Spatie\Html |
## Wichtige Regeln (Constraints)
1. **Kein Livewire / Keine Vue-Komponenten** - Nutze reines Blade + Bootstrap
2. **Formulare** - Nutze `Spatie\Html` für Formular-Generierung (nicht reines HTML)
3. **Datentabellen** - Nutze ausschließlich `Yajra\Datatables` für Listenansichten im Admin
4. **PDF** - Rechnungen/Berichte via `barryvdh/laravel-dompdf`
5. **SEO/Slugs** - Nutze `Eloquent-Sluggable` für Berater-Profile/Produkte
6. **Code Style** - Immer `./vendor/bin/pint` nach Änderungen ausführen
## Custom Packages
| Package | Pfad | Beschreibung |
|---------|------|--------------|
| DHL Integration | `packages/acme-laravel-dhl` | Versand-Labels und Tracking |
| Shopping Cart | `packages/digital-bird/shoppingcart` | Warenkorb-System |
## Projekt-Struktur
```
app/
├── Console/Commands/ # Artisan Commands (Business*, User*)
├── Cron/ # Scheduled Task Logic
├── Http/Controllers/ # 40+ Controller
├── Models/ # Eloquent Models
├── Repositories/ # Data Access Layer
├── Services/ # Business Logic
│ └── BusinessPlan/ # MLM-Berechnungen
packages/ # Custom Packages
dev/ # Dokumentation
```
## Wichtige Dateien
- **MLM-Berechnung**: `app/Services/BusinessPlan/TreeCalcBotOptimized.php`
- **Cron Jobs**: `app/Console/Kernel.php`
- **Domain Resolver**: Multi-Tenant Middleware
- **Cart Systems**: AboOrderCart, HomepartyCart, ShopApiOrderCart
## Development Commands
### Core Laravel Commands
### Laravel Basis
```bash
# Run development server
php artisan serve
# Run scheduled tasks
php artisan schedule:run
# Clear application cache
php artisan cache:clear
php artisan serve # Dev Server
php artisan migrate # Migrations
php artisan cache:clear # Cache leeren
php artisan config:clear
php artisan route:clear
php artisan view:clear
# Generate IDE helper files
php artisan ide-helper:generate
php artisan ide-helper:models
php artisan ide-helper:meta
# Database migrations
php artisan migrate
php artisan migrate:rollback
```
### Testing
```bash
# Run tests using Pest
./vendor/bin/pest
# Run specific test
./vendor/bin/pest --filter=TestName
```
### Code Quality
```bash
# Format code using Laravel Pint
./vendor/bin/pint
composer run format
./vendor/bin/pint # Code formatieren
./vendor/bin/pest # Tests ausführen
./vendor/bin/pest --filter=TestName # Einzelner Test
```
### Asset Compilation
### IDE Helper
```bash
# Install node dependencies
npm install
# Development build
npm run dev
npm run watch
# Production build
npm run production
# Asset postinstall (rebuilds node-sass)
npm run postinstall
php artisan ide-helper:generate
php artisan ide-helper:models
php artisan ide-helper:meta
```
### Business-Specific Commands
### Assets
```bash
# Business structure calculations (optimized version - recommended)
npm install && npm run dev # Development
npm run production # Production Build
```
### Business Commands
```bash
# Provisionsberechnung (empfohlen: optimierte Version)
php artisan business:store-optimized {month} {year}
php artisan business:store-optimized {month} {year} --clear
# Legacy business structure command
php artisan business:store {month} {year}
# Daten löschen
php artisan business:clear-data {month} {year} [--force]
# Clear business data
php artisan business:clear-data {month} {year}
php artisan business:clear-data {month} {year} --force
# Level Reports
php artisan business:level-reports {month} {year}
# User management
# User Management
php artisan user:cleanup
php artisan user:make_abo_order
# Payment processing
# Zahlungen
php artisan payments:check-accounts
# Level reports (new feature)
php artisan business:level-reports {month} {year}
# Test account management
# Test Account
php artisan business:test-account
```
## Architecture Overview
## Scheduled Tasks (Cron)
### Multi-Level Marketing Structure
- **TreeCalcBot/TreeCalcBotOptimized**: Core business logic for calculating commission structures and multi-level hierarchies
- **BusinessPlan Services**: Handle commission calculations, sales volumes, and business structure management
- **BusinessController/BusinessControllerOptimized**: Handle business administration and analytics
| Zeit | Command | Beschreibung |
|------|---------|--------------|
| 02:00 | `payments:check-accounts` | Zahlungsprüfung |
| 03:00 | `business:store-optimized 0 0` | Provisionsberechnung |
| 03:30 | `user:cleanup` | User-Bereinigung |
| 04:00 | `user:make_abo_order` | Abo-Bestellungen |
### Domain Architecture
- **Multi-tenant setup** using domain resolution
- **DomainService**: Manages domain-specific configurations and routing
- **DomainResolver Middleware**: Routes requests based on domain
## Docker Environment
### Key Service Classes
- **Payment Services**: Handle various payment methods (Payone, credit systems, invoices)
- **DHL Integration**: Complete shipping solution with label generation and tracking
- **Shopping Cart Systems**: Multiple cart implementations (AboOrderCart, HomepartyCart, ShopApiOrderCart)
- **User Management**: Comprehensive user hierarchy and team management
### Database Structure
- Business users with hierarchical relationships
- Product catalog with categories and ingredients
- Order and payment tracking
- Commission and sales volume calculations
- Multi-domain configurations
### Custom Packages
- **Gloudemans\Shoppingcart**: Custom shopping cart implementation
- **Acme\Dhl**: DHL shipping integration package
- **Alban\LaravelCollectiveSpatieHtmlParser**: HTML parsing utilities
## Scheduled Tasks (Cron Jobs)
The application runs several daily scheduled tasks (defined in `app/Console/Kernel.php`):
- `02:00` - Payment account checks (`payments:check-accounts`)
- `03:00` - Business structure optimization (`store-optimized 0 0`)
- `03:30` - User cleanup (`user:cleanup`)
- `04:00` - Automated subscription orders (`user:make_abo_order`)
## Important File Locations
- **Business Commands**: `app/Console/Commands/Business*.php`
- **Service Classes**: `app/Services/` (extensive service layer)
- **Controllers**: `app/Http/Controllers/` (40+ controllers)
- **Custom Packages**: `packages/` directory
- **Dev Documentation**: `dev/code/Services/*.md` (contains optimization guides)
## Development Notes
### Business Optimization Features
- Use `TreeCalcBotOptimized` for all new business calculation features
- Memory monitoring and automatic garbage collection built into optimized commands
- Comprehensive error handling with graceful degradation
- Performance logging and monitoring capabilities
### DHL Shipping Integration
- Full DHL API integration with both Developer API and Business Customer API support
- Automatic label generation and tracking
- Sandbox/production mode switching
- Complete shipping workflow integration
### Multi-Domain Support
- Each domain can have different configurations
- Domain-specific routing and middleware
- Subdomain management through console commands
### Asset Management
- Laravel Mix for asset compilation
- Appwork theme integration with Bootstrap 4
- Vendor assets management with SASS compilation
- Custom node-sass rebuild process for compatibility
## Docker Development Environment
The project uses Laravel Sail with Docker Compose:
```bash
# Start services
docker-compose up -d
# Execute artisan commands in container
./vendor/bin/sail artisan [command]
# Access container shell
./vendor/bin/sail shell
docker-compose up -d # Services starten
./vendor/bin/sail artisan [command] # Artisan im Container
./vendor/bin/sail shell # Shell im Container
```
### Services:
- **laravel.test**: Main application (Traefik-enabled with SSL)
- **horizon**: Laravel Horizon queue worker
- **mysql**: MySQL 8.0 database server
- **redis**: Redis cache/session store
- **mailpit**: Email testing interface (accessible at mivita-mail.test)
### Services
- **laravel.test** - Hauptanwendung (Traefik + SSL)
- **horizon** - Queue Worker
- **mysql** - MySQL 8.0
- **redis** - Cache/Session
- **mailpit** - Mail Testing (`mivita-mail.test`)
### Domain Configuration:
- Main domain: `mivita.test`
- Wildcard subdomain support: `*.mivita.test`
- Mail interface: `mivita-mail.test`
- Uses Traefik reverse proxy with SSL
### Domains
- Main: `mivita.test`
- Wildcard: `*.mivita.test`
- Mail: `mivita-mail.test`
## MLM-Architektur
### Kernkonzepte
- **Consultants (Berater)**: Hierarchie mit Upline/Downline
- **TreeCalcBotOptimized**: Provisionsberechnung für MLM-Strukturen
- **BusinessPlan Services**: Sales Volumes, Ränge, Boni
### Performance
- Memory Monitoring in optimierten Commands
- Automatic Garbage Collection
- Performance Logging
## Hinweise für Claude
- Nutze immer `TreeCalcBotOptimized` für neue Business-Features
- Prüfe Custom Packages in `packages/` vor Änderungen
- Beachte Multi-Tenant Domain-Logik bei Routing-Änderungen
- DHL-Integration unterstützt Sandbox/Production Mode