mirror of
https://github.com/escalante29/healthy-fit.git
synced 2026-03-21 09:08: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.
74 lines
1.6 KiB
Bash
Executable File
74 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Exit on error
|
|
set -e
|
|
|
|
# Load environment variables from .env
|
|
if [ -f .env ]; then
|
|
set -a
|
|
source .env
|
|
set +a
|
|
else
|
|
echo "Error: .env file not found"
|
|
exit 1
|
|
fi
|
|
|
|
# Start Database container
|
|
echo "Starting database container..."
|
|
docker compose up -d db
|
|
|
|
echo "Waiting for database to be ready..."
|
|
until docker compose exec -T db pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}; do
|
|
echo "Database is unavailable - sleeping"
|
|
sleep 1
|
|
done
|
|
|
|
# Set DATABASE_URL for local connection (using mapped port 5435)
|
|
export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5435/${POSTGRES_DB}"
|
|
echo "Configured DATABASE_URL for local development"
|
|
|
|
# Virtual Environment Setup
|
|
VENV_DIR="backend/.venv"
|
|
if [ ! -d "$VENV_DIR" ]; then
|
|
echo "Creating virtual environment in $VENV_DIR..."
|
|
python3 -m venv "$VENV_DIR"
|
|
fi
|
|
|
|
echo "Activating virtual environment..."
|
|
source "$VENV_DIR/bin/activate"
|
|
|
|
echo "Installing dependencies..."
|
|
pip install -r backend/requirements.txt
|
|
|
|
# Function to handle shutdown
|
|
cleanup() {
|
|
echo ""
|
|
echo "Stopping services..."
|
|
# Kill all child processes of this script
|
|
pkill -P $$
|
|
exit
|
|
}
|
|
|
|
# Trap signals for cleanup
|
|
trap cleanup SIGINT SIGTERM
|
|
|
|
echo "Starting Backend..."
|
|
# Run in background
|
|
(cd backend && uvicorn app.main:app --reload --host 0.0.0.0 --port 8000) &
|
|
|
|
echo "Starting Frontend..."
|
|
# Run in background
|
|
(cd frontend && npm run dev) &
|
|
|
|
# Wait for process to settle
|
|
sleep 2
|
|
|
|
echo ""
|
|
echo "Development environment running!"
|
|
echo "Backend: http://localhost:8000"
|
|
echo "Frontend: http://localhost:5173"
|
|
echo "Press Ctrl+C to stop"
|
|
|
|
# Wait indefinitely for background jobs
|
|
wait
|