Major refactoring of RFCP backend: - Modular propagation models (8 models) - SharedMemoryManager for terrain data - ProcessPoolExecutor parallel processing - WebSocket progress streaming - Building filtering pipeline (351k → 15k) - 82 unit tests Performance: Standard preset 38s → 5s (7.6x speedup) Known issue: Detailed preset timeout (fix in 3.1.0)
55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI, WebSocket
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.core.database import connect_to_mongo, close_mongo_connection
|
|
from app.api.routes import health, projects, terrain, coverage, regions, system
|
|
from app.api.websocket import websocket_endpoint
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await connect_to_mongo()
|
|
yield
|
|
await close_mongo_connection()
|
|
|
|
|
|
app = FastAPI(
|
|
title="RFCP Backend API",
|
|
description="RF Coverage Planning Backend",
|
|
version="3.0.0",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
# CORS for frontend
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["https://rfcp.eliah.one", "http://localhost:5173", "http://127.0.0.1:8888"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# REST routes
|
|
app.include_router(health.router, prefix="/api/health", tags=["health"])
|
|
app.include_router(projects.router, prefix="/api/projects", tags=["projects"])
|
|
app.include_router(terrain.router, prefix="/api/terrain", tags=["terrain"])
|
|
app.include_router(coverage.router, prefix="/api/coverage", tags=["coverage"])
|
|
app.include_router(regions.router, prefix="/api/regions", tags=["regions"])
|
|
app.include_router(system.router, prefix="/api/system", tags=["system"])
|
|
|
|
# WebSocket endpoint for real-time coverage with progress
|
|
app.websocket("/ws")(websocket_endpoint)
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "RFCP Backend API", "version": "3.0.0"}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8090)
|