Add deployment documentation and enhance project setup scripts

- Introduced `DEPLOYMENT.md` for comprehensive deployment instructions.
- Added `start.bat` and `start.sh` scripts for unified project startup on Windows and Linux/Mac.
- Updated `.gitignore` to exclude additional files and directories.
- Enhanced `main.py` to serve static frontend files and handle SPA routing.
- Configured Vite to output the frontend build to the backend public directory.
- Minor adjustments in `ReviewDetail.tsx` for improved data handling.
This commit is contained in:
Primakov Alexandr Alexandrovich
2025-10-12 23:27:41 +03:00
parent 09cdd06307
commit b297bcbba9
8 changed files with 932 additions and 304 deletions

View File

@@ -2,8 +2,11 @@
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from contextlib import asynccontextmanager
from typing import List
from pathlib import Path
import json
from app.config import settings
@@ -67,15 +70,39 @@ app.add_middleware(
# Include API routes
app.include_router(api_router, prefix="/api")
@app.get("/")
async def root():
"""Root endpoint"""
return {
"message": "AI Code Review Agent API",
"version": "0.1.0",
"docs": "/docs"
}
# Serve static files (frontend build)
public_dir = Path(__file__).parent.parent / "public"
if public_dir.exists():
# Serve assets (JS, CSS, images)
app.mount("/assets", StaticFiles(directory=str(public_dir / "assets")), name="assets")
@app.get("/", response_class=FileResponse)
async def serve_frontend_root():
"""Serve frontend index.html"""
return FileResponse(str(public_dir / "index.html"))
@app.get("/{full_path:path}", response_class=FileResponse)
async def serve_frontend_routes(full_path: str):
"""Serve frontend for all routes (SPA support)"""
# Skip API and WebSocket routes
if full_path.startswith(("api/", "ws/", "docs", "redoc", "openapi.json")):
return None
file_path = public_dir / full_path
if file_path.exists() and file_path.is_file():
return FileResponse(str(file_path))
# Fallback to index.html for SPA routing
return FileResponse(str(public_dir / "index.html"))
else:
@app.get("/")
async def root():
"""Root endpoint (when frontend not built)"""
return {
"message": "AI Code Review Agent API",
"version": "0.1.0",
"docs": "/docs",
"note": "Frontend not built. Run 'npm run build' in frontend directory."
}
@app.get("/health")