លំហសិក្សាកម្ពុជា លំហសិក្សាកម្ពុជា V1.0
ចូល ចុះឈ្មោះ

ReanMate Ai Tutur (Advanced OOP II Report)

អ្នកចូលរួម
គ្រូដឹកនាំ: សេក សុជាតិ
មូលសង្ខេប / Abstract

ReanMate is an AI-powered learning platform for people in Cambodia. The intended Minimum Viable Product (MVP) allows teachers to set up private classes, invite students to join online via a join code, upload PDFs and videos to the class, create assignments and quizzes, and manage each class's student usage of AI assistance. Students are able to enroll in authorized courses, view lessons created by the teacher, complete assignments and quizzes, and use AI tools to ask questions or get answers from lessons, quizzes, and assignments — all grounded in the teacher's uploaded content. The system is engineered to handle Khmer, English, or mixed-language questions, and to indicate the source document and page from which each AI answer is generated. This project illustrates advanced object-oriented programming concepts, including classes, service classes, repository classes, validation, composition, and separation of responsibility. It shows the structure of a layered system that decouples routes/controllers, business services, repositories, models, templates, and database access. Users, classes, memberships, lessons, videos, documents, assignments, conversations, messages, sources, practice questions, and AI usage records are stored in a relational database. The AI workflow involves processing and chunking PDFs, retrieving relevant embeddings, and building a grounded prompt that asks the OpenAI API or Gemini for an answer.

ពាក្យគន្លឹះ

UNIVERSITY OF TECHNOLOGY & ENTREPRENEURSHIP

Faculty of Technology — BSc (Hons) in Computer Science

ReanMate

AI Tutor and Private Classroom

Report

 

Field

Detail

Student Names

Yin Keo Odom, Thai Sokchea, Toek Pheakdey, Pou Chhiangheng

Lecturer / Professor

Prof. Sek Sokcheat

Academic Year – Term

Year 2, Term 5

Status

MVP in active development — live build available


 

Table of Contents

Table of Contents.................................................................................................................................... 2

Abstract.................................................................................................................................................. 4

Project Links............................................................................................................................................ 4

Introduction............................................................................................................................................ 5

Background.......................................................................................................................................... 5

Problem Statement.............................................................................................................................. 5

Solution............................................................................................................................................... 5

Objectives............................................................................................................................................ 5

Research and Development Questions.................................................................................................. 5

Scope................................................................................................................................................... 6

Included........................................................................................................................................... 6

Limited (out of scope for MVP)......................................................................................................... 6

Target Users and Stakeholders............................................................................................................. 6

Chapter 2: Literature and Technology Review........................................................................................... 7

Python................................................................................................................................................. 7

Flask.................................................................................................................................................... 7

PostgreSQL.......................................................................................................................................... 7

Retrieval-Augmented Generation......................................................................................................... 7

OpenAI API.......................................................................................................................................... 7

System Features................................................................................................................................... 7

Session Module................................................................................................................................ 7

Authorization Module...................................................................................................................... 8

User Management Module............................................................................................................... 8

Class Management Module.............................................................................................................. 8

Lesson & PDF Module....................................................................................................................... 8

Assignment Module......................................................................................................................... 8

AI Tutor Module............................................................................................................................... 8

Practice Module............................................................................................................................... 8

Admin Module................................................................................................................................. 9

Object-Oriented Programming Class Design.......................................................................................... 9

Service Layer...................................................................................................................................... 10

Repository Layer................................................................................................................................ 10

Project Structure................................................................................................................................ 10

System Architecture........................................................................................................................... 11

Database Design................................................................................................................................. 11

Why This Design............................................................................................................................. 11

Main Relations............................................................................................................................... 12

Implementation Plan.......................................................................................................................... 12

AI Response Rule............................................................................................................................ 13

API / Route Plan................................................................................................................................. 13

Security Design................................................................................................................................... 13

AI Usage Controls............................................................................................................................... 14

Testing................................................................................................................................................... 15

Function Testing................................................................................................................................. 15

Security Testing.................................................................................................................................. 15

AI Quality Testing............................................................................................................................... 15

Development Methodology and Timeline............................................................................................... 16

Development Phases.......................................................................................................................... 16

Weekly Timeline................................................................................................................................. 16

Risk, Ethics, and Privacy......................................................................................................................... 17

