Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
257 commits
Select commit Hold shift + click to select a range
9489d64
Align At Risk filter controls
k2the4 Aug 29, 2026
8eeb56a
Fix At Risk score color consistency
k2the4 Aug 29, 2026
40f2e4e
Fix at-risk filter sizing and excellent status color
k2the4 Aug 29, 2026
09fe7b7
Fix attendance trend metric and at-risk apply flow
k2the4 Aug 29, 2026
5bff14d
Fix academic table controls, colors, and apply behavior
k2the4 Aug 29, 2026
5ba8940
Fix overall basic and moderated mark colors
k2the4 Aug 29, 2026
9ab2dde
Redesign teacher dashboard
k2the4 Aug 29, 2026
670405d
Seed ECE batches and semester subjects
k2the4 Aug 29, 2026
8036e69
Reuse legacy ECE 7th-semester class in seed
k2the4 Aug 29, 2026
bb4ffdb
Add complete ECE batch curriculum seed
k2the4 Aug 29, 2026
a0c545f
Add teacher-scoped subject analysis chooser
k2the4 Aug 29, 2026
4041419
Fix subject analysis class scoping
k2the4 Aug 29, 2026
f14de4e
Route dashboard Subject Analysis through teacher chooser
k2the4 Aug 29, 2026
30803ab
test assignment update
k2the4 Aug 29, 2026
80ae7f4
Assign Geetanjali to six ECE classes
k2the4 Aug 29, 2026
a807061
Add theory and lab subject types
k2the4 Aug 29, 2026
e43dbcc
Seed ECE faculty and theory/lab subjects
k2the4 Aug 29, 2026
2cab1bc
Fix Geetanjali ECE 2 Sem 7 assignment
k2the4 Aug 29, 2026
958180a
Run Geetanjali assignment fix after seed
k2the4 Aug 29, 2026
8d1cea0
Seed ECE 2 Sem 7 students
k2the4 Aug 29, 2026
4fcd085
Run ECE 2 Sem 7 student seed
k2the4 Aug 29, 2026
c86f263
Merge main ClassPulse updates
k2the4 Aug 29, 2026
7af9380
Add themed Class Analysis class selector
k2the4 Aug 30, 2026
d8faa96
Use ECE-2 class naming in Subject Analysis
k2the4 Aug 30, 2026
e2a7046
Route legacy class analysis URLs through selector
k2the4 Aug 30, 2026
b739f76
Fix dashboard Class Analysis navigation to selector
k2the4 Aug 30, 2026
3681809
Restore existing Class Analysis experience after selector
k2the4 Aug 30, 2026
c49b117
Fix class analysis routing to existing section analysis
k2the4 Aug 30, 2026
3360489
Fix Class Analysis section routing and authorization
k2the4 Aug 30, 2026
318c692
Restore working section analysis route
k2the4 Aug 30, 2026
a831390
Route class analysis to authorized section
k2the4 Aug 30, 2026
c31f65b
Resolve class and section IDs for analysis access
k2the4 Aug 30, 2026
ae1862b
style class analysis like subject analysis shell
k2the4 Aug 30, 2026
9dd4ed6
remove unused analysis nav import
k2the4 Aug 30, 2026
ee12cb0
Restyle class attendance analysis to match Subject Analysis theme
k2the4 Aug 30, 2026
d76ff1f
Match Class Analysis sidebar and navbar to Subject Analysis theme
k2the4 Aug 30, 2026
39244e9
Fix Class Analysis shell spacing to match Subject Analysis
k2the4 Aug 30, 2026
e370238
Match Class Analysis view spacing to Subject Analysis
k2the4 Aug 30, 2026
784f3ef
Fix class-to-section analysis authorization resolution
k2the4 Aug 30, 2026
d0ee096
Fix class analysis routing to use class IDs
k2the4 Aug 30, 2026
081ac1f
Make class analysis navbar match subject analysis
k2the4 Aug 30, 2026
d8aa249
Copy subject analysis structure to class analysis attendance
k2the4 Aug 30, 2026
c1a69d3
Match class academic layout to subject analysis
k2the4 Aug 30, 2026
6edb5d0
Add combined academic view to class analysis
k2the4 Aug 30, 2026
6303bcc
Add combined academic score and sort filters
k2the4 Aug 30, 2026
2a8d266
Fix max score basis for combined grading
k2the4 Aug 30, 2026
4ed2c9f
Add performance grade column to class combined view
k2the4 Aug 30, 2026
ff72a4f
Keep class academic table columns and add combined grade
k2the4 Aug 30, 2026
d806529
Widen class academic table to avoid horizontal scrolling
k2the4 Aug 30, 2026
d0ed585
Load academic table layout fix
k2the4 Aug 30, 2026
1749a35
Fix class academic table layout
k2the4 Aug 30, 2026
f6efd9e
Restore class academic grade column and vertical table scroll
k2the4 Aug 30, 2026
fcd9bd0
Fix class academic grade column visibility
k2the4 Aug 30, 2026
104febe
Fix combined class academic maximum
k2the4 Aug 30, 2026
0940ed1
Add rank column when sorting class academic data
k2the4 Aug 30, 2026
b6eb501
Add class overall at-risk analysis view
k2the4 Aug 31, 2026
6e0e359
Fix class overall analysis chart markup
k2the4 Aug 31, 2026
bec0765
Fix class analysis overall authorization
k2the4 Aug 31, 2026
196bc95
Add Raw Data to analysis sidebars
k2the4 Aug 31, 2026
7472640
Fix class-level analysis authorization
k2the4 Aug 31, 2026
d50324d
Fix class overall routing authorization
k2the4 Aug 31, 2026
30ca4a3
Match class overall shell to subject analysis
k2the4 Aug 31, 2026
72eb2fc
Limit class overall analysis to six theory subjects
k2the4 Aug 31, 2026
b038f8f
Fix class overall at-risk subjects, totals, limits and mark colors
k2the4 Aug 31, 2026
a06f715
Fix class overall JSX build error cleanly
k2the4 Aug 31, 2026
7107eb5
Fix overall filter to use average marks
k2the4 Aug 31, 2026
a8b35fd
Redesign student report page
k2the4 Aug 31, 2026
221623c
Polish student report data binding
k2the4 Aug 31, 2026
b7a1e4d
Fix student report internal mark data
k2the4 Aug 31, 2026
4a232a0
Redesign Class Analysis student report
k2the4 Aug 31, 2026
c072199
Refine student report header and internal marks table
k2the4 Aug 31, 2026
c2306df
Remove overlapping search icon from student report
k2the4 Aug 31, 2026
8cf02b2
Improve academic student table columns and spacing
k2the4 Aug 31, 2026
c6d49ba
Refine Midsem student table layout
k2the4 Aug 31, 2026
be4bd02
Fix academic Midsem 1 build and table
k2the4 Sep 1, 2026
b871e9d
Tighten academic side panel and standardize grade colors
k2the4 Sep 1, 2026
5d8532f
Fix academic table proportions and grade color mapping
k2the4 Sep 1, 2026
2dd4048
Fix combined academic sorting and grade colors
k2the4 Sep 1, 2026
007c3c3
Fix combined academic table layout and sort colors
k2the4 Sep 1, 2026
a41f74c
Remove combined performance tiers and force table to fit
k2the4 Sep 1, 2026
fa7baa8
Apply subject analysis layout fixes
k2the4 Sep 1, 2026
2e4cfae
Fix subject analysis combined table layout
k2the4 Sep 1, 2026
13473c2
Remove temporary subject analysis fix workflow
k2the4 Sep 1, 2026
a062eea
chore: apply combined analysis UI fix
k2the4 Sep 1, 2026
d1a539e
chore: retry combined analysis UI patch
k2the4 Sep 1, 2026
d49bf64
chore: add combined UI patch runner
k2the4 Sep 1, 2026
a4aabc6
fix: route subject academic through combined UI shell
k2the4 Sep 1, 2026
c5e86d6
fix: polish combined analysis layout
k2the4 Sep 1, 2026
c3bef0e
chore: remove temporary combined UI patch runner
k2the4 Sep 1, 2026
21dd000
chore: remove temporary combined UI patch workflow
k2the4 Sep 1, 2026
097ef1b
chore: remove temporary postcss UI overrides
k2the4 Sep 1, 2026
116096e
Fix academic summary table layout and controls
k2the4 Sep 2, 2026
22a75ae
Fix Academic nav active state after route rewrite
k2the4 Sep 2, 2026
ec78bd7
Fix Summary table heading and alignment
k2the4 Sep 2, 2026
bdc3a79
Standardize class analysis student report shell
k2the4 Sep 2, 2026
05f1c29
Fix class analysis student shell structure
k2the4 Sep 2, 2026
dc413a6
Add overall analysis page heading
k2the4 Sep 2, 2026
95f1269
Route class analysis shell fixes
k2the4 Sep 2, 2026
cd34ab3
Preserve student report raw data control
k2the4 Sep 2, 2026
7ee3261
Use shared class analysis sidebar for student report
k2the4 Sep 2, 2026
1eacad9
Fix Class Analysis Overall navigation active state
k2the4 Sep 2, 2026
32dde0d
Complete Class Analysis Overall layout and interactions
k2the4 Sep 2, 2026
1389fd5
Refine Overall metrics, mark mode, and distribution interactions
k2the4 Sep 2, 2026
69d4fa6
Fix Overall card spacing and table layout
k2the4 Sep 2, 2026
fc44182
Add fixed Class Analysis attendance trend layout
k2the4 Sep 2, 2026
3bd63ec
Route attendance trend through fixed layout
k2the4 Sep 2, 2026
1d094c1
Stabilize attendance trend layout and pagination
k2the4 Sep 2, 2026
5ec8334
Refine attendance trend layout and scrolling
k2the4 Sep 2, 2026
5f48519
Refine class academic midsem layout
k2the4 Sep 2, 2026
d59b37f
Match subject attendance trend layout to class attendance
k2the4 Sep 2, 2026
299c685
Route subject attendance trend through layout wrapper
k2the4 Sep 2, 2026
c61dda7
Fix subject attendance nav active state
k2the4 Sep 2, 2026
3f229a0
Match subject academic layout to class structure
k2the4 Sep 2, 2026
c6c4048
Stabilize subject academic tier layout updater
k2the4 Sep 2, 2026
22fa3c5
Align subject academic performance tier panel
k2the4 Sep 2, 2026
5f92396
Add class academic summary view with subject-level filtering
k2the4 Sep 2, 2026
b5ffa23
Fix class academic summary layout typography
k2the4 Sep 2, 2026
a3fbace
Load academic summary layout styles
k2the4 Sep 2, 2026
cbb12cb
Fix academic summary filters and ranking
k2the4 Sep 2, 2026
9e6fc31
Fix subject academic summary filters and ranking
k2the4 Sep 2, 2026
4ec2f5a
Fix section academic table ranking and alignment
k2the4 Sep 2, 2026
3b070b4
Add standalone subject academic summary page
k2the4 Sep 2, 2026
48182c9
Add standalone summary navigation to subject analysis
k2the4 Sep 2, 2026
c02a332
Route academic Summary tab to new summary page
k2the4 Sep 2, 2026
e556d5d
Keep Summary inside Academic tab
k2the4 Sep 2, 2026
4286572
Remove standalone Subject Analysis Summary page
k2the4 Sep 2, 2026
0aaf460
Remove legacy Academic UI DOM mutation
k2the4 Sep 2, 2026
36b5b89
Fix academic summary table layout
k2the4 Sep 2, 2026
c8ef1a7
Fix @ import alias resolution
k2the4 Sep 2, 2026
670cdb1
Add Supabase SSR dependency
k2the4 Sep 2, 2026
ea7068a
Restore package versions
k2the4 Sep 2, 2026
25c8746
Restore package configuration
k2the4 Sep 2, 2026
c871a6c
Fix Class Analysis sidebar destination
k2the4 Sep 2, 2026
5431f60
Fix analysis sidebar navigation
k2the4 Sep 2, 2026
10c64e1
Unify subject analysis sidebar with class analysis
k2the4 Sep 2, 2026
94bd4ce
Remove redundant class analysis page heading
k2the4 Sep 2, 2026
dde72f0
Remove redundant subject analysis page heading
k2the4 Sep 2, 2026
9de6f6d
Add class context API for analysis pages
k2the4 Sep 2, 2026
be3f072
Add subject context API for analysis pages
k2the4 Sep 2, 2026
d24c421
Show class and subject context in subject analysis
k2the4 Sep 2, 2026
39fecfd
Show class context in class analysis
k2the4 Sep 2, 2026
af05b49
Style subject context heading
k2the4 Sep 2, 2026
8e03507
Style class context heading
k2the4 Sep 2, 2026
44bb13e
Fix subject analysis info API imports
k2the4 Sep 2, 2026
ebc3c65
Fix section analysis API import paths
k2the4 Sep 2, 2026
8931c43
Add attendance agent data models
k2the4 Sep 2, 2026
6613510
Add attendance agent migration
k2the4 Sep 2, 2026
408413e
Add attendance agent API
k2the4 Sep 2, 2026
2606ec6
Build Attendance Agent UI
k2the4 Sep 2, 2026
27221d4
Support editing attendance sessions
k2the4 Sep 2, 2026
6559411
Align attendance migration name
k2the4 Sep 2, 2026
91925ec
Remove duplicate attendance migration
k2the4 Sep 2, 2026
6a33aff
Fix Attendance Agent time slots and sheet student ordering
k2the4 Sep 2, 2026
9e6b2c2
Add Attendance Agent time slot selector and sheet serial numbers
k2the4 Sep 2, 2026
6e3df8f
Improve attendance list workflow
k2the4 Sep 2, 2026
6c3b671
Add Google Sheets teacher diary attendance writer
k2the4 Sep 2, 2026
d59a09b
Enable Google Sheets writes for attendance agent
k2the4 Sep 2, 2026
57b2207
Connect attendance agent submissions to Teacher Diary sheets
k2the4 Sep 2, 2026
fac2da3
Clean attendance sheet writer before integration
k2the4 Sep 2, 2026
87b338c
Add Teacher Diary attendance deletion
k2the4 Sep 2, 2026
f0c70df
Add attendance session deletion API
k2the4 Sep 2, 2026
fddc230
Add attendance session delete action
k2the4 Sep 2, 2026
889f3a1
Sync Teacher Diary attendance to monthly sheets
k2the4 Sep 2, 2026
da288b8
Fix attendance date switching race conditions
k2the4 Sep 2, 2026
badd62d
fix attendance diary ordering and delete recovery
k2the4 Sep 2, 2026
1aaff75
fix monthly subject column detection
k2the4 Sep 3, 2026
e3e3e2e
add Google Sheets attendance session reader
k2the4 Sep 3, 2026
fb5ffc0
remove Prisma attendance storage from Attendance Agent
k2the4 Sep 3, 2026
7d29226
add class access migration
k2the4 Sep 3, 2026
24e7ed9
enforce one teacher per subject
k2the4 Sep 3, 2026
31c9b0c
add class access and single subject teacher model
k2the4 Sep 3, 2026
604872a
separate class access from subject assignment
k2the4 Sep 3, 2026
c013013
clean auth dependencies and add Supabase auth sync
k2the4 Sep 3, 2026
fe13a7c
add Supabase Auth account sync utility
k2the4 Sep 3, 2026
2fd9151
link Prisma users to Supabase Auth
k2the4 Sep 3, 2026
071baeb
move user authentication to Supabase Auth
k2the4 Sep 3, 2026
1e12b66
authenticate credentials with Supabase Auth
k2the4 Sep 3, 2026
21bb0df
remove password storage from Prisma seed
k2the4 Sep 3, 2026
7e596d2
document single database and Supabase Auth configuration
k2the4 Sep 3, 2026
7f70165
remove unused legacy Supabase admin route
k2the4 Sep 3, 2026
af95a86
remove unused legacy Supabase admin route
k2the4 Sep 3, 2026
c5e0aba
remove unused legacy Supabase admin route
k2the4 Sep 3, 2026
fb9b029
remove unused legacy Supabase admin route
k2the4 Sep 3, 2026
01643e5
remove unused legacy Supabase auth route
k2the4 Sep 3, 2026
09f71e8
remove unused legacy Supabase class route
k2the4 Sep 3, 2026
62ff820
remove unused legacy Supabase class route
k2the4 Sep 3, 2026
12e288a
remove unused legacy Supabase class route
k2the4 Sep 3, 2026
a6fef6e
remove unused legacy Supabase class route
k2the4 Sep 3, 2026
585f2b5
remove unused legacy Supabase class route
k2the4 Sep 3, 2026
c2053f9
remove unused legacy Supabase route
k2the4 Sep 3, 2026
0aab970
remove unused legacy Supabase route
k2the4 Sep 3, 2026
181184a
remove duplicate global stylesheet
k2the4 Sep 3, 2026
754cf76
remove duplicate App Router shell
k2the4 Sep 3, 2026
1461528
remove duplicate App Router CSS and session provider
k2the4 Sep 3, 2026
78a929b
remove unused duplicate Supabase auth form
k2the4 Sep 3, 2026
2048e15
remove unused legacy Supabase admin forms
k2the4 Sep 3, 2026
0d41c7d
remove unused legacy Supabase admin forms
k2the4 Sep 3, 2026
aa563a3
remove unused legacy Supabase admin forms
k2the4 Sep 3, 2026
cbd2ad8
remove unused legacy App Router shell
k2the4 Sep 3, 2026
2bb8238
remove unused legacy class form
k2the4 Sep 3, 2026
ac90f22
remove unused legacy class form
k2the4 Sep 3, 2026
32383fb
remove unused legacy upload flow
k2the4 Sep 3, 2026
75e2761
remove unused legacy class component
k2the4 Sep 3, 2026
c5cacf2
remove legacy Supabase server data layer
k2the4 Sep 3, 2026
1bee038
remove legacy Supabase data types
k2the4 Sep 3, 2026
a92db8b
remove legacy Supabase internal-marks layer
k2the4 Sep 3, 2026
f87284a
remove unused duplicate Supabase application schema
k2the4 Sep 3, 2026
794b5ce
remove unused duplicate Supabase application schema
k2the4 Sep 3, 2026
a0efc7b
remove unused duplicate Supabase application schema
k2the4 Sep 3, 2026
ead2e74
remove unused duplicate Supabase seed
k2the4 Sep 3, 2026
80aba49
document the cleaned single-source architecture
k2the4 Sep 3, 2026
045d134
use one Supabase public auth client configuration
k2the4 Sep 3, 2026
3ddbf05
use existing Supabase SSR dependency only
k2the4 Sep 3, 2026
d437cfd
use Supabase Auth as the credential authority
k2the4 Sep 3, 2026
c447c29
use the existing Supabase SSR dependency for auth provisioning
k2the4 Sep 3, 2026
078e9d1
use the official Supabase client for server-side credential verification
k2the4 Sep 3, 2026
494e516
use Supabase Auth for credential verification
k2the4 Sep 3, 2026
51e7b2c
use the official Supabase client for auth provisioning
k2the4 Sep 3, 2026
6365614
Normalize User auth identity to Supabase Auth
k2the4 Sep 3, 2026
c340c73
Make database seed commands safe and explicit
k2the4 Sep 3, 2026
f138a4e
Make ECE 2 student seed target the real class safely
k2the4 Sep 3, 2026
e09bf80
Remove legacy demo seed that creates conflicting application data
k2the4 Sep 3, 2026
b6d4485
Remove unsafe legacy Prisma seed entrypoint
k2the4 Sep 3, 2026
656f3e8
Align Supabase auth migration name with applied database migration
k2the4 Sep 3, 2026
b8fa500
Record Supabase Auth identity migration
k2the4 Sep 3, 2026
65017a7
Remove obsolete Geetanjali assignment repair script
k2the4 Sep 3, 2026
3e5bfba
Remove obsolete database repair command
k2the4 Sep 3, 2026
63989cc
Add missing foreign-key indexes to Prisma schema
k2the4 Sep 3, 2026
481f577
Record foreign-key index migration
k2the4 Sep 3, 2026
ab5af9e
Harden Supabase Auth synchronization verification
k2the4 Sep 3, 2026
50388cb
fix Prisma CLI dependency and auth sync script
k2the4 Sep 3, 2026
d8c7f5d
fix Prisma CLI dependency
k2the4 Sep 3, 2026
5188977
Fix Supabase auth sync initialization
k2the4 Sep 3, 2026
3509393
fix auth sync Supabase client typing
k2the4 Sep 3, 2026
8e6b1de
fix auth sync env loading
k2the4 Sep 3, 2026
2978c0a
Fix auth sync environment loading
k2the4 Sep 3, 2026
e7265a2
Fix auth sync env loading without Next env import
k2the4 Sep 3, 2026
068c576
fix Supabase Auth sync key handling
k2the4 Sep 3, 2026
616a957
Fix Supabase Auth sync URL handling
k2the4 Sep 3, 2026
db01953
fix auth sync secret key endpoint configuration
k2the4 Sep 3, 2026
11c331e
Fix Supabase credential auth configuration and diagnostics
k2the4 Sep 3, 2026
60ec8c1
fix Supabase auth URL normalization
k2the4 Sep 3, 2026
c500eae
Fix class analysis access to use ClassAccess
k2the4 Sep 3, 2026
8b9ccd0
Enforce ClassAccess on class analysis routes
k2the4 Sep 3, 2026
32e7f54
Fix Tailwind/PostCSS utility generation
k2the4 Sep 3, 2026
8857e6c
fix Tailwind PostCSS config
k2the4 Sep 3, 2026
8cfe0b1
Restore working PostCSS config
k2the4 Sep 3, 2026
c7c9c7e
Restore Class and Subject Analysis styles
k2the4 Sep 3, 2026
588e3f9
Load shared analysis styles
k2the4 Sep 3, 2026
b9daa39
Decouple class analysis chooser from Tailwind
k2the4 Sep 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
DATABASE_URL=
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=
# Optional comma-separated allowlist for future server-side registration enforcement, e.g. msit.in
COLLEGE_EMAIL_DOMAINS=
# Server-only. Never prefix with NEXT_PUBLIC_ and never import it into client components.
SUPABASE_SERVICE_ROLE_KEY=
NEXTAUTH_SECRET=
COLLEGE_EMAIL_DOMAINS=
CLASS_PULSE_DEFAULT_PASSWORD=changeme123
GOOGLE_SA_EMAIL=
GOOGLE_SA_PRIVATE_KEY=
169 changes: 95 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,116 @@
# ClassPulse — Attendance & Academic Analytics Platform

