feat: implement ERP AI Assistant Phase 1
Backend (FastAPI + SQLAlchemy + Claude API + RAG): - Config management with Pydantic v2 - Database engine with connection pooling and SQL injection prevention - AI engine with Claude API integration (support custom base URL) - RAG engine with ChromaDB and sentence-transformers - Requirement analysis service - Config generation service - Executor engine with SQL validation - REST API endpoints: /analyze, /generate, /execute Frontend (Vue 3 + Element Plus + Pinia): - Complete 3-step workflow: analyze → generate → execute - Step indicator with progress visualization - Analysis result display with field table - SQL preview with monospace font - Execute confirmation dialog with safety warning - Execution result display - State management with Pinia - API service integration Security: - SQL injection prevention with parameterized queries - Dangerous SQL operation blocking - Database password URL encoding - Transaction auto-rollback - Pydantic config validation Features: - Natural language requirement analysis - Automated SQL configuration generation - Safe execution with human review - LAN access support - Custom Claude API endpoint support Documentation: - README with quick start guide - Quick start guide - LAN access configuration - Dependency fixes guide - Claude API configuration - Git operation guide - Implementation report Dependencies fixed: - numpy<2.0.0 for chromadb compatibility - sentence-transformers==2.7.0 for huggingface_hub compatibility Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
78
backend/app/main.py
Normal file
78
backend/app/main.py
Normal file
@@ -0,0 +1,78 @@
|
||||
"""FastAPI application entry point for ERP AI Assistant.
|
||||
|
||||
This module creates and configures the main FastAPI application instance.
|
||||
"""
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.config import get_settings
|
||||
from app.api import analyze, generate, execute
|
||||
|
||||
# Get application settings
|
||||
settings = get_settings()
|
||||
|
||||
# Create FastAPI application instance
|
||||
app = FastAPI(
|
||||
title=settings.APP_NAME,
|
||||
version="1.0.0",
|
||||
debug=settings.DEBUG,
|
||||
description="AI-powered assistant for ERP platform configuration"
|
||||
)
|
||||
|
||||
# Configure CORS middleware for frontend communication
|
||||
# For development: allow all origins with port 5173
|
||||
# For production: configure specific origins in environment
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"] if settings.DEBUG else [
|
||||
"http://localhost:5173",
|
||||
"http://127.0.0.1:5173",
|
||||
],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Register API routers
|
||||
app.include_router(analyze.router, prefix="/api/v1", tags=["Analysis"])
|
||||
app.include_router(generate.router, prefix="/api/v1", tags=["Generation"])
|
||||
app.include_router(execute.router, prefix="/api/v1", tags=["Execution"])
|
||||
|
||||
|
||||
@app.get("/", tags=["Root"])
|
||||
async def root() -> dict:
|
||||
"""Root endpoint returning application info.
|
||||
|
||||
Returns:
|
||||
Dictionary with application name, version, and status
|
||||
"""
|
||||
return {
|
||||
"message": settings.APP_NAME,
|
||||
"version": "1.0.0",
|
||||
"status": "running"
|
||||
}
|
||||
|
||||
|
||||
@app.get("/health", tags=["Health"])
|
||||
async def health_check() -> dict:
|
||||
"""Health check endpoint for monitoring.
|
||||
|
||||
Returns:
|
||||
Dictionary with health status
|
||||
"""
|
||||
return {
|
||||
"status": "healthy",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(
|
||||
"app.main:app",
|
||||
host="0.0.0.0",
|
||||
port=8000,
|
||||
reload=settings.DEBUG
|
||||
)
|
||||
Reference in New Issue
Block a user