Risk and Mitigation............................................................................................................................ 17

Privacy............................................................................................................................................... 17

Ethical AI Use..................................................................................................................................... 17

Chapter 3: Current Implementation and UI Showcase............................................................................. 18

Conclusion............................................................................................................................................. 21

Future Work.......................................................................................................................................... 21

References............................................................................................................................................. 22

 


 

Abstract

ReanMate is an AI-powered learning platform for people in Cambodia. The intended Minimum Viable Product (MVP) allows teachers to set up private classes, invite students to join online via a join code, upload PDFs and videos to the class, create assignments and quizzes, and manage each class's student usage of AI assistance. Students are able to enroll in authorized courses, view lessons created by the teacher, complete assignments and quizzes, and use AI tools to ask questions or get answers from lessons, quizzes, and assignments — all grounded in the teacher's uploaded content. The system is engineered to handle Khmer, English, or mixed-language questions, and to indicate the source document and page from which each AI answer is generated.

This project illustrates advanced object-oriented programming concepts, including classes, service classes, repository classes, validation, composition, and separation of responsibility. It shows the structure of a layered system that decouples routes/controllers, business services, repositories, models, templates, and database access. Users, classes, memberships, lessons, videos, documents, assignments, conversations, messages, sources, practice questions, and AI usage records are stored in a relational database. The AI workflow involves processing and chunking PDFs, retrieving relevant embeddings, and building a grounded prompt that asks the OpenAI API or Gemini for an answer.

Project Links

Live Application: https://z-rean-mate-abum.vercel.app/

Source Code (GitHub): https://github.com/The-Prompt-Guys/zReanMate

The links above point to the team's working deployment and source repository for ReanMate, referenced throughout this report and shown in the UI Showcase section.


 

Introduction

Background

Digital learning systems increasingly combine course materials, assignments, communications, and personalized learning support. ReanMate implements a focused learning environment in which a teacher's own lesson material becomes the main knowledge source for the AI tutor, instead of treating AI as a general-purpose chatbot. The platform connects the AI experience directly to a private class and the teacher's uploaded PDF lessons.

Problem Statement

●      Students need additional explanations after class.

●      PDF materials alone do not provide interactive learning support.

●      General AI may provide answers outside the teacher's materials.

●      Students need answers they can verify against the original lesson.

●      Teachers need control over AI usage in their classes.

●      Private class materials must be protected from unauthorized access.

●      Khmer/English bilingual AI support is needed.

●      Teachers need classes, lessons, PDFs, and assignments in one platform.

●      AI usage must be controlled and monitored.

Solution

ReanMate will provide private classes, teacher-managed PDF lessons, assignments, and a controlled AI tutor that answers questions based only on authorized class materials.

Objectives

●      Implement secure login and role-based access.

●      Manage lessons and PDF learning materials.

●      Manage assignments and student progress.

●      Build a PDF-grounded AI Tutor.

●      Support Khmer and English learning.

●      Provide AI answers with source-page references.

●      Generate practice questions.

●      Track and control AI usage.

●      Apply secure OOP-based system architecture.

Research and Development Questions

●      How can object-oriented design be used to separate learning-domain responsibilities from database and web concerns?

●      How can private class membership be enforced throughout normal requests and AI retrieval?

●      How can teacher-uploaded PDF material be transformed into searchable chunks while preserving page information?

●      How can a RAG workflow provide useful AI explanations while reducing unsupported answers?

●      How can the system support Khmer, English, and mixed-language questions?

●      How can AI usage be measured and limited during a small demonstration?

Scope

Included

●      Student, teacher, and administrator roles.

●      Private classes with join codes.

●      Class membership management.

●      Teacher-created lessons and private PDF materials.

●      PDF viewing and page navigation.

●      Teacher-created and published assignments.

●      Student assignment dashboard and status filtering.

●      Class-scoped AI Tutor and Study Workspace.

●      AI quick actions: Explain in Khmer, Summarize, Generate Practice Questions, and Quiz Me.

●      Source document/page citation for grounded AI answers.

●      Practice sets and questions.

●      AI usage tracking and limits.

●      Administrative monitoring of users, classes, documents, and AI usage.

Limited (out of scope for MVP)

●      Live video classes.

●      Native mobile application.