A college-wide web app version of the "CLASSPULSE" Google Sheet: teachers log in,
pick a class or subject, and see the same analysis (attendance trends, midsem
performance, KPI cards, top/bottom performers, report cards) — but live,
multi-user, and backed by a real database.
ClassPulse is a college-wide attendance and academic analytics application for teachers. The application reads its structured academic data from one PostgreSQL database and uses Google Sheets only as the raw attendance/marks source where configured.

## Architecture

```text
Supabase
├─ Auth
│ └─ email/password credentials
└─ PostgreSQL
└─ ClassPulse application tables
└─ accessed by the Next.js backend through Prisma

Google Sheets
└─ raw attendance / marks source for analysis syncs
```

There is one application database: the PostgreSQL database belonging to the ClassPulse Supabase project. Prisma is the ORM used by the Next.js backend to access that database. Supabase Auth is the single authority for user passwords and identities.

The current Pages Router still uses NextAuth as a session bridge around the Supabase credential check. NextAuth does not store passwords or application user records; Supabase Auth owns credentials, while Prisma owns the ClassPulse user/profile and academic data.

## Data model

```text
College
└─ Department (e.g. ECE)
└─ Class (e.g. B.Tech ECE, 4th Year, Sem 7)
└─ Section (e.g. A)
├─ Student (enrollment no, name, email)
└─ Subject (e.g. Data Analysis — DA 338 T)
├─ TeacherAssignment (which teacher owns this subject/section)
├─ SheetLink (the Google Sheet holding raw marks/attendance)
└─ AnalysisSnapshot (cached computed analysis, refreshed on demand)
└─ Department
└─ Class
└─ Section
├─ Student
└─ Subject
├─ Assignment → User
├─ SheetLink
└─ AnalysisSnapshot

User
├─ Assignment
├─ ClassAccess
├─ Proctored classes
└─ AttendanceSession
```

