Add complete ai.card Rust implementation
- Implement complete Rust API server with axum framework - Add database abstraction supporting PostgreSQL and SQLite - Implement comprehensive gacha system with probability calculations - Add JWT authentication with atproto DID integration - Create card master data system with rarities (Normal, Rare, SuperRare, Kira, Unique) - Implement draw history tracking and collection management - Add API endpoints for authentication, card drawing, and collection viewing - Include database migrations for both PostgreSQL and SQLite - Maintain full compatibility with Python API implementation - Add comprehensive documentation and development guide 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
65
python/api/app/main.py
Normal file
65
python/api/app/main.py
Normal file
@ -0,0 +1,65 @@
|
||||
"""FastAPI application entry point"""
|
||||
import os
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.core.config import settings
|
||||
from app.routes import cards, auth, sync
|
||||
from app.mcp_server import AICardMcpServer
|
||||
|
||||
# Initialize MCP server
|
||||
enable_mcp = os.getenv("ENABLE_MCP", "true").lower() == "true"
|
||||
mcp_server = AICardMcpServer(enable_mcp=enable_mcp)
|
||||
|
||||
# Get FastAPI app from MCP server
|
||||
app = mcp_server.get_app()
|
||||
|
||||
# Update app configuration
|
||||
app.title = settings.app_name
|
||||
app.version = settings.app_version
|
||||
app.docs_url = "/docs"
|
||||
app.redoc_url = "/redoc"
|
||||
|
||||
# CORS middleware
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.cors_origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Include routers
|
||||
app.include_router(auth.router, prefix=settings.api_v1_prefix)
|
||||
app.include_router(cards.router, prefix=settings.api_v1_prefix)
|
||||
app.include_router(sync.router, prefix=settings.api_v1_prefix)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
"""Root endpoint"""
|
||||
return {
|
||||
"app": settings.app_name,
|
||||
"version": settings.app_version,
|
||||
"status": "running"
|
||||
}
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
"""Health check endpoint"""
|
||||
return {
|
||||
"status": "healthy",
|
||||
"mcp_enabled": enable_mcp,
|
||||
"mcp_endpoint": "/mcp" if enable_mcp else None
|
||||
}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(
|
||||
"app.main:app",
|
||||
host="0.0.0.0",
|
||||
port=8000,
|
||||
reload=True
|
||||
)
|
Reference in New Issue
Block a user