mirror of
https://github.com/escalante29/healthy-fit.git
synced 2026-03-21 10:48:46 +01:00
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.
34 lines
792 B
Python
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"}
|