Overview
Emohol is a multi-tenant SaaS platform for coaching centers in Bangladesh. It provides comprehensive management tools for students, teachers, parents, attendance, fees, and AI-powered features.
Student Management
Track students, enrollments, attendance, and academic progress.
Teacher Tools
Manage batches, assignments, grading, and communication.
Parent Portal
Keep parents informed with progress reports and notifications.
AI Features
Dropout prediction, smart reports, and doubt solving.
Tech Stack
- API: Cloudflare Workers + Hono.js
- Database: Cloudflare D1 (SQLite)
- Frontend: Cloudflare Pages (Static HTML/JS)
- Authentication: JWT tokens
Quick Start
1. Register a Coaching Center
curl -X POST https://emohol-api.humayunkabir1140.workers.dev/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"centerName": "My Coaching Center",
"ownerName": "Your Name",
"email": "owner@example.com",
"password": "secure123",
"phone": "01700000000",
"city": "Dhaka"
}'
2. Login to Get Token
curl -X POST https://emohol-api.humayunkabir1140.workers.dev/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "owner@example.com",
"password": "secure123"
}'
token from the response. You'll need it for all authenticated requests.
3. Access the Dashboard
Visit https://emohol-dashboard.pages.dev and login with your credentials.
Architecture
Multi-Tenant Structure
Each coaching center is isolated with its own:
- Unique subdomain (e.g.,
mycoaching.emohol.com) - Isolated data (all queries filtered by
coaching_center_id) - Custom branding options
User Roles
| Role | Description | Permissions |
|---|---|---|
owner |
Coaching center owner | Full access to all features |
admin |
Administrator | Manage users, settings (no billing) |
teacher |
Teacher/Instructor | Manage batches, attendance, assignments |
student |
Student | View own data, submit assignments |
parent |
Parent/Guardian | View linked children's data |
Authentication API
/api/auth/register
Register a new coaching center with owner account.
/api/auth/login
Login and receive JWT token.
Using the Token
Include the token in all authenticated requests:
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...
Users & Students API
/api/users
List all users in the coaching center.
/api/users
Create a new user (student, teacher, etc.).
{
"name": "Student Name",
"email": "student@example.com",
"password": "password123",
"phone": "01700000000",
"role": "student"
}
/api/students/:id
Get detailed student information including attendance and assignments.
Dropout Prediction AI
শিক্ষার্থী ঝরে পড়া রোধে এআই - Students at risk of dropping out are identified early.
/api/ai/dropout-prediction
Get all at-risk students with their risk scores.
Response Example
{
"success": true,
"summary": {
"total_students": 50,
"at_risk_count": 8,
"critical": 2,
"high": 3,
"medium": 3,
"low": 0
},
"students": [
{
"id": 10,
"name": "Test Student",
"email": "student@test.com",
"riskScore": 45,
"riskLevel": "high",
"riskFactors": ["Critical attendance", "Frequent recent absences"],
"metrics": {
"attendance_rate": 35,
"recent_absences": 5,
"days_inactive": 3
}
}
]
}
Risk Scoring Algorithm
| Factor | Weight | Trigger |
|---|---|---|
| Attendance Rate | 30% | <50% = Critical, <70% = Low, <85% = Warning |
| Recent Absences | 15% | >5 in 2 weeks = High, >3 = Medium |
| Inactivity | 10% | >14 days = High, >7 days = Low |
/api/ai/dropout-prediction/:studentId/alert
Send alert to parent about at-risk student.
Smart Progress Reports
অভিভাবকদের জন্য স্মার্ট প্রগ্রেস রিপোর্ট - AI-generated insights in English and Bengali.
/api/ai/progress-report/:studentId
Generate comprehensive progress report with AI insights.
Response Example
{
"success": true,
"report": {
"student": { "id": 10, "name": "Test Student" },
"overallScore": 65,
"attendanceRate": 78,
"assignmentCompletionRate": 85,
"avgGrade": 72,
"status": "good",
"status_bn": "ভালো",
"insights": [
{
"type": "positive",
"message_en": "Good attendance, but there's room for improvement.",
"message_bn": "ভালো উপস্থিতি, তবে আরও উন্নতির সুযোগ আছে।"
}
]
}
}
/api/ai/progress-report/:studentId/voice-script
Get voice-ready script for WhatsApp sharing (English + Bengali).
Voice Script Response
{
"success": true,
"voiceScript": {
"script_en": "Hello, this is a progress update for Test Student. Attendance is 78%, which is good but could be better.",
"script_bn": "আসসালামু আলাইকুম। Test Student এর অভিভাবক, আপনার সন্তানের গত ৩০ দিনের অগ্রগতি রিপোর্ট শুনুন। উপস্থিতি ৭৮ শতাংশ, যা মোটামুটি ভালো।",
"student_name": "Test Student",
"attendance_rate": 78
}
}
AI Doubt Solver
ডাউট সলভিং এজেন্ট - Students can ask questions and get AI-assisted answers.
/api/ai/doubt-solver/ask
Submit a question (for students).
{
"question": "What is photosynthesis?",
"subject": "Biology",
"batch_id": 1
}
/api/ai/doubt-solver/pending
Get pending questions for teachers to answer.
/api/ai/doubt-solver/:questionId/answer
Teacher submits an answer to a question.
Deploy API
Prerequisites
- Node.js 18+
- Cloudflare account
- Wrangler CLI installed
Steps
# 1. Navigate to API directory
cd emohol/api
# 2. Install dependencies
npm install
# 3. Login to Cloudflare
npx wrangler login
# 4. Create D1 database (first time only)
npx wrangler d1 create emohol-db
# 5. Run migrations
npx wrangler d1 execute emohol-db --remote --file=migrations/001_initial.sql
npx wrangler d1 execute emohol-db --remote --file=migrations/002_subscriptions.sql
npx wrangler d1 execute emohol-db --remote --file=migrations/003_messaging_reports.sql
npx wrangler d1 execute emohol-db --remote --file=migrations/004_ai_features.sql
# 6. Deploy
npx wrangler deploy
https://emohol-api.{your-subdomain}.workers.dev
Deploy Dashboard
# Deploy dashboard to Cloudflare Pages
npx wrangler pages deploy ./dashboard --project-name emohol-dashboard
Update API URL
Edit dashboard/index.html and update the API URL:
const API_URL = 'https://your-api-url.workers.dev';
Custom Domain Setup
For API (Workers)
- Go to Cloudflare Dashboard > Workers & Pages
- Select your worker
- Go to Settings > Triggers
- Add Custom Domain:
api.emohol.com
For Dashboard (Pages)
- Go to Cloudflare Dashboard > Workers & Pages
- Select your Pages project
- Go to Custom Domains
- Add:
dashboard.emohol.com
Test Endpoints
Health Check
curl https://emohol-api.humayunkabir1140.workers.dev/health
Full API Test Script
#!/bin/bash
API="https://emohol-api.humayunkabir1140.workers.dev"
# Register
echo "=== Register ==="
curl -s -X POST "$API/api/auth/register" \
-H "Content-Type: application/json" \
-d '{
"centerName": "Test Academy",
"ownerName": "Test Owner",
"email": "test@example.com",
"password": "test123456"
}'
# Login
echo -e "\n\n=== Login ==="
RESPONSE=$(curl -s -X POST "$API/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com", "password": "test123456"}')
echo $RESPONSE
TOKEN=$(echo $RESPONSE | grep -o '"token":"[^"]*' | cut -d'"' -f4)
# Create Student
echo -e "\n\n=== Create Student ==="
curl -s -X POST "$API/api/users" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Student One",
"email": "student1@test.com",
"password": "student123",
"role": "student"
}'
# Test Dropout Prediction
echo -e "\n\n=== Dropout Prediction ==="
curl -s "$API/api/ai/dropout-prediction" \
-H "Authorization: Bearer $TOKEN"
# Test Progress Report
echo -e "\n\n=== Progress Report ==="
curl -s "$API/api/ai/progress-report/1" \
-H "Authorization: Bearer $TOKEN"
Sample Data
Add Test Attendance
# Using wrangler D1 execute
npx wrangler d1 execute emohol-db --remote --command="
INSERT INTO attendance (batch_id, student_id, date, status) VALUES
(1, 10, date('now', '-1 day'), 'present'),
(1, 10, date('now', '-2 days'), 'present'),
(1, 10, date('now', '-3 days'), 'absent'),
(1, 10, date('now', '-4 days'), 'present'),
(1, 10, date('now', '-5 days'), 'late');
"
Add Test Assignment
npx wrangler d1 execute emohol-db --remote --command="
INSERT INTO assignments (batch_id, title, description, due_date, total_marks)
VALUES (1, 'Math Homework 1', 'Complete exercises 1-10', date('now', '+7 days'), 100);
"