
- 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
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api import users, destinations, trips
|
|
from app.db.session import engine
|
|
from app.db.base import Base
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="Travel App API",
|
|
description="A travel planning and management API",
|
|
version="1.0.0",
|
|
openapi_url="/openapi.json",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {
|
|
"title": "Travel App API",
|
|
"description": "A travel planning and management API",
|
|
"documentation": "/docs",
|
|
"health": "/health",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {"status": "healthy", "service": "Travel App API", "version": "1.0.0"}
|
|
|
|
|
|
app.include_router(users.router, prefix="/api/users", tags=["users"])
|
|
app.include_router(
|
|
destinations.router, prefix="/api/destinations", tags=["destinations"]
|
|
)
|
|
app.include_router(trips.router, prefix="/api/trips", tags=["trips"])
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|