●      Payments and subscriptions.

●      School-wide administration.

●      Public course marketplace.

●      AI voice tutor.

●      Advanced proctoring.

●      Full LMS grading engine.

●      Automatic high-stakes grading.

●      Additional AI providers before the OpenAI-based MVP is reliable.

Target Users and Stakeholders

Role

Main Responsibilities

Student

Join private classes, read lessons, view assignments, ask the AI Tutor, practice, and monitor learning activity.

Teacher

Create classes, manage members, upload lessons, create assignments, and configure class AI behavior.

Admin

Manage users and classes, monitor document processing and AI usage, apply system controls, and review technical logs.

Lecturer / Evaluator

Review the R&D process, OOP design, implementation, testing, and final demonstration.


 

Chapter 2: Literature and Technology Review

The project uses object-oriented programming to represent important concepts such as User, Class, Lesson, Document, Assignment, Conversation, and AI Usage. The goal is not to create classes only for appearance — each class has a clear responsibility and meaningful methods. Services coordinate business workflows, while repositories isolate database operations.

Composition is preferred where one component depends on another, such as an AI service depending on a repository or usage tracker. Inheritance is used only when the relationship is meaningful, such as role-specific behavior, where it improves the design. Type hints, validation, and documentation are used for public methods.

Python

Python is the main programming language for the course implementation. Its class system, type hints, modules, exception handling, testing ecosystem, and web frameworks make it suitable for demonstrating object-oriented design.

Flask

Flask is used as the web framework required by the Advanced OOP course. Flask routes/controllers receive requests, validate access, call service methods, and return HTML views or JSON responses. The route layer does not contain direct SQL queries or complex business rules.

PostgreSQL

PostgreSQL is used as the primary relational database for the course implementation. Relational tables represent users, classes, memberships, lessons, documents, assignments, conversations, messages, and AI usage. Primary keys, foreign keys, unique constraints, and appropriate data types are used to maintain data integrity.

Retrieval-Augmented Generation

ReanMate uses a retrieval-augmented generation (RAG) concept. Teacher PDFs are processed page by page, cleaned, divided into chunks, and represented for semantic retrieval. When a student asks a question, the application checks authentication, class membership, AI availability, and usage limits before retrieving relevant material. The retrieved context is then used to construct a grounded prompt for the AI provider.

A key requirement is that retrieval must remain inside the student's authorized class/document scope. The AI system must not retrieve chunks from another private class. When the material does not sufficiently answer a question, the tutor states that the material is insufficient rather than inventing a source or page.

OpenAI API

The product specification selects the OpenAI API as the MVP AI provider. The API key remains on the backend and is never exposed to the browser. AI requests, token usage, and estimated cost are recorded for monitoring.

System Features

Session Module

●      Register

●      Login

●      Logout

●      Password management

Authorization Module

●      Student role

●      Teacher role

●      Admin role

●      Role-based access control

User Management Module

●      User list

●      CRUD

●      Search

●      User report

Class Management Module

●      Class list

●      CRUD

●      Search

●      Class report

Lesson & PDF Module

●      Lesson list

●      CRUD

●      PDF upload/delete

●      Search

●      Processing status

Assignment Module

●      Assignment list

●      CRUD

●      Search/filter

●      Assignment report

AI Tutor Module

●      Ask AI

●      PDF-based retrieval

●      Source/page citation

●      AI usage tracking

Practice Module

●      Practice list

●      CRUD

●      Search

●      Practice results

Admin Module

●      User management

●      Class monitoring

●      AI usage monitoring

●      System controls


Figure 1. Educational Platform System — module breakdown.

Object-Oriented Programming Class Design

Class

Responsibility

Example Methods

User

Represent account identity, role, and status.

has_role(), is_active()

Classroom

Represent a private learning class.

generate_join_code(), archive()

ClassMember

Represent membership between a user and class.

can_access()

Lesson

Represent an ordered published/unpublished lesson.

publish(), unpublish()

Document

Represent an uploaded lesson PDF and processing state.

validate(), mark_ready()

DocumentChunk

Represent page-aware searchable document content.

metadata()

Assignment

Represent teacher-created class work.

publish(), close(), is_overdue()

AssignmentProgress

Track a student's assignment state.

complete(), submit()

Conversation

Represent a student's AI conversation.

