feat: backend servis iskeletini ve yönetim uçlarını ekle

This commit is contained in:
2026-03-21 11:53:04 +03:00
parent df1924b772
commit 62add37d9d
29 changed files with 953 additions and 0 deletions

56
backend/app/main.py Normal file
View File

@@ -0,0 +1,56 @@
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.admin.routes import router as admin_router
from app.config import get_settings
from app.db import init_db, session_scope
from app.models import HealthStatus
from app.orchestrator import WiseClawOrchestrator
from app.runtime import RuntimeServices
from app.telegram.bot import TelegramBotService
settings = get_settings()
runtime_services = RuntimeServices()
@asynccontextmanager
async def lifespan(_: FastAPI):
init_db()
if settings.telegram_bot_token:
runtime_services.telegram_bot = TelegramBotService(settings.telegram_bot_token, session_scope)
await runtime_services.telegram_bot.start()
yield
await runtime_services.shutdown()
app = FastAPI(title="WiseClaw", version="0.1.0", lifespan=lifespan)
app.add_middleware(
CORSMiddleware,
allow_origins=["http://127.0.0.1:5173", "http://localhost:5173"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(admin_router)
@app.get("/health", response_model=HealthStatus)
def health() -> HealthStatus:
return HealthStatus()
@app.get("/bootstrap")
def bootstrap() -> dict[str, object]:
with session_scope() as session:
orchestrator = WiseClawOrchestrator(session)
runtime = orchestrator.get_runtime_settings().model_dump()
return {
"env": settings.env,
"admin_host": settings.admin_host,
"admin_port": settings.admin_port,
"runtime": runtime,
}