All checks were successful
Deploy Development / deploy (push) Successful in 36s
- New run_migrations.py script - Runs all SQL files in migrations/ on startup - Tracks executed migrations in schema_migrations table - Retries database connection (30 attempts) - Separate Shinkan DB (shinkan_dev / shinkan) This ensures a clean separation from Mitai database.
86 lines
2.2 KiB
Python
86 lines
2.2 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"
|
|
}
|
|
|
|
# TODO: Register routers here as they are created
|
|
# from routers import auth, profiles, clubs, groups, skills, methods, exercises
|
|
# app.include_router(auth.router, prefix="/api")
|
|
# app.include_router(profiles.router, prefix="/api")
|
|
# ... etc
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(
|
|
"main:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
reload=True
|
|
)
|