SmartLearn AI is a modern full-stack AI-powered learning assistant that combines:
- ⚡ FastAPI backend
- 💻 React frontend (Vite)
- 🧠 LLMs (Groq - LLaMA 3)
- 🔍 RAG (Retrieval-Augmented Generation)
- 🗄️ PostgreSQL (persistent chat history)
👉 It allows users to chat with AI and ask questions from uploaded PDFs with context-aware responses.
- 💬 Real-time AI Chat (Groq API)
- 📄 PDF Upload + Q&A
- 🔍 Semantic Search (FAISS)
- 🧠 Context-aware answers (RAG pipeline)
- 🗄️ Persistent chat history (PostgreSQL)
- 🧹 Chat deletion & multi-chat support
- ⚡ FastAPI high-performance backend
- 🎨 Clean ChatGPT-like UI
| Service | URL |
|---|---|
| Frontend | https://smart-learn-ai-gules.vercel.app |
| Backend | https://smartlearn-ai-production.up.railway.app |
smartlearn/
│
├── smartlearn-frontend/ # React + Vite frontend
│ ├── src/
│ │ ├── App.jsx
│ │ └── components/
│
├── smartlearn-backend/ # FastAPI backend
│ ├── main.py
│ ├── database.py
│ ├── .env # secrets (git-ignored, never commit)
│ └── services/
│ ├── llm.py
│ ├── rag.py
│ └── pdf.py
│
├── README.md
└── .gitignore- React (Vite)
- Axios
- Tailwind (optional)
- Framer Motion
- FastAPI
- Groq API (LLaMA 3)
- Sentence Transformers
- FAISS
- PostgreSQL (SQLAlchemy)
git clone https://github.com/YOUR_USERNAME/smartlearn.git
cd smartlearncd smartlearn-backend
pip install -r requirements.txtGROQ_API_KEY=your_groq_api_key_here
DATABASE_URL=your_railway_public_postgresql_url
ENV=development
⚠️ Important: Use the public Railway DB URL, not the internal one. Go to Railway → PostgreSQL service → Variables tab → copyDATABASE_PUBLIC_URL. It should look like:postgresql://postgres:xxxx@monorail.proxy.rlwy.net:PORT/railwayThe internal URL (postgres.railway.internal) only works inside Railway — not locally.
uvicorn main:app --reload📍 Runs on http://127.0.0.1:8000
cd smartlearn-frontend
npm installnpm run dev📍 Runs on http://localhost:5173
| Where | Environment | CORS policy |
|---|---|---|
Local (uvicorn --reload) |
development | allows localhost + Vercel |
| Railway (deployed) | production | allows Vercel only |
The backend reads the ENV variable to decide which origins CORS allows:
development→ allows localhost + Vercelproduction→ allows Vercel only (no wildcard*)
| Method | Endpoint | Description |
|---|---|---|
POST |
/chat |
Send a message, get AI response |
GET |
/chats |
Get all chat sessions |
GET |
/chat/{chat_id} |
Get messages for a specific chat |
DELETE |
/chat/{chat_id} |
Delete a chat session |
POST |
/upload |
Upload PDF for RAG |
GET |
/ |
Health check |
{
"message": "Explain AI",
"chat_id": "12345"
}- 📄 Upload PDF
- 🔍 Extract text
- ✂️ Chunking
- 🧠 Embeddings (Sentence Transformers)
- 💾 Store in FAISS (in-memory)
- ❓ User asks question
- 🔎 Retrieve relevant context
- 🤖 Generate answer via Groq (LLaMA 3)
- 🗄️ Save chat in PostgreSQL
CREATE TABLE chats (
id SERIAL PRIMARY KEY,
chat_id TEXT,
message TEXT,
response TEXT,
created_at TIMESTAMP DEFAULT NOW()
);- 🔒 Never commit
.env— add it to.gitignore - ⚡ FAISS is in-memory — vector index resets on server restart
- 🌐 Use
DATABASE_PUBLIC_URLfrom Railway for local dev, not the internal URL - 🔐 Keep
GROQ_API_KEYandDATABASE_URLin backend only — never frontend
- 🔐 Authentication (JWT/OAUth)
- 🧠 Long-term memory
- 📱 Mobile Optimization
- 💾 Persistent FAISS index
- Fork the repo
- Create your branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'add: your feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
| Name | Role |
|---|---|
| Sanan Malik | Leader |
| Naveed Ahmed | Developer |
| Dua Fatima | Developer |
| Zeshan Sikandar | Developer |
| Shayan Umer | Developer |
| Fiza Imran | Developer |
🚧 Actively Developing
If you like this project, give it a ⭐ on GitHub!