
- FastAPI application with user management, destinations, and trip planning - SQLite database with SQLAlchemy ORM - Database models for Users, Destinations, and Trips - Pydantic schemas for request/response validation - Full CRUD API endpoints for all resources - Alembic migrations setup - Health check endpoint - CORS configuration for development - Comprehensive documentation and README
Travel App Backend
A FastAPI-based backend application for a travel planning and management system.
Features
- User Management: Create and manage user accounts
- Destination Management: Add, update, and browse travel destinations
- Trip Planning: Create and manage travel trips with destinations, dates, and budgets
- RESTful API: Full CRUD operations for all resources
- Database Integration: SQLite database with SQLAlchemy ORM
- API Documentation: Automatic OpenAPI documentation
Tech Stack
- Framework: FastAPI
- Database: SQLite
- ORM: SQLAlchemy
- Migrations: Alembic
- Validation: Pydantic
- Server: Uvicorn
Installation
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the server:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Documentation
- Interactive Docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/openapi.json
API Endpoints
Root
GET /
- API information and linksGET /health
- Health check endpoint
Users
GET /api/users/
- List all usersGET /api/users/{user_id}
- Get user by IDPOST /api/users/
- Create new userPUT /api/users/{user_id}
- Update user
Destinations
GET /api/destinations/
- List all destinationsGET /api/destinations/{destination_id}
- Get destination by IDPOST /api/destinations/
- Create new destinationPUT /api/destinations/{destination_id}
- Update destinationDELETE /api/destinations/{destination_id}
- Delete destination
Trips
GET /api/trips/
- List all tripsGET /api/trips/{trip_id}
- Get trip by IDGET /api/trips/user/{user_id}
- Get trips for specific userPOST /api/trips/
- Create new tripPUT /api/trips/{trip_id}
- Update tripDELETE /api/trips/{trip_id}
- Delete trip
Database Schema
Users
id
: Primary keyemail
: Unique email addressfull_name
: User's full namehashed_password
: Encrypted passwordis_active
: Account statuscreated_at
: Account creation timestampupdated_at
: Last update timestamp
Destinations
id
: Primary keyname
: Destination namecountry
: Country namecity
: City namedescription
: Destination descriptionlatitude
: GPS latitudelongitude
: GPS longituderating
: Destination rating (0-5)image_url
: Destination image URLcreated_at
: Creation timestampupdated_at
: Last update timestamp
Trips
id
: Primary keytitle
: Trip titledescription
: Trip descriptionuser_id
: Foreign key to Users tabledestination_id
: Foreign key to Destinations tablestart_date
: Trip start dateend_date
: Trip end datebudget
: Trip budgetstatus
: Trip status (planned, ongoing, completed, cancelled)created_at
: Creation timestampupdated_at
: Last update timestamp
Development
Running with Ruff
ruff check .
ruff format .
Database Migrations
# Create new migration
alembic revision --autogenerate -m "Description"
# Apply migrations
alembic upgrade head
# Rollback migration
alembic downgrade -1
Storage
The application uses /app/storage/db/
directory for SQLite database storage.
CORS Configuration
The API is configured to allow all origins (*) for development purposes.
Description
Languages
Python
97.4%
Mako
2.6%