Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

254 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ UniVerse β€” School Management Platform

Fastify Next.js React Flutter TypeScript Prisma PostgreSQL Redis Docker Firebase Gemini

Connecting Admins β€’ Teachers β€’ Security β€’ Parents through one unified backend, a web dashboard, and a mobile app.


✨ What's Inside

πŸ” Auth & RBAC JWT + bcrypt + OTP, 5 roles (admin/teacher/security/parent/pending), parent 2FA

πŸšͺ Gate System QR scan IN/OUT + auto-checkout cron at 18:00 + parent FCM alerts

βœ… Attendance Daily sessions, batch submit, calendar view, parent visibility

πŸ“Š Results Per-term modules, grades, publish/unpublish flow

πŸ’¬ Messaging Threads, contacts, AI draft suggestions

πŸ“’ Announcements School-wide & class-scoped notices

πŸ€– RAG Chatbot Policy PDFs β†’ Gemini embeddings (768-dim pgvector) β†’ hybrid search β†’ LLM

πŸ™‹ Complaints Parent β†’ admin β†’ staff triage, status state machine

πŸ”” Push Notifications Firebase FCM (multicast)

πŸ” Lost & Found Items posted by staff, reports filed by parents

πŸ“§ Email Resend OTPs & approval notifications

⚑ Cache Redis for RAG, sessions, online status (graceful degrade)


πŸ“ Project Structure

