A full-stack application with FastAPI backend and Next.js frontend, featuring outdoor route recommendations with gamification and story generation.
Backend:
- FastAPI (Python 3.11+)
- SQLAlchemy with async SQLite
- Alembic for database migrations
Frontend:
- Next.js 16 with React 19
- TypeScript
- Tailwind CSS
- Python 3.11+
- Node.js 18+ (pnpm or npm)
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
alembic upgrade headcd frontend
pnpm install # or npm install
pnpm run build # or npm run buildcd backend
source venv/bin/activate
uvicorn app.main:app --reload --port 8000Access the application at:
- Frontend: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/healthz
Or use the dev script:
./scripts/dev.sh-
Set up environment (first time only)
# Backend cd backend && python -m venv venv source venv/bin/activate pip install -r requirements.txt -r requirements-dev.txt alembic upgrade head # Frontend cd ../frontend && pnpm install
-
Develop backend
- Edit code in
backend/app/ - Create migrations:
alembic revision --autogenerate -m "description" - Apply migrations:
alembic upgrade head
- Edit code in
-
Develop frontend
cd frontend pnpm run dev # Runs on http://localhost:3000
-
Build and serve together
# Build frontend cd frontend && pnpm run build # Run backend (serves both API and frontend) cd ../backend && source venv/bin/activate uvicorn app.main:app --reload --port 8000
.
├── backend/
│ ├── app/
│ │ ├── api/v1/ # API endpoints
│ │ ├── models/ # Database models
│ │ ├── services/ # Business logic
│ │ ├── database.py # DB connection
│ │ └── main.py # FastAPI app
│ ├── alembic/ # Database migrations
│ ├── data/ # SQLite database
│ ├── scripts/ # Utility scripts
│ └── requirements.txt
├── frontend/
│ ├── app/ # Next.js app directory
│ ├── components/ # React components
│ └── out/ # Build output (generated)
└── scripts/
└── dev.sh # Development server script
- Default location:
backend/data/app.db - Migrations: Managed with Alembic
alembic revision --autogenerate -m "description" alembic upgrade head alembic downgrade -1 - Environment: Copy
backend/env.exampletobackend/.envto customizeDATABASE_URL
backend/scripts/seed_db.py- Seed database with demo databackend/scripts/test_models.py- Test database modelsscripts/dev.sh- Start development server
See backend/env.example for available configuration options. Create backend/.env to override defaults.