Skip to content
mdimranhsPublic

About

An intelligent AI assistant powered by FastAPI, Hugging Face, Retrieval-Augmented Generation (RAG), and modern LLM technologies.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

EdgeMind 🧠

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.

✨ Features

  • 🚀 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

🏗️ Tech Stack

  • 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

🚀 Quick Start

Local Development

cd backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Test API

# 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}'

📚 Documentation

Getting Started

Integration

Production

🎯 Use Cases

Portfolio Integration

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"
/>

See: Vercel Integration Guide

Standalone API

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

📊 Progress

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

🛠️ Configuration

Environment Variables

# 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=True

Providers

  • hf_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

Railway (CLI)

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

See: Railway Deployment Guide

AWS ECS Express Mode

# 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

🤝 Contributing

Contributions welcome! See Roadmap for planned features.

📄 License

MIT License - see LICENSE file

🔗 Links

  • Live API: Configure after deploying on Railway (railway domain) or AWS ECS
  • Portfolio: mdimranhs.vercel.app
  • Documentation: docs/

Built with ❤️ by Md Imran Hossain

About

An intelligent AI assistant powered by FastAPI, Hugging Face, Retrieval-Augmented Generation (RAG), and modern LLM technologies.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages