Skip to content

YeboLearn Services Deep Dive ​

Complete documentation of every backend service with methods, parameters, and functionality.

AIService ​

Location: backend/src/services/aiService.ts

AI-powered features using Google Gemini.

Methods ​

generateDailyReport(data) ​

Generates a daily progress report for a student.

typescript
interface DailyReportData {
  studentName: string;
  attendanceToday: 'present' | 'absent' | 'late' | 'excused';
  recentGrades: { subject: string; score: number; maxScore: number; date: string }[];
  behaviorNotes?: string;
  classParticipation?: string;
}

// Returns: string (2-3 paragraph report)

generateWeeklyReport(data) ​

Comprehensive weekly summary.

typescript
interface WeeklyReportData {
  studentName: string;
  weekStartDate: string;
  weekEndDate: string;
  attendanceRate: number;
  grades: { subject: string; averageScore: number; trend: 'improving' | 'stable' | 'declining' }[];
  strengths: string[];
  areasForImprovement: string[];
}

gradeEssay(data) ​

AI-assisted essay grading with rubric.

typescript
interface EssayGradingData {
  essayText: string;
  rubric: { criteria: string; maxPoints: number }[];
  gradingGuidelines?: string;
}

// Returns:
interface GradingResult {
  totalScore: number;
  maxScore: number;
  feedback: string;
  criteriaScores: { criteria: string; score: number; feedback: string }[];
}

generateLessonPlan(data) ​

Creates comprehensive lesson plans.

typescript
interface LessonPlanInput {
  subject: string;
  topic: string;
  gradeLevel: string;
  duration: number;  // minutes
  learningObjectives?: string[];
  curriculumFramework?: string;
}

// Returns:
interface LessonPlan {
  title: string;
  objectives: string[];
  materials: string[];
  introduction: string;
  mainActivity: string;
  assessment: string;
  conclusion: string;
  homework?: string;
}

generateQuiz(data) ​

Auto-generates quizzes with multiple question types.

typescript
interface QuizInput {
  subject: string;
  topic: string;
  gradeLevel: string;
  numberOfQuestions: number;
  questionTypes?: ('multiple-choice' | 'true-false' | 'short-answer')[];
}

tutorHelp(data) ​

24/7 AI homework assistance.

typescript
// Guides students step-by-step, doesn't just give answers
async tutorHelp(data: {
  question: string;
  subject: string;
  gradeLevel: string;
  context?: string;
}): Promise<string>

generateLearningPath(data) ​

Personalized multi-week learning plans.

typescript
interface LearningPathInput {
  studentName: string;
  subject: string;
  currentLevel: string;
  strengths: string[];
  weaknesses: string[];
  goals: string[];
}

// Returns 4-8 week path with weekly topics, activities, and resources

AuthService ​

Location: backend/src/services/auth.service.ts

Handles authentication, password management, and session security.

Methods ​

register(data) ​

typescript
interface RegisterData {
  school_id?: string;
  email: string;
  password: string;  // Validated against PasswordPolicy
  first_name: string;
  last_name: string;
  phone?: string;
  role: UserRole;
}

// Returns: { user, accessToken, refreshToken }

Security Features:

  • Password policy validation (length, complexity, no personal info)
  • Account lockout protection
  • Token versioning

login(email, password, schoolId?) ​

typescript
// Security: 
// - 5 failed attempts = 30 min lockout
// - Audit logging on success/failure
// - Token version check

// Returns: { user, accessToken, refreshToken }

refreshAccessToken(refreshToken) ​

Rotates tokens securely:

  • Verifies refresh token validity
  • Checks token version matches DB
  • Issues new token pair
  • Deletes old refresh token

changePassword(userId, currentPassword, newPassword) ​

typescript
// Security:
// - Validates new password against policy
// - Prevents password reuse
// - Increments token_version (invalidates all sessions)
// - Audit logs the change

logoutAllDevices(userId) ​

Invalidates all sessions by incrementing token_version.


StudentService ​

Location: backend/src/services/student.service.ts

Student lifecycle management.

Methods ​

MethodParametersDescription
createStudent{ school_id, first_name, last_name, ... }Creates student with auto-provisioned guardian link
getStudentByIdid, schoolIdFetches with class/guardian joins
updateStudentid, schoolId, dataUpdates profile
deleteStudentid, schoolIdSoft-delete
listStudentsschoolId, filtersPaginated list with search
assignToClassstudentId, classIdClass assignment

