Initial commit: Robot ökoszisztéma v2.0 - Stabilizált jármű és szerviz robotok

This commit is contained in:
Kincses
2026-03-04 02:03:03 +01:00
commit 250f4f4b8f
7942 changed files with 449625 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.core.config import settings
from app.core.database import engine, Base
from app.api.v1.router import api_router
# --- Lifespan Manager (Startup & Shutdown Logic) ---
@asynccontextmanager
async def lifespan(app: FastAPI):
# STARTUP: Adatbázis táblák létrehozása
# Figyelem: Éles környezetben (Production) inkább Alembic migrációt használunk!
async with engine.begin() as conn:
# Betöltjük a modelleket, hogy a metadata tudjon róluk
# Fontos: importálni kell őket, különben nem jönnek létre!
from app.models import social, vehicle, user, logistics
await conn.run_sync(Base.metadata.create_all)
print("--- Database Tables Checked/Created ---")
yield # Itt fut az alkalmazás...
# SHUTDOWN: Erőforrások felszabadítása (ha lenne)
print("--- Shutting down ---")
# --- App Initialization ---
app = FastAPI(
title=settings.PROJECT_NAME,
version=settings.VERSION,
openapi_url=f"{settings.API_V1_STR}/openapi.json",
lifespan=lifespan
)
# --- Middleware (CORS) ---
# Engedélyezzük a frontend kommunikációt
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Élesben szigorítani kell!
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# --- Routers ---
app.include_router(api_router, prefix=settings.API_V1_STR)
@app.get("/")
async def root():
return {
"message": "Traffic Ecosystem SuperApp API is Running",
"docs_url": "/docs",
"version": settings.VERSION
}