add_message()

Message

Represent an AI/student message.

record_usage()

MessageSource

Connect an AI message to a document page/chunk.

open_reference()

PracticeSet

Represent saved practice generated from material.

add_question()

PracticeQuestion

Represent one practice question.

check_answer()

AIUsage

Record request type, model, tokens, and estimated cost.

within_limit()

Service Layer

Service

Responsibility

Auth Service

Registration, login, password verification, session-related business rules.

Class Service

Create classes, join codes, membership, archive and access rules.

Lesson Service

Create/publish lessons and coordinate lesson documents.

Document Service

Validate uploads, coordinate private storage and processing status.

Assignment Service

Create/publish/close assignments and manage assignment state.

AI Service

Coordinate AI requests, prompts, answers, citations, and usage recording.

RAG Service

Retrieve authorized document chunks and prepare grounded context.

Practice Service

Generate and store practice sets and questions.

Usage Service

Apply request limits and record token/cost information.

Repository Layer

Repositories provide database access without UI logic. Example repositories include UserRepository, ClassRepository, ClassMemberRepository, LessonRepository, DocumentRepository, AssignmentRepository, ConversationRepository, PracticeRepository, and AIUsageRepository. Parameterized SQL or a safe database abstraction is used instead of concatenating user input into SQL.

Project Structure

project_name/
├── app/
│   ├── __init__.py        # Flask application factory
│   ├── config.py          # configuration classes
│   ├── extensions.py      # db, login_manager, bcrypt, etc.
│   ├── models/            # domain/data models
│   ├── repositories/      # MySQL data access
│   ├── services/          # business rules / workflows
│   ├── routes/            # Flask blueprints
│   ├── forms/             # WTForms or validation helpers
│   ├── templates/         # Jinja2 pages
│   └── static/            # CSS, JS, images
├── tests/
├── migrations/ or sql/
├── docs/
├── run.py
├── requirements.txt
└── README.md

System Architecture

The request flow is Browser → Flask Routes/Controllers → Services → Repositories → PostgreSQL. The AI flow adds document processing and retrieval components: PDF Upload → Validation → Private Storage → Page Extraction → Chunking → Embedding/Indexing → Authorized Retrieval → Grounded Prompt → OpenAI API → Saved Answer + Sources.


Database Design

The API owns every data access decision. PostgreSQL is the durable state store; Redis and MinIO solve separate operational problems and never hold the authoritative learning record.


Why This Design

●      DATABASE_URL and storage credentials stay in the backend environment only.

●      File bytes are not database columns — relational rows keep private object metadata.

●      PostgreSQL remains authoritative even when Redis or MinIO is temporarily unavailable.


Main Relations

●      One teacher can own many classes.

●      A class can contain many students through ClassMember.

●      A class can contain many lessons.

●      A lesson can have one or more associated documents depending on final implementation.

●      A document can contain many page-aware document chunks.

●      A class can contain many assignments.

●      An assignment can have progress records for many students.

●      A conversation belongs to a user and can be scoped to a class/lesson/document.

●      A conversation contains many messages.

●      An AI message can have multiple source references.

●      AIUsage records connect usage to a user and, optionally, a class.

Implementation Plan

User Interface → Student Experience → Teacher Experience → Admin Experience → AI Processing Workflow


 Teacher PDF upload workflow and student question workflow.

AI Response Rule

●      Teacher material is the primary evidence.

●      If the material is insufficient, the system clearly says so.

●      The AI must never fabricate a source page.

●      Explanations should be readable and appropriate for students.

●      Khmer, English, and mixed-language questions are supported.

●      Useful English technical terms may be preserved in Khmer explanations.

●      For assessed assignments, the tutor should prefer explanations, hints, examples, and step-by-step guidance rather than automatically providing final answers.

API / Route Plan

Area

Example Endpoint

Authentication

POST /auth/register, POST /auth/login

Classes

GET/POST /classes, POST /classes/join

Students

GET /classes/<id>/students

Lessons

GET/POST /classes/<id>/lessons

Documents

POST /lessons/<id>/documents

Assignments

GET/POST /classes/<id>/assignments, PATCH /assignments/<id>

AI

POST /ai/ask, POST /ai/practice

Admin

GET /admin/ai-usage

Security Design

●      Hash passwords securely.