TeacherService ​

Location: backend/src/services/teacherService.ts

Methods ​

MethodDescription
createTeacherCreates teacher user with subjects
getTeacherByIdWith classes and subjects
assignSubjectsLink teacher to subjects
getTeacherScheduleWeekly class schedule
getTeacherClassesAll assigned classes

GradeService ​

Location: backend/src/services/gradeService.ts

Academic performance tracking.

Methods ​

typescript
// Create grade entry
async createGrade(data: {
  student_id: string;
  subject_id: string;
  school_id: string;
  assessment_type: 'quiz' | 'test' | 'exam' | 'assignment';
  score: number;
  max_score: number;
  teacher_id: string;
  term?: string;
}): Promise<Grade>

// Get student grades
async getStudentGrades(studentId: string, schoolId: string, filters?: {
  subjectId?: string;
  term?: string;
  dateFrom?: Date;
  dateTo?: Date;
}): Promise<Grade[]>

// Calculate GPA
async calculateGPA(studentId: string, schoolId: string, term?: string): Promise<number>

// Class grade analytics
async getClassGradeDistribution(classId: string): Promise<GradeDistribution>

AttendanceService ​

Location: backend/src/services/attendance.service.ts

Methods ​

typescript
// Mark attendance
async markAttendance(data: {
  student_id: string;
  class_id: string;
  date: Date;
  status: 'present' | 'absent' | 'late' | 'excused';
  marked_by: string;
  notes?: string;
}): Promise<Attendance>

// Bulk mark (teacher marking entire class)
async bulkMarkAttendance(classId: string, date: Date, records: AttendanceRecord[]): Promise<void>

// Get attendance stats
async getStudentAttendanceRate(studentId: string, dateRange: DateRange): Promise<{
  present: number;
  absent: number;
  late: number;
  excused: number;
  rate: number;  // percentage
}>

FeeService ​

Location: backend/src/services/feeService.ts

School fee management.

Methods ​

MethodDescription
createFeeStructureDefine fee items per term
generateInvoiceCreate invoice for student
recordPaymentLog payment against invoice
getStudentBalanceOutstanding amount
getPaymentHistoryStudent payment records
sendPaymentReminderVia notification service

NotificationService ​

Location: backend/src/services/notification.service.ts

Multi-channel notifications.

typescript
async sendNotification(data: {
  userId: string;
  type: 'in_app' | 'email' | 'sms' | 'whatsapp' | 'push';
  title: string;
  body: string;
  action_url?: string;
  data?: Record<string, unknown>;
}): Promise<void>

// Bulk notifications
async sendBulkNotification(userIds: string[], notification: NotificationData): Promise<void>

// Get user notifications
async getUserNotifications(userId: string, options: {
  unreadOnly?: boolean;
  limit?: number;
  offset?: number;
}): Promise<Notification[]>

AnalyticsService ​

Location: backend/src/services/analytics.service.ts

Reporting and insights.

Methods ​

typescript
// School-wide dashboard
async getSchoolAnalytics(schoolId: string): Promise<{
  totalStudents: number;
  totalTeachers: number;
  attendanceRate: number;
  averageGPA: number;
  feeCollectionRate: number;
}>

// Student performance trends
async getStudentPerformanceTrend(studentId: string, months: number): Promise<TrendData[]>

// Class comparison
async getClassComparison(schoolId: string, subjectId: string): Promise<ClassComparison[]>

// Subject analytics
async getSubjectAnalytics(schoolId: string, subjectId: string): Promise<SubjectAnalytics>

Other Services ​

ServicePurpose
ClassServiceClass/section management
SubjectServiceSubject CRUD
GuardianServiceParent/guardian management
MessageServiceIn-app messaging
UploadServiceFile uploads to R2
ReportServiceReport card generation
FlashcardServiceStudy flashcards
AvatarTeacherServiceAI avatar tutor
GamificationServicePoints, badges, leaderboards
AuditLogServiceSecurity audit trail
OnboardingServiceSchool onboarding wizard
SchoolManagementServicePlatform admin school ops
PlatformAuthServiceSuper admin auth

One chat. Everything done.