CoolFace
Apppublic

hassan-dev14/stellar-dna-api

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
main.py54 linesDownload Raw Back to root
1"""Stellar DNA FastAPI application entry point."""2 3import os4import logging5 6from dotenv import load_dotenv7from fastapi import FastAPI8from fastapi.middleware.cors import CORSMiddleware9 10from routers import part1, part211 12load_dotenv()13 14logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")15logger = logging.getLogger(__name__)16 17if not os.getenv("GEMINI_API_KEY") and not os.getenv("GROQ_API_KEY"):18    logger.warning(19        "No LLM API keys found (GEMINI_API_KEY or GROQ_API_KEY). "20        "Trait scores will still compute, but narrative paragraphs "21        "will be empty. Copy backend/.env.example to backend/.env "22        "and add at least one key."23    )24 25app = FastAPI(26    title="Stellar DNA API",27    version="0.1.0",28    description="Compute elemental stellar profiles from birth data.",29)30 31origins = os.getenv("CORS_ORIGINS", "http://localhost:5173,http://localhost:5174,http://localhost:5175")32allowed_origins = [o.strip() for o in origins.split(",") if o.strip()]33 34app.add_middleware(35    CORSMiddleware,36    allow_origins=allowed_origins,37    allow_credentials=True,38    allow_methods=["*"],39    allow_headers=["*"],40)41 42app.include_router(part1.router, prefix="/api", tags=["part1"])43app.include_router(part2.router, prefix="/api", tags=["part2"])44 45 46@app.get("/")47def root():48    return {"service": "stellar-dna", "status": "ok"}49 50 51@app.get("/health")52def health():53    return {"status": "healthy"}54