Production-ready AI assistant backend powered by FastAPI and HuggingFace. Deploy as a containerized service on Railway or AWS with streaming, RAG, and conversation memory.
- 🚀 Deployment ready — Docker image for Railway (IaC) and Amazon ECR / ECS Express Mode
- 🔄 Streaming — Token-by-token via Server-Sent Events
- 🧠 RAG — FAISS + Sentence Transformers, MMR diversification, source attribution
- 💾 Conversation memory — Per-session history in SQLite
- 🔌 Modular providers — Local HuggingFace / Cloud Inference API / OpenAI / Ollama
- ⚡ Production optimizations — Lazy initialization, background warmup, graceful cold starts
- Backend: Python 3.14 / FastAPI / Uvicorn
- AI: HuggingFace Transformers / PyTorch / Sentence Transformers
- Search: FAISS (vector similarity)
- Database: SQLite (aiosqlite)
- Deployment: Docker / Railway (CLI + IaC) / Amazon ECR / ECS Express Mode / Vercel-ready
cd backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload# Health check
curl http://localhost:8000/health
# Non-streaming chat
curl -X POST http://localhost:8000/chat \
-H "Content-Type: application/json" \
-d '{"messages": [{"role":"user", "content":"Hello!"}]}'
# Streaming chat
curl -N -X POST http://localhost:8000/chat \
-H "Content-Type: application/json" \
-d '{"messages": [{"role":"user", "content":"Explain RAG"}], "stream": true}'- Railway Deployment Guide - Deploy with the Railway CLI + IaC
- Deployment Guide - Deploy to AWS ECR and ECS Express Mode
- API Reference - Complete endpoint documentation
- Architecture - System design and components
- Integration Guide - Connect your frontend
- Vercel + Next.js - Full Next.js integration
- React Component - Drop-in chat widget
- JavaScript Client - Production client
- Architecture - AWS target architecture and migration path
- Roadmap - Future features
Power your portfolio with an AI assistant. Example: mdimranhs.vercel.app
// Next.js integration
import { EdgeMindChat } from './EdgeMindChat';
<EdgeMindChat
apiUrl="/api/chat"
systemPrompt="Help visitors learn about Md Imran Hossain's work"
/>Deploy as a standalone service for any frontend:
# Deploy to Railway
railway up
# Or deploy to AWS
docker build --platform linux/amd64 -t edgemind-api .
# Use from anywhere
curl https://your-endpoint/chat -d '...'See: Railway Deployment Guide · Deployment Guide
| Feature | Status |
|---|---|
| Base LLM integration | ✅ Complete |
| Streaming responses | ✅ Complete |
| RAG with FAISS | ✅ Complete |
| MMR + source attribution | ✅ Complete |
| Conversation memory | ✅ Complete |
| Production optimizations | ✅ Complete |
| AWS container deployment | 🚧 In progress |
| Railway deployment (CLI + IaC) | ✅ Complete |
| Cloud database and vector store | 🚧 Planned |
| Frontend integration docs | ✅ Complete |
| Fine-tuned model | ⏸️ On hold |
# backend/.env
LLM_PROVIDER=hf_api # local | hf_api | openai | ollama
HF_TOKEN=hf_your_token_here # HuggingFace API token
HF_MODEL=Qwen/Qwen2.5-1.5B-Instruct
DEBUG=False
WEB_SEARCH_ENABLED=Truehf_api- HuggingFace Inference API (recommended for deployment)local- Local model on GPU (development only)openai- OpenAI API (not implemented yet)ollama- Ollama local server (not implemented yet)
Deployment is defined in code with Infrastructure as Code — .railway/railway.ts creates the edgemind service, /health check, and environment variables.
npm install # Railway IaC SDK
railway login
railway init # create a project
railway config apply # apply infra (service + env)
railway variables set "HF_TOKEN=hf_..." # secret stays out of git
railway up # build & deploy the Docker image
railway domain # generate a public URL# Build and push to ECR, then deploy the image through ECS Express Mode.
# See docs/deployment.md for the complete AWS CLI workflow.ECS Express Mode provides a managed Fargate service, HTTPS endpoint, load balancing, scaling, and CloudWatch monitoring. See: Deployment Guide
Contributions welcome! See Roadmap for planned features.
MIT License - see LICENSE file
- Live API: Configure after deploying on Railway (
railway domain) or AWS ECS - Portfolio: mdimranhs.vercel.app
- Documentation: docs/
Built with ❤️ by Md Imran Hossain