Files
healthy-fit/backend/app/main.py
Carlos Escalante 5dc6dc88f7 Initial project scaffolding for health tracker app
Set up backend and frontend structure for a health and fitness tracker using Python (FastAPI, SQLModel, DSPy) and React. Includes Docker and Compose configs, authentication, nutrition AI module, health/nutrition/user endpoints, database models, and basic frontend with routing and context. Enables tracking nutrition, health metrics, and user management, with architecture ready for future mobile and cloud deployment.
2026-01-18 10:29:44 -06:00

34 lines
792 B
Python

from contextlib import asynccontextmanager
from dotenv import load_dotenv
load_dotenv()
from fastapi import FastAPI
from app.api.v1.api import api_router
from app.db import init_db
from app.core.ai_config import configure_dspy
@asynccontextmanager
async def lifespan(app: FastAPI):
init_db()
configure_dspy()
yield
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI(title="Healthy Fit API", lifespan=lifespan)
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173", "http://localhost:5174", "http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(api_router, prefix="/api/v1")
@app.get("/")
def read_root():
return {"message": "Welcome to Healthy Fit API"}