●      Keep the OpenAI API key on the backend only.

●      Apply server-side role and ownership guards.

●      Validate resource access on every protected request to prevent IDOR.

●      Use private/signed document URLs where applicable.

●      Validate PDF MIME type and maximum file size.

●      Rate-limit authentication, upload, and AI endpoints.

●      Log administrative actions and AI errors without logging secrets.

●      Keep classes private by default.

AI Usage Controls

Limit

Demo Setting

Total demo users

10

AI Tutor

30 requests/user/day

Burst rate

3 AI requests/minute/user

Monthly user ceiling

500 AI requests/user

AI lesson

2 sessions/day if enabled

Practice generation

3 sets/day


 

Testing

Function Testing

Test

Expected Result

Teacher creates a class

Class is created and a join code is available.

Student joins valid class

Student becomes a class member.

Student uses disabled/archived code

Join is rejected.

Teacher uploads valid PDF

PDF is accepted and processing begins.

Teacher uploads invalid/oversized file

Upload is rejected with a clear error.

Student opens published lesson

Authorized student can view the PDF.

Teacher publishes assignment

Assignment appears to authorized students.

Student asks grounded AI question

Answer is returned with a source document/page.

Khmer/English/mixed question

Tutor responds appropriately in the requested language.

Admin views AI usage

Usage and estimated cost are visible.

Security Testing

●      Student attempts to access another class by changing a URL ID.

●      Student attempts to access another class's document directly.

●      Teacher attempts to edit another teacher's class.

●      User attempts to change their role through a frontend request.

●      AI endpoint is called above its rate limit.

●      Vector retrieval attempts to cross a class boundary.

●      Non-PDF and oversized uploads are submitted.

AI Quality Testing

●      Question is directly answered in the PDF.

●      Question is partially answered in the PDF.

●      Question is absent from the PDF and the AI should state that the material is insufficient.

●      Khmer-only question.

●      English-only question.

●      Mixed Khmer/English question.

●      Student makes an incorrect assumption and the tutor corrects it using the source material.

●      Source page opens the correct PDF location.


 

Development Methodology and Timeline

Development Phases

Phase

Main Work

Acceptance Evidence

0 – Foundation

Repository, Flask frontend/backend setup, MySQL, environment, lint/test baseline.

Application and database run together.

1 – Authentication

Register/login/logout, roles, protected routes.

Role-based access works.

2 – Private Classes

Create class, join code, join/leave, student list, archive.

Class flow works without AI.

3 – Lessons & PDFs

Lessons, PDF upload/storage, validation, viewer, processing status.

Student securely opens teacher PDF.

4 – Assignments

Teacher create/publish; student dashboard and assignment page.

Deadlines and visibility work.

5 – Document AI Processing

Page extraction, chunking, embeddings/indexing.

Relevant chunks are retrieved.

6 – RAG + OpenAI

Grounded prompt, API call, citations, no-answer behavior.

AI answer includes correct source.

7 – Study Workspace

PDF + AI split workspace, quick actions, language modes.

Approved learning UI works.

8 – Practice

Generate/save practice questions and explanations.

Practice can be reused.

9 – Usage Controls

Rate limits, token/cost tracking, admin controls.

AI usage remains controlled.

10 – QA & Demo

Security, responsive testing, ten-user accounts, real lesson validation.

Reliable demonstration.

Weekly Timeline

Week

Task

Deliverable

1

Finalize scope, team roles, and requirements.

Confirmed project direction.

2

OOP class design, architecture, ERD, and Flask foundation.

Class diagram, ERD & project skeleton.

3

Authentication, roles, private classes, and membership.

Working login, access control & class module.

4

Lessons, PDF upload, and Assignments modules.

Lesson, PDF & Assignment modules.

5

PDF processing, chunk retrieval, RAG, and OpenAI integration.

Searchable document chunks & grounded AI Tutor.

6

Study Workspace development and UI refinement.

Student workspace.

7

Practice features and usage controls.

Practice tools & limits.

8

Security, functional testing, and bug fixing.

Test evidence & bug fixes.

9

Final bug fixing and demo preparation.

Stable MVP.

10

Final report writing and defense PPTX preparation.

Final submission.


 

Risk, Ethics, and Privacy

Risk and Mitigation

Risk

Impact

Mitigation

AI API cost increases

