Travel agent chatbot backend powered by FastAPI, LangChain/LangGraph/DeepAgents with RAG and tool integrations for holiday and travel planning.
- Clone the repo and enter the backend folder:
git clone <repo-url> cd chatbot-backend
- Create a virtual environment (Python >= 3.13):
python -m venv .venv .venv\Scripts\activate # on Windows # source .venv/bin/activate # on macOS/Linux
- Install dependencies for the API (uv recommended since this project is PEP 621/pyproject-native):
uv venv .venv # if you want uv to manage the venv (optional) uv pip install -e . # Optional: install dev tooling (pytest/ruff/pre-commit) if your installer supports groups/extras # uv pip install -e ".[dev]"
- Configure environment:
# Windows copy .env.example .env # macOS/Linux cp .env.example .env # update secrets, DB, and provider keys
Start the FastAPI app with auto-reload using the packaged script from pyproject.toml:
uv run startAlternative (explicit uvicorn invocation):
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Open the interactive docs at http://localhost:8000/docs to exercise the endpoints.
From the chatbot-backend directory:
docker compose up --buildServices:
- API: http://localhost:8000
- Postgres (
pgvectorenabled):localhost:5432
The compose stack automatically enables the vector extension on first database initialization.
- Username/password only (no MFA)
- Passwords are hashed with
bcryptbefore storing - Endpoints:
POST /api/v1/auth/registerwith{ "username": "...", "password": "..." }POST /api/v1/auth/loginwith{ "username": "...", "password": "..." }
- Structured logging: Request completion logs include
request_id,status_code,duration_ms, method, and path. - Error wrappers: Custom exceptions (
AppExceptionhierarchy) are centrally handled and serialized with consistent error payloads. - Prometheus metrics:
http_requests_total{method,path,status}http_request_duration_seconds{path}auth_events_total{action,outcome}exception_events_total{exception_type,path}
- OpenTelemetry traces:
- FastAPI auto-instrumentation (incoming HTTP spans)
- SQLAlchemy and
requestsinstrumentation - Manual spans for key auth/user operations
- Exceptions are recorded on active spans
Observability endpoints and config:
- Metrics endpoint:
GET /metrics - OTLP target: set
OTEL_EXPORTER_OTLP_ENDPOINTandOTEL_TRACES_EXPORTER=otlp - Service metadata:
OTEL_SERVICE_NAME,ENVIRONMENT
- Run tests:
pytest - Lint/format:
ruff check . - Pre-commit hooks:
pre-commit install
This backend includes a ready-to-run LangSmith evaluation harness for both agent runtimes.
- Enable tracing environment variables:
# PowerShell $env:LANGCHAIN_TRACING_V2="true" $env:LANGCHAIN_API_KEY="<your_langsmith_api_key>" $env:LANGCHAIN_PROJECT="Travel_Agent_Evaluation"
- Upload dataset file
evals/eval_dataset.jsonlin LangSmith asTravel_Agent_Eval_Set. - Run evaluation script:
uv run python evals/run_langsmith_eval.py --dataset "Travel_Agent_Eval_Set" --max-concurrency 1
See evals/README.md for full setup notes and troubleshooting.