Real-time AI assistant backend: RAG chat over Hye Aero data, dynamic market comparison, predictive pricing, and resale advisory. Data sources: Controller, AircraftExchange, FAA, Internal DB.
PostgreSQL (listings, sales, aircraft, FAA) ──┬──► RAG Pipeline ──► Pinecone
└──► API (comparison, price, resale)
│
FastAPI ──► /api/rag/answer
/api/market-comparison
/api/price-estimate
/api/resale-advisory
- API (FastAPI): Chat (RAG), market comparison, price estimate, resale advisory
- RAG: Sync Postgres → Pinecone; query service (retrieve + LLM answer)
- Market comparison: Query listings by model, age, hours, region
- Price estimate: Heuristic from historical sales (extensible to ML)
- Resale advisory: Plain-English guidance via RAG/LLM
- Install dependencies:
cd backend
pip install -r requirements.txt-
Configure
.env(see.env.exampleor docs):POSTGRES_CONNECTION_STRING— required for all endpointsPINECONE_*,OPENAI_*— required for RAG chat and resale advisoryOPENAI_CHAT_MODEL— optional (defaultgpt-4o-mini)
-
(Optional) Sync data to Pinecone for RAG:
python runners/run_rag_pipeline.py --limit 100cd backend
python runners/run_api.pyOr with uvicorn directly:
uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload- API: http://localhost:8000
- Docs: http://localhost:8000/docs
Allow access from other PCs: The app binds to 0.0.0.0:8000, but the server firewall must allow inbound TCP on port 8000. Otherwise you get "i/o timeout" from other machines.
- Windows (on the server): Run in Administrator PowerShell:
New-NetFirewallRule -DisplayName "HyeAero API 8000" -Direction Inbound -Protocol TCP -LocalPort 8000 -Action Allow
- Linux (on the server):
sudo ufw allow 8000thensudo ufw reload(or add an iptables rule for port 8000). - Cloud (AWS/DigitalOcean/etc.): In the instance Security Group or Firewall, add an inbound rule: TCP port 8000 from
0.0.0.0/0(or your frontend’s IP) if you want the API reachable from the internet.
| Method | Path | Description |
|---|---|---|
| POST | /api/rag/answer |
Ask the Consultant (RAG over Hye Aero data) |
| POST | /api/market-comparison |
Compare aircraft by model, region, hours, year |
| POST | /api/price-estimate |
Predictive valuation from sale history |
| POST | /api/resale-advisory |
Plain-English resale guidance (RAG) |
| GET | /health |
Health check |
Set in frontend .env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000Chat uses the Next.js proxy (/api/chat → backend /api/rag/answer). Market Comparison, Price Estimator, and Resale Advisory call the backend from the browser (CORS is enabled for http://localhost:3000).
Data is loaded by the etl-pipeline (Controller, AircraftExchange, FAA, Internal DB) into PostgreSQL. This backend reads from the same database for comparison and pricing, and from Pinecone (after RAG sync) for natural-language chat.