**Why cache analysis instead of recomputing from Sheets on every page load?**
Google Sheets API has per-minute quotas (default 60 read requests/min/user).
At college scale (many teachers loading dashboards concurrently) hitting the
Sheets API on every request will throttle fast. Pattern used here:
- A "Sync now" button / cron job pulls the sheet, computes analysis, stores it
in Postgres (`AnalysisSnapshot`) with a `computedAt` timestamp.
- Dashboard pages read from the DB (fast, no quota risk) and show
"Last synced: X min ago" with a manual refresh option.
- This still satisfies "live data" — it's live on-demand, not a hardcoded
snapshot baked into the app.
A subject assignment identifies the single teacher responsible for a class/section subject. ClassAccess is separate and grants whole-class visibility. This allows multiple teachers to have access to the same class while keeping each exact class+subject assignment unique.

## Stack

- **Frontend/Backend**: Next.js 14 (App Router), TypeScript, Tailwind CSS, Recharts
- **Auth**: NextAuth.js (Credentials provider — bcrypt-hashed passwords), JWT sessions
- **Database**: PostgreSQL + Prisma ORM
- **Google Sheets access**: `googleapis` with a **service account** (share each
subject sheet with the service account's email, read-only)
- **Deployment target**: Vercel (app) + Neon/Supabase/RDS (Postgres)
- Next.js 14 / TypeScript
- Tailwind CSS / Recharts
- Supabase Auth
- Supabase PostgreSQL
- Prisma ORM
- Google Sheets API via a service account

## Authentication

## Auth & roles
Teacher and admin accounts exist in both systems for different purposes:

- `ADMIN` — college/department admin: creates classes, sections, subjects, assigns teachers
- `TEACHER` — logs in, sees only classes/subjects assigned to them
- Passwords stored as bcrypt hashes. Sessions are JWT, httpOnly cookies.
- (Recommended next step once this is running: switch admin-created accounts
to invite-based signup + SSO via your college's Google Workspace, using
NextAuth's Google provider restricted to your college domain.)
- Supabase Auth stores the actual email/password credential.
- Prisma `User` stores the ClassPulse application profile, role, college and authorization relationships.
- `User.authUserId` links the Prisma user to the corresponding Supabase Auth user.
- Password hashes are not stored in Prisma.

## Setup
To provision the current Prisma users in Supabase Auth, configure `SUPABASE_SERVICE_ROLE_KEY` and run:

```bash
cp .env.example .env # fill in DATABASE_URL, NEXTAUTH_SECRET, Google service account
npm install
npx prisma migrate dev --name init
npx prisma db seed # optional: creates a demo admin + demo class
npx prisma generate
npx prisma migrate deploy
npm run auth:sync
```

The sync utility creates missing Supabase Auth users, confirms their emails, sets the configured demo password, and links their Supabase Auth IDs back to Prisma. Set `CLASS_PULSE_DEFAULT_PASSWORD` before running it if you do not want the demo default.

## Environment

Copy `.env.example` to `.env.local` and configure:

```text
DATABASE_URL
NEXT_PUBLIC_SUPABASE_URL
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
SUPABASE_SERVICE_ROLE_KEY
NEXTAUTH_SECRET
GOOGLE_SA_EMAIL
GOOGLE_SA_PRIVATE_KEY
```

`SUPABASE_SERVICE_ROLE_KEY` is server-only and must never be exposed to client code.

## Prisma

Prisma migrations are the source of truth for the ClassPulse application schema. Run migrations with:

```bash
npx prisma migrate deploy
```

For local development:

```bash
npm run dev
```

## Google Sheets service account (needed for live sync)

1. In Google Cloud Console: create a project → enable "Google Sheets API".
2. Create a Service Account → generate a JSON key.
3. Put `client_email` and `private_key` from that JSON into `.env`
(`GOOGLE_SA_EMAIL`, `GOOGLE_SA_PRIVATE_KEY`).
4. For every subject sheet, share it (Viewer access) with the service
account's email — same as sharing with a person.
5. Store each sheet's ID (from its URL) in the `SheetLink` table when a
teacher/admin adds a subject.

## What's included in this scaffold

- Prisma schema for the full data model (multi-college, multi-department ready)
- NextAuth credentials auth with bcrypt
- Google Sheets fetch + parser (`lib/googleSheets.ts`)
- Analysis engine (`lib/analysis.ts`) — ports the sheet's logic: attendance
trend classification, KPI cards, tiering, top/bottom performer lists
- API routes for class analysis and subject analysis (read from cache, or
trigger a live resync)
- Login page + dashboard (choose Class Analysis vs Subject Analysis) +
class/subject analysis pages with charts

## What you still need to do to go to production

1. Run `npx prisma migrate dev` against a real Postgres instance.
2. Add your college's actual class/section/subject/teacher data (via a seed
script or a simple admin UI you build on top of the `Admin*` API routes).
3. Share each Google Sheet with the service account.
4. Set a strong `NEXTAUTH_SECRET`, deploy behind HTTPS (Vercel handles this).
5. Decide on a sync strategy: manual "Sync now" button (included), and/or a
scheduled job (Vercel Cron / GitHub Action) hitting `/api/analysis/sync`
every N minutes for active subjects.
6. Add row-level access control checks (included in API routes as
`assertTeacherOwnsSubject`) — extend for admin/department-head roles.
Prisma Studio:

```bash
npm run prisma:studio
```

## Google Sheets

The Google Sheets service account is used only when a ClassPulse `SheetLink` is configured for a section or subject. Share the relevant sheet with the service account email and store its sheet ID in PostgreSQL through Prisma-backed application functionality.

## Important rule

Do not add a second application database or a second password store. New teachers, classes, subjects, assignments, class access, students, attendance sessions and analysis snapshots belong in the Prisma schema/database. Authentication belongs in Supabase Auth.
1 change: 0 additions & 1 deletion app/admin/classes/page.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/admin/page.tsx

This file was deleted.

1 change: 0 additions & 1 deletion app/admin/settings/page.tsx

This file was deleted.

1 change: 0 additions & 1 deletion app/admin/teachers/page.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/auth/signout/route.ts

This file was deleted.

2 changes: 0 additions & 2 deletions app/classes/[id]/page.tsx

This file was deleted.

1 change: 0 additions & 1 deletion app/classes/[id]/students/[studentId]/page.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/classes/[id]/upload/page.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/classes/new/page.tsx

This file was deleted.

Loading