parinazAkef's picture
Fresh start: TalimBot project without binary files
2fe573b
|
Raw History Blame Contribute Delete
11.3 kB
# TalimBot - سیسΨͺΩ… Ϊ―Ψ±ΩˆΩ‡β€ŒΨ¨Ω†Ψ―ΫŒ Ω‡ΩˆΨ΄Ω…Ω†Ψ― Ψ―Ψ§Ω†Ψ΄β€ŒΨ’Ω…ΩˆΨ²Ψ§Ω†
A full-stack intelligent student grouping system using AI-powered analysis with FastAPI backend and GitHub Pages frontend.
## 🎯 Overview
TalimBot groups 30 real students based on MBTI personality types, learning styles, math grades, and peer preferences using AI (GPT-4o-mini via OpenRouter). Teachers control when students can view their group assignments.
### Real Student Data
- **30 Students** from class 1061 (Ψ―Ω‡Ω… Ψͺجربی)
- **Persian Names**: Full Persian names from actual class roster
- **National Code Authentication**: Students login with their national ID
- **Math Grades**: Real grades from student records
---
## πŸš€ Quick Start (Local Development)
### Prerequisites
- Python 3.8+ installed
- Modern web browser
- Internet connection (for AI grouping)
### Step 1: Start Backend (30 seconds)
```powershell
# Navigate to backend folder
cd backend
# Install dependencies (first time only)
pip install -r requirements.txt
# Start the server
python main.py
```
**Server runs on:** `http://localhost:8000`
**Keep this terminal running!**
### Step 2: Open Frontend (10 seconds)
**Option A - Direct Open (Easiest):**
- Double-click `index.html` in File Explorer
**Option B - Local Server (Recommended):**
```powershell
# In a NEW terminal window
python -m http.server 3000
```
Then visit: `http://localhost:3000`
---
## πŸ‘₯ Login Credentials
### Students (30 students available)
Login with:
- **Student Number:** S001, S002, ..., S030
- **National Code:** Each student's 10-digit national ID
**Example:**
- Student Number: `S001`
- National Code: `929986644`
- Name: Ψ’Ψ―ΫŒΩ†Ω‡ پور - ΫŒΨ§Ψ³Ω…Ω†
### Teacher
- **Password:** `teacher123`
---
## πŸ“‹ How It Works
### For Students:
1. **Login**
- Enter student number (S001-S030)
- Enter your 10-digit national code
- System displays your Persian name
2. **Complete Profile**
- Take MBTI test (link provided)
- Take VARK learning style test (link provided)
- Fill out AMS and Cooperative preferences
- Select up to 4 preferred groupmates
- Save your information
3. **View Group** (after teacher enables)
- See your group number
- View all group members
- Read AI reasoning in Persian
### For Teachers:
1. **Monitor Progress**
- View dashboard with statistics
- See which students completed profiles
- Check readiness for grouping
2. **Perform Grouping**
- Enter course name
- Click "Start Grouping"
- AI analyzes all data (10-30 seconds)
- Review generated groups with Persian reasoning
3. **Control Visibility**
- Groups are hidden by default
- Click "Show Results to Students"
- Toggle visibility on/off anytime
4. **Manage Data**
- View all student information
- Edit student data if needed
- Reset grouping when necessary
---
## 🌐 Deployment to GitHub Pages
### Part 1: Deploy Frontend to GitHub Pages
1. **Create GitHub Repository**
```bash
# Initialize git (if not already done)
git init
git add .
git commit -m "Initial commit with real student data"
# Create repo on GitHub and push
git remote add origin https://github.com/talimbot/talimbot.git
git branch -M main
git push -u origin main
```
2. **Enable GitHub Pages**
- Go to repository Settings β†’ Pages
- Source: Deploy from branch `main`
- Folder: `/ (root)`
- Click Save
3. **Your site will be live at:**
`https://talimbot.github.io/talimbot/`
### Part 2: Deploy Backend to Render.com (Free)
1. **Create Render Account**
- Visit [render.com](https://render.com)
- Sign up with GitHub
2. **Create New Web Service**
- Click "New +" β†’ "Web Service"
- Connect your GitHub repository
- Settings:
- **Name:** `talimbot-backend`
- **Environment:** `Python 3`
- **Build Command:** `pip install -r backend/requirements.txt`
- **Start Command:** `cd backend && uvicorn main:app --host 0.0.0.0 --port $PORT`
- **Plan:** Free
3. **Add Environment Variable**
- In Render dashboard β†’ Environment
- Add: `OPENROUTER_API_KEY` = `your-api-key`
- Optionally: `TEACHER_PASSWORD` = `your-password`
4. **Get Your Backend URL**
- Copy the URL (e.g., `https://talimbot-backend.onrender.com`)
### Part 3: Update Frontend to Use Deployed Backend
Update `API_BASE_URL` in BOTH files:
- `assets/js/data.js`
- `assets/js/grouping.js`
```javascript
// Change from:
const API_BASE_URL = 'http://localhost:8000/api';
// To:
const API_BASE_URL = 'https://talimbot-backend.onrender.com/api';
```
Commit and push changes:
```bash
git add .
git commit -m "Update API URL for production"
git push
```
GitHub Pages will auto-deploy in ~1 minute.
---
## πŸ”§ Configuration
### API Key (OpenRouter)
Located in `backend/grouping_logic.py`:
```python
OPENROUTER_API_KEY = 'sk-or-v1-...'
```
### Teacher Password
Located in `backend/main.py` (SystemData model):
```python
teacherPassword: str = "teacher123"
```
Change as needed for security.
### Student Data
Students are initialized in `backend/main.py` in the `load_data()` function.
All 30 real students with Persian names and national codes are pre-loaded.
---
## πŸ“ Project Structure
```
talimbot/
β”œβ”€β”€ backend/
β”‚ β”œβ”€β”€ main.py # FastAPI server with real student data
β”‚ β”œβ”€β”€ grouping_logic.py # AI grouping with OpenRouter
β”‚ β”œβ”€β”€ requirements.txt # Python dependencies
β”‚ β”œβ”€β”€ README.md # Backend documentation
β”‚ └── data/
β”‚ └── students.json # Auto-created data storage
β”‚
β”œβ”€β”€ assets/
β”‚ β”œβ”€β”€ css/
β”‚ β”‚ └── styles.css
β”‚ └── js/
β”‚ β”œβ”€β”€ data.js # API client for student data
β”‚ └── grouping.js # API client for grouping
β”‚
β”œβ”€β”€ pages/
β”‚ β”œβ”€β”€ login.html # Login with national code
β”‚ β”œβ”€β”€ student-dashboard.html
β”‚ β”œβ”€β”€ student-data.html
β”‚ β”œβ”€β”€ teacher-dashboard.html
β”‚ └── group-view.html
β”‚
β”œβ”€β”€ Icons/ # UI icons
β”œβ”€β”€ index.html # Redirects to login
β”œβ”€β”€ README.md # This file
β”œβ”€β”€ .gitignore # Git ignore rules
└── start-backend.ps1 # Windows startup script
```
---
## 🎯 Features
### βœ… Implemented
- **Real Student Data**: 30 actual students with Persian names
- **National Code Authentication**: Secure login using national IDs
- **Persistent Storage**: JSON database on backend
- **AI-Powered Grouping**: OpenRouter GPT-4o-mini integration
- **Persian Language**: Full RTL support with Persian reasoning
- **Teacher Controls**: Show/hide results, reset grouping
- **Math Grades**: Real grades from class records
- **MBTI & Learning Styles**: Comprehensive personality analysis
- **Peer Preferences**: Students select preferred groupmates
### 🎨 UI Features
- Modern, responsive design with Tailwind CSS
- Persian (RTL) interface
- Real-time validation
- Progress indicators
---
## πŸ› Troubleshooting
### "Failed to fetch" errors
**Problem:** Backend not running or wrong URL
**Solution:**
1. Check backend is running: Visit `http://localhost:8000`
2. Should see: `{"message":"TalimBot API is running"}`
3. Check `API_BASE_URL` in JS files matches backend
### Students can't login
**Problem:** Wrong national code
**Solution:**
- National code must be exactly 10 digits
- Must match the code in backend database
- Check `backend/main.py` for correct codes
### Students can't see groups
**Problem:** Teacher hasn't enabled visibility
**Solution:**
- Teacher must click "Show Results to Students"
- Button appears after grouping is complete
### Grouping fails
**Problem:** API error or no internet
**Solution:**
1. Check internet connection
2. Verify OpenRouter API key is valid
3. Check backend logs for errors
4. System has fallback random grouping if AI fails
---
## πŸ“Š Student List (Sample)
| # | Student Number | Name | National Code | Math Grade |
|---|----------------|------|---------------|------------|
| 1 | S001 | Ψ’Ψ―ΫŒΩ†Ω‡ پور - ΫŒΨ§Ψ³Ω…Ω† | 929986644 | 16.0 |
| 2 | S002 | Ψ§Ψ­Ω…Ψ―Ψ²Ψ§Ψ―Ω‡ - پریا | 980085330 | 12.0 |
| 3 | S003 | Ψ§Ϊ©Ψ¨Ψ±Ψ²Ψ§Ψ―Ω‡ - فاطمه | 970154550 | 11.0 |
| 4 | S004 | Ψ§Ω„Ω‡ΫŒ Ω…Ω‡Ψ± - Ψ’Ω†Ψ§Ω‡ΫŒΨͺΨ§ | 26425955 | 17.0 |
| 5 | S005 | Ψ§Ω…ΫŒΨ±ΫŒ - Ω…Ψ±ΫŒΩ… | 980093341 | 18.0 |
| ... | ... | ... | ... | ... |
| 30 | S030 | وحدΨͺی - Ψ¨Ψ§Ψ±Ψ§Ω† | 929916913 | 12.0 |
*Full list available in `backend/main.py`*
---
## πŸ” Security Notes
### Current (Demo/Development):
- βœ… Simple password authentication
- βœ… CORS allows all origins
- βœ… National codes as passwords
### Recommended for Production:
- πŸ”’ Use environment variables for secrets
- πŸ”’ Implement JWT token authentication
- πŸ”’ Enable HTTPS only
- πŸ”’ Add rate limiting
- πŸ”’ Use PostgreSQL instead of JSON
- πŸ”’ Hash national codes
- πŸ”’ Implement proper session management
---
## πŸ“ž API Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Health check |
| `/api/students` | GET | Get all students |
| `/api/student/{id}` | GET | Get one student |
| `/api/student/{id}` | PUT | Update student |
| `/api/auth/student` | POST | Authenticate student |
| `/api/auth/teacher` | POST | Authenticate teacher |
| `/api/grouping/perform` | POST | Run AI grouping |
| `/api/grouping/status` | GET | Get stats |
| `/api/grouping/toggle-visibility` | POST | Show/hide results |
| `/api/grouping/reset` | POST | Clear grouping |
| `/api/student/{id}/group` | GET | Get student's group |
---
## πŸŽ“ Technologies Used
### Backend
- **FastAPI** - Modern Python web framework
- **Uvicorn** - ASGI server
- **Pydantic** - Data validation
- **aiohttp** - Async HTTP client
- **OpenRouter API** - AI integration
### Frontend
- **HTML5 / CSS3** - Structure and styling
- **Tailwind CSS** - Utility-first CSS
- **JavaScript (Async/Await)** - Modern JS
- **Fetch API** - HTTP requests
### Deployment
- **GitHub Pages** - Frontend hosting (free)
- **Render.com** - Backend hosting (free)
---
## πŸ“ License
This project is for educational purposes.
---
## πŸ™ Credits
- Student data from class 1061 (Ψ―Ω‡Ω… Ψͺجربی)
- AI grouping powered by OpenRouter (GPT-4o-mini)
---
## βœ… Pre-Launch Checklist
- [ ] Backend running locally
- [ ] Students can login with national codes
- [ ] Teacher can login with password
- [ ] Grouping works with AI
- [ ] Visibility toggle works
- [ ] All 30 students load correctly
- [ ] Persian names display properly
- [ ] Math grades show correctly
- [ ] Backend deployed to Render
- [ ] Frontend deployed to GitHub Pages
- [ ] API URLs updated for production
---
**Live URL:** `https://talimbot.github.io/talimbot/pages/login.html`
**Last Updated:** December 2025