মনচিত্র প্রজেক্ট গাইড
ডেটাবেস স্পেসিফিকেশন
প্রস্তাবিত relational entity, প্রধান field, সম্পর্ক, index ও row-level access rule।
Schema অবস্থা ও নিয়ম
পরিদর্শনের সময় সংযুক্ত Supabase database-এ public table ছিল না। এই নথি target model নির্ধারণ করে; migration প্রয়োগ ও পুনরায় যাচাই না হওয়া পর্যন্ত table বা capability deployed বলে ধরা যাবে না।
- UUID primary key, timestamptz audit field, explicit foreign key ও check constraint ব্যবহার করুন।
- foreign key এবং সাধারণ owner/status/date query path index করুন।
- user, child, annotation, progress ও payment-সম্পর্কিত সব table-এ RLS চালু করুন।
মূল entity ও সম্পর্ক
| Table | গুরুত্বপূর্ণ field | সম্পর্ক / index |
|---|---|---|
| profiles | id (auth user FK), display_name, locale, created_at | প্রতি auth user-এ একটি profile |
| student_profiles | user_id, class_level, curriculum, medium, board, consent_state | profile FK; class/medium index |
| guardian_links | guardian_id, student_id, status, approved_at | guardian/student pair unique; status index |
| teachers / class_members | teacher_id, class_id, student_id, role | membership FK; class/user index |
| curriculums / books | code, class_level, medium, subject, title, status | প্রকাশিত content index |
| book_versions / chapters / pages | version, chapter_order, page_number, localized body | book/version ও chapter/page order unique |
| text_nodes / audio_assets | page_id, node_key, text, locale, asset_key, rights | Page FK; locale ও order index |
| annotations / bookmarks | user_id, page_id, kind, selected_text, note, color | Owner/page index; owner-only RLS |
| questions / quiz_attempts | chapter_id, version, prompt, options, key, explanation, answers, score | শিক্ষার্থী তালিকায় answer key প্রকাশ নয় |
| study_rooms / room_members / comments | room_id, member_id, status, body, moderation_state | প্রতিটি room write-এ membership যাচাই |
| learning_progress | user_id, book_version_id, page_index, completed_at | user/book-version unique; user scope |
| subscriptions / payments | user_id, provider, status, amount_bdt, idempotency_key | server-only mutation; unique idempotency key |
RLS policy matrix
| ডেটা শ্রেণি | Read | Write |
|---|---|---|
| প্রকাশিত শিক্ষামূলক content | প্রকাশিত row-এ anonymous/authenticated read | শুধু editor/admin server path |
| Profile ও student record | মালিক; অনুমোদিত linked guardian summary | মালিক-সীমিত field; role field server-only |
| Private note ও bookmark | শুধু মালিক | মালিক ও বৈধ page relationship |
| Quiz attempt ও progress | শিক্ষার্থী মালিক; স্পষ্ট scope-এ guardian | |
| Room content | অনুমোদিত room member ও moderator | বিদ্যমান membership + moderation rule |
| Subscription/payment | মালিক-নিরাপদ receipt summary | শুধু trusted server/provider webhook |
Index ও data integrity
- Unique: guardian_links(guardian_id, student_id); bookmarks(user_id, page_id); learning_progress(user_id, book_version_id)।
- Composite: pages(chapter_id, page_number); chapters(book_version_id, position); questions(chapter_id, status, position)।
- নির্ভরশীল learning content-এ ON DELETE CASCADE ব্যবহার করুন; অনুমোদিত retention policy অনুযায়ী financial audit record রাখুন।
- medium, status, annotation kind, BDT amount ও consent state constraint দিয়ে যাচাই করুন।
উদাহরণ record ও migration
উদাহরণ table contract sql
create table public.bookmarks (
id uuid primary key default gen_random_uuid(),
user_id uuid not null references auth.users(id) on delete cascade,
page_id uuid not null references public.pages(id) on delete cascade,
created_at timestamptz not null default now(),
unique (user_id, page_id)
);
alter table public.bookmarks enable row level security;
create policy bookmarks_owner_all
on public.bookmarks for all
using (auth.uid() = user_id)
with check (auth.uid() = user_id);