Problem: Hard-codierte Werte (Fokusbereich, Trainingscharakter) + fehlende Dimensionen (Stil, Fähigkeiten-Matrix) + keine Rollen-basierte Sichtbarkeit Lösung: Dynamische Kataloge mit Admin-CRUD Migration 007_exercise_catalogs.sql: - focus_areas (statt hard-coded 'karate', 'selbstverteidigung', 'gewaltschutz') - training_styles (NEU: Shotokan, Goju-Ryu, Wado-Ryu, etc. mit Hierarchie) - training_characters (statt hard-coded 'grundlage', 'aufbau', etc.) - skill_categories (Matrix: Kategorien → Einzelfähigkeiten) - trainer_focus_areas (Zuordnung: Trainer → Fokusbereiche) - exercises erweitert: training_style_id, training_character_id, focus_area_id - skills erweitert: category_id, parent_skill_id, level, sort_order - Seed-Daten für alle Kataloge Backend (routers/catalogs.py): - CRUD für focus_areas (admin only) - CRUD für training_styles (admin only, mit parent_style_id) - CRUD für training_characters (admin only) - CRUD für skill_categories (admin only, mit parent_category_id) - CRUD für trainer_focus_areas (admin: assign, trainer: read own) - Alle mit status-Filter (active/inactive) Backend (routers/exercises.py): - CREATE/UPDATE erweitert um training_style_id, training_character_id, focus_area_id - Legacy-Felder (focus_area text, training_character text) bleiben parallel Backend (main.py): - catalogs Router registriert Nächster Schritt: Frontend-UI (Admin-Kataloge + Exercise-Formular-Update)
91 lines
2.3 KiB
Python
91 lines
2.3 KiB
Python
"""
|
|
Shinkan Jinkendo - Main Application Entry Point
|
|
|
|
Trainer- und Vereinsplattform für Kampfsport-Trainingsplanung
|
|
"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
import os
|
|
|
|
from version import APP_VERSION, BUILD_DATE, DB_SCHEMA_VERSION, MODULE_VERSIONS
|
|
|
|
# Run database migrations on startup
|
|
try:
|
|
import run_migrations
|
|
run_migrations.main()
|
|
print("✓ Database migrations completed")
|
|
except Exception as e:
|
|
print(f"⚠ Warning: Migration error: {e}")
|
|
print(" Continuing startup - migrations may need manual intervention")
|
|
|
|
# Initialize FastAPI app
|
|
app = FastAPI(
|
|
title="Shinkan Jinkendo API",
|
|
description="Trainer- und Vereinsplattform für Kampfsport-Trainingsplanung",
|
|
version=APP_VERSION
|
|
)
|
|
|
|
# CORS Configuration
|
|
ALLOWED_ORIGINS = os.getenv("ALLOWED_ORIGINS", "http://localhost:3098").split(",")
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=ALLOWED_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# TODO: Initialize Database with migrations
|
|
|
|
# Version Endpoint (public, no auth)
|
|
@app.get("/api/version")
|
|
def get_version():
|
|
"""Get application version and build info"""
|
|
return {
|
|
"app_version": APP_VERSION,
|
|
"build_date": BUILD_DATE,
|
|
"backend_version": APP_VERSION,
|
|
"modules": MODULE_VERSIONS,
|
|
"db_schema_version": DB_SCHEMA_VERSION,
|
|
"environment": os.getenv("ENVIRONMENT", "development")
|
|
}
|
|
|
|
# Health Check
|
|
@app.get("/health")
|
|
def health_check():
|
|
"""Health check endpoint"""
|
|
return {"status": "healthy", "version": APP_VERSION}
|
|
|
|
# Root Endpoint
|
|
@app.get("/")
|
|
def read_root():
|
|
"""Root endpoint - API info"""
|
|
return {
|
|
"app": "Shinkan Jinkendo API",
|
|
"version": APP_VERSION,
|
|
"docs": "/docs",
|
|
"health": "/health"
|
|
}
|
|
|
|
# Register routers
|
|
from routers import auth, profiles, exercises, clubs, skills, training_planning, catalogs
|
|
|
|
app.include_router(auth.router)
|
|
app.include_router(profiles.router)
|
|
app.include_router(exercises.router)
|
|
app.include_router(clubs.router)
|
|
app.include_router(skills.router)
|
|
app.include_router(training_planning.router)
|
|
app.include_router(catalogs.router)
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(
|
|
"main:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
reload=True
|
|
)
|