""" FastAPI application entry point for myFidelityTracker. This module initializes the FastAPI application, configures CORS, and registers all API routers. """ from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.config import settings from app.api.endpoints import accounts, transactions, positions, import_endpoint from app.api.endpoints import analytics_v2 as analytics # Create FastAPI application app = FastAPI( title=settings.PROJECT_NAME, description="Track and analyze your Fidelity brokerage account performance", version="1.0.0", ) # Configure CORS middleware - allow all origins for local network access app.add_middleware( CORSMiddleware, allow_origins=["*"], # Allow all origins for local development allow_credentials=False, # Must be False when using allow_origins=["*"] allow_methods=["*"], allow_headers=["*"], ) # Register API routers app.include_router( accounts.router, prefix=f"{settings.API_V1_PREFIX}/accounts", tags=["accounts"] ) app.include_router( transactions.router, prefix=f"{settings.API_V1_PREFIX}/transactions", tags=["transactions"], ) app.include_router( positions.router, prefix=f"{settings.API_V1_PREFIX}/positions", tags=["positions"] ) app.include_router( analytics.router, prefix=f"{settings.API_V1_PREFIX}/analytics", tags=["analytics"] ) app.include_router( import_endpoint.router, prefix=f"{settings.API_V1_PREFIX}/import", tags=["import"], ) @app.get("/") def root(): """Root endpoint returning API information.""" return { "name": settings.PROJECT_NAME, "version": "1.0.0", "message": "Welcome to myFidelityTracker API", } @app.get("/health") def health_check(): """Health check endpoint.""" return {"status": "healthy"}