Universe-System/                              🟦 npm workspace monorepo
β”‚
β”œβ”€β”€ 🟩 apps/
β”‚   β”œβ”€β”€ backend/                              βš™οΈ  Fastify + Prisma REST API  Β·  :5000
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ server.ts Β· app.ts            πŸš€ entry + Fastify config
β”‚   β”‚   β”‚   β”œβ”€β”€ config/                       πŸ”§ env Β· prisma Β· redis Β· firebase Β· supabase
β”‚   β”‚   β”‚   β”œβ”€β”€ common/{middleware,utils}/    πŸ›‘οΈ  authenticate Β· rbac Β· errorHandler Β· jwt Β· hash Β· otp Β· email Β· cache
β”‚   β”‚   β”‚   └── modules/                      πŸ“¦ 11 feature modules
β”‚   β”‚   β”‚       β”œβ”€β”€ auth/ Β· users/ Β· school/
β”‚   β”‚   β”‚       β”œβ”€β”€ gate/ Β· attendance/
β”‚   β”‚   β”‚       β”œβ”€β”€ announcements/ Β· messages/
β”‚   β”‚   β”‚       β”œβ”€β”€ complaints/ Β· lost-found/ Β· results/
β”‚   β”‚   β”‚       └── rag/{controllers,services}  πŸ€– chunker Β· embedder Β· retrieval Β· generation
β”‚   β”‚   β”œβ”€β”€ prisma/schema.prisma              πŸ—„οΈ  20 models Β· pgvector Β· uuid-ossp
β”‚   β”‚   β”œβ”€β”€ tests/{unit,integration}/         πŸ§ͺ Jest + supertest
β”‚   β”‚   β”œβ”€β”€ Dockerfile.dev Β· jest.config.js
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   β”œβ”€β”€ frontend/                             🌐 Next.js 16 + React 19 + Tailwind  Β·  :3000
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ app/                          πŸ“ App Router
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ login/ Β· register/ Β· forgot-password/ Β· pending/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ admin/    {overview,attendance,students,teachers,complaints,notices,...}
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ teacher/  {overview,attendance,classes,results,messages,notices,...}
β”‚   β”‚   β”‚   β”‚   └── security/ {dashboard,logs,messages,overview,profile}
β”‚   β”‚   β”‚   β”œβ”€β”€ features/                     🧩 auth Β· attendance Β· gate Β· messages Β· notices Β· complaints Β· results Β· rag Β· school
β”‚   β”‚   β”‚   β”œβ”€β”€ shared/components/            🎨 layout Β· auth Β· admin Β· ui Β· AttendanceCalendar
β”‚   β”‚   β”‚   β”œβ”€β”€ shared/hooks/ Β· shared/lib/
β”‚   β”‚   β”‚   └── core/
β”‚   β”‚   β”œβ”€β”€ Dockerfile.dev Β· eslint.config.mjs
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   └── flutter/                              πŸ“± Flutter parent app (Android/iOS)
β”‚       β”œβ”€β”€ lib/
β”‚       β”‚   β”œβ”€β”€ main.dart Β· app.dart Β· firebase_options.dart
β”‚       β”‚   β”œβ”€β”€ core/                         πŸ”§ api Β· di Β· navigation Β· services Β· storage
β”‚       β”‚   β”œβ”€β”€ features/                     🧩 15 modules
β”‚       β”‚   β”‚   β”œβ”€β”€ splash/ Β· auth/ Β· dashboard/ Β· profile/
β”‚       β”‚   β”‚   β”œβ”€β”€ attendance/ Β· gate/ Β· results/
β”‚       β”‚   β”‚   β”œβ”€β”€ messages/ Β· contact_teacher/ Β· notices/
β”‚       β”‚   β”‚   β”œβ”€β”€ chatbot/ Β· support/ Β· lost_and_found/
β”‚       β”‚   β”‚   β”œβ”€β”€ notifications/ Β· settings/
β”‚       β”‚   └── shared/{themes,widgets}/      🎨 ActionCard Β· AppButton Β· LiveClockWidget
β”‚       β”œβ”€β”€ android/ Β· ios/
β”‚       β”œβ”€β”€ test/widget_test.dart
β”‚       β”œβ”€β”€ .githooks/{pre-commit,pre-push}
β”‚       └── pubspec.yaml
β”‚
β”œβ”€β”€ πŸŸͺ .github/workflows/
β”‚   β”œβ”€β”€ ci.yml                                βœ… PR tests (backend + flutter)
β”‚   └── flutter-release.yml                   πŸ“¦ APK auto-build on release/development
β”‚
β”œβ”€β”€ 🟧 .husky/                                πŸͺ pre-commit Β· pre-push Β· commit-msg (commitlint)
β”œβ”€β”€ 🟫 Doc/                                   πŸ“š 10 detailed reference docs
β”œβ”€β”€ 🟨 Documentation/                         πŸ“– 5 comprehensive guides (overview Β· backend Β· frontend Β· flutter Β· devops)
β”‚
β”œβ”€β”€ 🐳 docker-compose.yml                     production stack
β”œβ”€β”€ 🐳 docker-compose.dev.yml                 dev stack (hot reload)
β”œβ”€β”€ πŸ“¦ package.json Β· package-lock.json       single root workspace
β”œβ”€β”€ 🎨 .prettierrc Β· commitlint.config.js     code style + conventional commits
β”œβ”€β”€ ⚑ vercel.json                            Vercel deploy config
└── πŸ”Œ .mcp.json                              MCP servers (Supabase)

🐳 Quick Start with Docker

🟒 One command. Three services up.

# 1️⃣  Set env vars
cp apps/backend/.env.example apps/backend/.env       # fill in secrets
touch apps/frontend/.env.local                       # add NEXT_PUBLIC_API_URL=http://backend:5000

# 2️⃣  Run the dev stack (hot reload)
docker compose -f docker-compose.dev.yml up --build

# 3️⃣  Stop
docker compose -f docker-compose.dev.yml down

🟒 Services started

Service URL Container
🟦 Backend API http://localhost:5000 universe-backend
πŸ’š Health Check http://localhost:5000/health β€”
πŸŸͺ Web Frontend http://localhost:3000 universe-frontend
πŸ”΄ Redis localhost:6379 universe-redis

πŸ”΅ Production stack

docker compose up --build      # uses docker-compose.yml (no volume mounts, NODE_ENV=production)

πŸ§‘β€πŸ’» Run Without Docker

