StudyPal is an AI-powered study companion built for secondary school and university students across Africa. Students ask any academic question or upload a document β PDF, image, or text β and instantly receive a clear, level-appropriate explanation, two practice questions with model answers, and an encouraging message. Every session is saved,.
# π StudyPal β AI Study Companion
## Project Structure
```
studypal/
βββ backend/ β Node.js + Express API server
βββ frontend/ β Next.js UI
```
---
## Backend Setup (Node.js + Express)
```bash
cd backend
npm install
cp .env.example .env
# Add your free Gemini key to .env
# Get it at:
aistudio.google.com
npm run dev
```
Runs on β **
http://localhost:4000**
### API Endpoints
| Method | Route | Description |
| ------ | ------------------------- | ----------------------------------- |
| POST | `/api/session` | Create or resume a session |
| POST | `/api/ask` | Ask a question (with optional file) |
| GET | `/api/history/:username` | Get question history |
| GET | `/api/progress/:username` | Get progress stats |
---
## Frontend Setup (Next.js)
```bash
cd frontend
npm install
cp .env.local.example .env.local
# .env.local already points to
localhost
npm run dev
```
Runs on β **
http://localhost:3000**
---
## Run Both Together
Open two terminals:
**Terminal 1 β Backend:**
```bash
cd backend && npm run dev
```
**Terminal 2 β Frontend:**
```bash
cd frontend && npm run dev
```
Then open **
http://localhost:3000**