Skip to main content

Education System Overview

The Akako LMS education system provides a comprehensive hierarchical structure for organizing and delivering educational content. The system is designed to be flexible, scalable, and user-friendly for both educators and learners.

System Architecture

Hierarchical Structure

The education system follows a four-level hierarchy:

Education Level (e.g., "Primary School")
└── Grade (e.g., "Grade 1", "Grade 2")
└── Subject (e.g., "Mathematics", "Science")
└── Topic (e.g., "Addition", "Photosynthesis")

Database Schema

model EducationLevel {
id String @id @default(cuid())
name String @unique
description String
imageUrl String?
isActive Boolean @default(true)
deletedAt DateTime?

grades Grade[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model Grade {
id String @id @default(cuid())
name String
description String @default("")
level String // primary, secondary, higher
imageUrl String?
isActive Boolean @default(true)
deletedAt DateTime?

educationLevelId String
educationLevel EducationLevel @relation(fields: [educationLevelId], references: [id], onDelete: Cascade)
subjects Subject[]

@@unique([name, educationLevelId])
}

model Subject {
id String @id @default(cuid())
name String
description String
imageUrl String?
isActive Boolean @default(true)
deletedAt DateTime?

// Mentor assignment
mentorId String?
mentorEmail String?

gradeId String
grade Grade @relation(fields: [gradeId], references: [id], onDelete: Cascade)
topics Topic[]

@@unique([name, gradeId])
}

model Topic {
id String @id @default(cuid())
name String
description String
content String @db.Text
videoUrl String?
isActive Boolean @default(true)
deletedAt DateTime?

// Documents storage
documents Json? // Array of document metadata

subjectId String
subject Subject @relation(fields: [subjectId], references: [id], onDelete: Cascade)

@@unique([name, subjectId])
}

Key Features

1. Content Management

Video Management

  • Supported Formats: MP4, WebM, OGG, MOV, AVI
  • Restricted Formats: MKV (with conversion guidance)
  • Dynamic MIME Type Detection: Automatic format detection
  • Error Handling: Comprehensive error handling for playback issues

Document Management

  • File Types: PDF, Excel, Word, and other formats
  • AWS S3 Integration: Scalable cloud storage
  • Role-based Access: Admin/mentor upload, enrolled learners download
  • Metadata Storage: JSON field for document information

Content Organization

  • Hierarchical Navigation: Easy content discovery
  • Search and Filter: Find content quickly
  • Progress Tracking: Monitor learning progress
  • Completion Status: Track topic completion

2. Mentor Assignment

Mentors are assigned at the Subject level only:

// Subject with mentor assignment
const subject = await prisma.subject.create({
data: {
name: "Mathematics",
description: "Basic mathematics concepts",
gradeId: gradeId,
mentorId: mentorClerkId,
mentorEmail: mentorEmail,
},
});

Why Subject Level Only?

  • Aligns with educational hierarchy
  • Provides focused expertise
  • Simplifies mentor management
  • Better matches real-world teaching structure

3. Uniqueness Constraints

The system enforces uniqueness at each level:

  • Education Level: Names are globally unique
  • Grade: Names are unique within each education level
  • Subject: Names are unique within each grade
  • Topic: Names are unique within each subject
-- Database constraints
CREATE UNIQUE INDEX education_levels_name_key ON education_levels(name);
CREATE UNIQUE INDEX grades_name_educationLevelId_unique ON grades(name, "educationLevelId");
CREATE UNIQUE INDEX subjects_name_gradeId_unique ON subjects(name, "gradeId");
CREATE UNIQUE INDEX topics_name_subjectId_unique ON topics(name, "subjectId");

User Experience

For Learners

Content Access

  • Enrollment Required: Must be enrolled in subjects to access content
  • Progress Tracking: Visual progress indicators
  • Note-taking: Personal notes for each topic
  • Document Downloads: Access to study materials

Learning Features

  • Video Player: Built-in video player with controls
  • Responsive Design: Works on all devices
  • Offline Notes: Notes saved locally and synced
  • Completion Tracking: Mark topics as completed

For Mentors

Content Creation

  • Topic Management: Create and edit topics
  • Video Upload: Upload educational videos
  • Document Management: Upload study materials
  • Content Organization: Organize content hierarchically

Student Management

  • Progress Monitoring: Track student progress
  • Enrollment Management: Approve/reject enrollments
  • Student Notes: View student notes and feedback

For Admins

System Management

  • Full CRUD Operations: Create, read, update, delete all content
  • User Management: Manage mentors and learners
  • Content Oversight: Monitor all educational content
  • System Configuration: Configure education levels and grades

API Endpoints

Education Content Management

// Get all education levels
GET /api/education/levels

// Get grades for a level
GET /api/education/levels/[id]/grades

// Get subjects for a grade
GET /api/education/grades/[id]/subjects

// Get topics for a subject
GET /api/education/subjects/[id]/topics

// Create new education level
POST /api/admin/education/levels

// Update education level
PUT /api/admin/education/levels/[id]

// Delete education level
DELETE /api/admin/education/levels/[id]

Video Management

// Upload video for topic
PUT /api/admin/education/topics/[id]/video

// Delete video from topic
DELETE /api/admin/education/topics/[id]/video

Document Management

// Upload document
POST /api/s3/document/upload

// Stream document
GET /api/s3/document/stream?key=[s3Key]

// Delete document
DELETE /api/admin/education/topics/[id]/documents/[documentId]

Content Creation Workflow

1. Create Education Level

const educationLevel = await prisma.educationLevel.create({
data: {
name: "Primary School",
description: "Elementary education for ages 6-12",
imageUrl: "https://example.com/primary-school.jpg",
},
});

2. Create Grade

const grade = await prisma.grade.create({
data: {
name: "Grade 1",
description: "First grade curriculum",
level: "primary",
educationLevelId: educationLevel.id,
},
});

3. Create Subject

const subject = await prisma.subject.create({
data: {
name: "Mathematics",
description: "Basic mathematics concepts",
gradeId: grade.id,
mentorId: mentorClerkId,
mentorEmail: mentorEmail,
},
});

4. Create Topic

const topic = await prisma.topic.create({
data: {
name: "Addition",
description: "Learning basic addition",
content: "Addition is the process of combining numbers...",
subjectId: subject.id,
},
});

Error Handling

Content Validation

The system includes comprehensive error handling:

// Duplicate content validation
if (existingContent) {
return NextResponse.json(
{ error: 'Content with this name already exists' },
{ status: 409 }
);
}

// Video format validation
const allowedFormats = ['mp4', 'webm', 'ogg', 'mov', 'avi'];
if (!allowedFormats.includes(fileExtension)) {
return NextResponse.json(
{ error: 'Unsupported video format' },
{ status: 400 }
);
}

User-friendly Error Messages

  • Duplicate Content: Clear messages about existing content
  • Format Issues: Guidance on supported formats
  • Permission Errors: Clear role-based access messages
  • Upload Failures: Detailed error information

Performance Optimizations

Database Queries

  • Selective Fields: Use select to fetch only needed data
  • Proper Indexing: Indexes on frequently queried fields
  • Pagination: Implement pagination for large datasets
  • Caching: Use TanStack Query for client-side caching

File Management

  • AWS S3: Scalable cloud storage
  • CDN Integration: Fast content delivery
  • Image Optimization: Automatic image compression
  • Lazy Loading: Load content as needed

Security Features

Access Control

  • Role-based Access: Different permissions for different roles
  • Enrollment Validation: Only enrolled users can access content
  • File Security: Secure document streaming with access validation
  • Input Validation: Comprehensive input sanitization

Content Protection

  • Video Streaming: Secure video delivery
  • Document Access: Role-based document access
  • API Protection: Protected API endpoints
  • Data Validation: Zod schema validation

Next Steps