2026-04-21 14:26:12 +02:00
|
|
|
"""
|
|
|
|
|
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
|
2026-04-21 14:49:28 +02:00
|
|
|
|
|
|
|
|
# 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")
|
2026-04-21 14:26:12 +02:00
|
|
|
|
|
|
|
|
# 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=["*"],
|
|
|
|
|
)
|
|
|
|
|
|
2026-04-21 14:49:28 +02:00
|
|
|
# TODO: Initialize Database with migrations
|
2026-04-21 14:26:12 +02:00
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-21 14:56:16 +02:00
|
|
|
# Register routers
|
feat: Skills & Methods catalog complete
Backend:
- Created routers/skills.py with full CRUD
- Skills: list (with category filter), get, create, update, delete
- Methods: list (with category filter), get, create, update, delete
- Default: only show active items
- Read access: all authenticated users
- Write access: admin only
- Registered skills router in main.py
Frontend:
- Complete SkillsPage with 2 tabs (Fähigkeiten, Trainingsmethoden)
- Browse by category with cards layout
- Admin CRUD forms (importance rating for skills, duration/group size for methods)
- Mobile-responsive grid layout
- Updated api.js with all skill/method functions
- Added /skills route to App.jsx
Migration already exists: 003_catalogs.sql (skills, training_methods + seed data)
Next: Training Planning (core feature)
2026-04-22 16:50:31 +02:00
|
|
|
from routers import auth, profiles, exercises, clubs, skills
|
2026-04-21 14:56:16 +02:00
|
|
|
|
2026-04-21 16:12:25 +02:00
|
|
|
app.include_router(auth.router)
|
|
|
|
|
app.include_router(profiles.router)
|
2026-04-22 16:44:32 +02:00
|
|
|
app.include_router(exercises.router)
|
feat: Clubs & Organization Management complete
Backend:
- Created routers/clubs.py with full CRUD
- Clubs: list, get, create, update, delete (admin only)
- Divisions: list, create, update, delete (admin only)
- Training Groups: list, get, create, update, delete (admin/trainer)
- Registered clubs router in main.py
- Permission checks: admin for clubs/divisions, trainer for groups
Frontend:
- Complete ClubsPage with 3 tabs (Vereine, Sparten, Gruppen)
- Role-based UI (admin sees all actions, trainer can manage groups)
- Full CRUD forms with modals
- Mobile-responsive card layouts
- Updated api.js with all club/division/group functions
Migration already exists: 002_organization.sql (clubs, divisions, training_groups)
Next: Skills & Methods display (read-only)
2026-04-22 16:48:02 +02:00
|
|
|
app.include_router(clubs.router)
|
feat: Skills & Methods catalog complete
Backend:
- Created routers/skills.py with full CRUD
- Skills: list (with category filter), get, create, update, delete
- Methods: list (with category filter), get, create, update, delete
- Default: only show active items
- Read access: all authenticated users
- Write access: admin only
- Registered skills router in main.py
Frontend:
- Complete SkillsPage with 2 tabs (Fähigkeiten, Trainingsmethoden)
- Browse by category with cards layout
- Admin CRUD forms (importance rating for skills, duration/group size for methods)
- Mobile-responsive grid layout
- Updated api.js with all skill/method functions
- Added /skills route to App.jsx
Migration already exists: 003_catalogs.sql (skills, training_methods + seed data)
Next: Training Planning (core feature)
2026-04-22 16:50:31 +02:00
|
|
|
app.include_router(skills.router)
|
2026-04-21 14:56:16 +02:00
|
|
|
|
|
|
|
|
# TODO: Add more routers as they are created
|
feat: Skills & Methods catalog complete
Backend:
- Created routers/skills.py with full CRUD
- Skills: list (with category filter), get, create, update, delete
- Methods: list (with category filter), get, create, update, delete
- Default: only show active items
- Read access: all authenticated users
- Write access: admin only
- Registered skills router in main.py
Frontend:
- Complete SkillsPage with 2 tabs (Fähigkeiten, Trainingsmethoden)
- Browse by category with cards layout
- Admin CRUD forms (importance rating for skills, duration/group size for methods)
- Mobile-responsive grid layout
- Updated api.js with all skill/method functions
- Added /skills route to App.jsx
Migration already exists: 003_catalogs.sql (skills, training_methods + seed data)
Next: Training Planning (core feature)
2026-04-22 16:50:31 +02:00
|
|
|
# from routers import training_planning
|
|
|
|
|
# app.include_router(training_planning.router, prefix="/api")
|
2026-04-21 14:26:12 +02:00
|
|
|
# ... etc
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
import uvicorn
|
|
|
|
|
uvicorn.run(
|
|
|
|
|
"main:app",
|
|
|
|
|
host="0.0.0.0",
|
|
|
|
|
port=8000,
|
|
|
|
|
reload=True
|
|
|
|
|
)
|