High

Rate limits, daily/monthly caps, usage tracking, global AI control.

AI gives unsupported information

High

RAG grounding, source citations, insufficient-material behavior.

Cross-class data exposure

Critical

Membership guards, ownership checks, retrieval filters, security tests.

PDF processing failure

Medium

File validation, processing status, error handling.

Scope becomes too large

High

Keep MVP exclusions and prioritize core proof.

Team member availability

Medium

Clear responsibilities and shared Git activity.

Security mistakes

High

Server-side authorization and dedicated security testing.

Privacy

●      Classes are private by default.

●      Documents are not exposed via public URLs.

●      Student conversations are not exposed to other students.

●      Teacher analytics should prefer aggregate signals rather than reading private chats.

●      Administrative access to user content should be minimal and audited.

●      Technical logs should avoid secrets and unnecessary private content.

Ethical AI Use

ReanMate is intended to support learning rather than replace the student's own work. For marked assignments, the tutor prefers explanations, hints, examples, and step-by-step guidance rather than automatically providing a final answer. The system also communicates uncertainty when the teacher's material does not contain enough information to answer.


 

Chapter 3: Current Implementation and UI Showcase

The screenshots below are taken from the live ReanMate deployment (see Project Links) and show the mobile-first UI implemented so far for the student experience: the home dashboard, the learning-document library, joining a class, the AI study assistant chat, and the profile/settings screen.

Home Dashboard


Welcomes the signed-in student by name, offers a one-tap “add your material” shortcut for uploading a PDF, and lists the student's document folders (e.g. “cake”, “data”).

Learning Documents Library


Lists every document folder the student has created, each showing how many files it contains, with a floating action button to add a new folder or document.

Classroom — Join a Class


The Classroom tab, where a student who has not yet joined a class is prompted to enter one using a join code, matching the private-class membership flow described in Chapter 2.

AI Study Assistant


The class-scoped AI Tutor chat. A document/class selector at the top constrains retrieval, and the assistant opens by asking what the student wants help with, grounded in their own learning material.


 

Profile and Settings


Shows the student's activity summary (documents studied, streak days, goal progress) and account settings such as notifications, session timeout, appearance, and language (Khmer/English).

 


 

Conclusion

ReanMate implements a focused AI-assisted learning platform that combines private classes, teacher-controlled PDF materials, assignments, and a document-grounded AI tutor. The design directly supports the Advanced OOP course requirements by separating domain objects, services, repositories, routes, and database access. It also provides a practical R&D problem: how to make AI assistance useful while maintaining private class boundaries, source traceability, and controlled usage.

The MVP is deliberately limited to approximately ten users so that the team can prioritize a reliable end-to-end proof. The core demonstration is complete when a teacher creates a private class, uploads a real lesson, creates an assignment, a student joins the class, studies the PDF, asks a useful question in Khmer or English, receives a grounded answer with the correct source page, and completes the learning flow without manual database intervention.

A working build of the student experience is already deployed and browsable at the Live Application link in the Project Links section, with the full source available in the GitHub repository, and is illustrated in the UI Showcase (Chapter 3).

Future Work

●      Flashcards and improved AI lesson mode.

●      Richer assignment submissions and a stronger progress page.

●      Announcements and due-date notifications.

●      DOCX/PPTX support.

●      Mock exams and weak-topic detection.

●      Teacher review workflow.

●      School/organization accounts and institution analytics.

●      AI voice questions, OCR, lecture transcription, personalized tutoring, study plans, and AI-generated diagrams.

The product plan recommends delaying payment systems, school administration, additional AI providers, and other broad LMS features until the core student and teacher value is proven.


 

References

[1] S. Sokcheat, “Advanced Object-Oriented Programming,” lecture notes, University of Technology and Entrepreneurship, Phnom Penh, Cambodia, 2026.

[2] GeeksforGeeks, “Object-Oriented Programming (OOPs) Concept in Java,” GeeksforGeeks, 2026. [Online]. Available: https://www.geeksforgeeks.org/object-oriented-programming-oops-concept-in-java/

ចែករំលែក
រក្សាទុក
ការផ្សព្វផ្សាយ
ការផ្សព្វផ្សាយ
មតិយោបល់ 0
ចូលគណនី ដើម្បីបញ្ចេញមតិ