npm install                                          # install all workspaces
npm run prisma:generate --prefix apps/backend        # generate Prisma client

# Two terminals
npm run backend:dev          # βš™οΈ  http://localhost:5000
npm run frontend:dev         # 🌐 http://localhost:3000

# Flutter (3rd terminal)
cd apps/flutter && flutter pub get && flutter run

πŸ“² Android emulator uses http://10.0.2.2:5000 Β· iOS simulator uses http://127.0.0.1:5000.


πŸ”‘ Required Environment Variables

🟦 Backend β€” apps/backend/.env
PORT=5000
DATABASE_URL=postgresql://...                # Supabase pooled
DIRECT_URL=postgresql://...                  # Supabase direct (Prisma migrations)
REDIS_URL=redis://redis:6379                 # optional (graceful degrade)
JWT_SECRET=...                               # min 32 chars
SUPABASE_URL=...
SUPABASE_ANON_KEY=...
SUPABASE_SERVICE_KEY=...
RESEND_API_KEY=re_...
GEMINI_API_KEY=...
FIREBASE_PROJECT_ID=...
FIREBASE_SERVICE_ACCOUNT_JSON='{"type":"service_account",...}'
WEB_URL=http://localhost:3000
FLUTTER_ORIGIN=http://localhost:3001
πŸŸͺ Frontend β€” apps/frontend/.env.local
NEXT_PUBLIC_API_URL=http://localhost:5000
NEXT_PUBLIC_SUPABASE_URL=https://....supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=...
πŸ“± Flutter β€” build-time
flutter build apk --dart-define=API_BASE_URL=https://api.yourdomain.com

🎯 Tech Stack at a Glance

Layer Backend Web Mobile
Framework 🟒 Fastify 5 ⚫ Next.js 16 App Router πŸ”΅ Flutter 3.32
Language πŸ”· TypeScript πŸ”· TypeScript 🎯 Dart
State / Data Prisma 6 + PostgreSQL React 19 + Context Provider + Repositories
HTTP Built-in (Fastify) fetch + credentials Dio + interceptors
Validation Zod 4 Zod + react-hook-form Custom
Auth JWT (7d) + bcrypt + OTP HttpOnly cookies flutter_secure_storage + biometric
Cache / Realtime Redis 7 β€” FCM + local notifications
AI Gemini embeddings + LLM β€” Calls backend RAG
Testing 🟑 Jest (3 of 11 modules) πŸ”΄ None yet πŸ”΄ 1 smoke test
Hosting Railway Vercel GitHub Releases / TestFlight

πŸͺ Git Hooks (auto-enforced)

Hook Action
🟒 pre-commit ESLint --fix on staged files
🟑 pre-push Lint + production build
πŸ”΅ commit-msg Conventional Commits (feat: fix: docs: ...)
πŸ“± Flutter pre-commit dart format staged .dart files
πŸ“± Flutter pre-push flutter test

🚦 CI/CD

Workflow Trigger What it does
🟒 ci.yml Every PR Backend unit + integration tests · Flutter widget tests
πŸ“¦ flutter-release.yml Push to release/development Builds debug APK Β· Auto-bumps semver tag Β· Publishes GitHub Release

πŸ“š Documentation

Folder Contents
πŸ“– Documentation/ 5 comprehensive guides β€” overview Β· backend Β· frontend Β· flutter Β· devops
πŸ“š Doc/ 10 deep references β€” schema Β· auth flow Β· API Β· realtime Β· sprints Β· production checklist

🌿 Branch Strategy

Branch Purpose
🟒 main Production-ready
🟑 release/development Active integration (triggers Flutter APK build)
πŸ”΅ feature/* Individual work

Built with ❀️ by @Methexx

πŸ“„ ISC License

About

AI-assisted schoolcommunication platform tailored for Sri Lankan higher education institutions.

Resources

Stars

Watchers

Forks

Releases

Contributors

Languages