How dewanshakib/uu-unifile-v1 works
1. Overall shape
- This is a Next.js 16 App Router application with three clear surfaces:
- Public browsing for files and Google Classroom metadata
- Auth flows for sign-in/sign-up/password reset
- Protected dashboard for admin management
2. Route organization
- The app/ tree is the main composition boundary.
- Route groups split the app into:
- app/(auth) for authentication pages
- app/(private) for the role-protected dashboard
- Public content lives outside those groups in app/files and app/google-classrooms.
3. Core data hierarchy
- The entire browsing model is built around an academic path:
- year → semester (semister in routes) → section
- From there it branches into:
- category → files
- subject → classroom files
- This hierarchy is the main data-shaping boundary for both public browsing and admin entry forms.
4. Two domain tracks
- There are two content domains with similar navigation patterns:
- Files: categorized academic resources
- Google Classrooms: course/classroom entries tied to subjects
- Both share the same academic filters, but diverge at the final entity level (category vs subject).
5. Authentication subsystem
- Auth is handled by Better Auth through app/api/auth/[...all]/route.ts.
- Client/server auth setup is split between lib/auth-client.ts and lib/auth.ts.
- Auth pages in components/auth/* back the sign-in, sign-up, and password reset flows.
- Session cookies are part of the auth boundary, and the app uses roles from the user record.
6. Authorization and protected access
- app/(private)/dashboard/layout.tsx is the key server-side guard for admin areas.
- The dashboard redirects:
- unauthenticated users to /sign-in
- non-admin users back to /
- Role access is hierarchical:
- ADMIN can manage files and Google Classrooms
- SUPER_ADMIN can additionally manage categories and subjects
7. Admin management flow
- Dashboard pages under app/(private)/dashboard/* are thin route shells.
- Most CRUD UI is in components/sections/dashboard/*.
- actions/*.ts contains server actions for create/update operations across:
- files
- categories
- subjects
- Google Classroom entries
- This keeps the route layer separate from mutation logic and form UI.
8. Public browsing flow
- Public pages under app/files/* and app/google-classrooms/* progressively narrow the dataset by URL params.
- The navigation is hierarchical rather than search-based: each page refines the academic scope until the final list page.
- The leaf pages are where the actual resource lists are rendered.
9. Database and schema layer
- Persistence is PostgreSQL via Drizzle ORM.
- The DB boundary is centralized in:
- drizzle/db.ts
- drizzle/schema.ts
- drizzle/migrations/*
- The schema includes auth tables (user, session, account, verification) plus domain tables for files, categories, subjects, and Google Classrooms.
- The README indicates the app is designed for Supabase-compatible Postgres.
10. Password reset and email
- Password reset is implemented as a separate auth flow and sends mail through Nodemailer with Gmail SMTP.
- lib/send-mail.ts and the reset-password auth components form the mail flow boundary.
- The reset redirect depends on the public Better Auth URL env vars.
11. Operational endpoint
- app/api/cron/keep-alive/route.ts is a small operational API used to keep the database warm.
- It is protected by CRON_SECRET and performs a simple DB ping (SELECT 1).
- vercel.json schedules this endpoint, so deployment/runtime concerns are part of the architecture.
12. Shared UI layer
- components/ui/* is the reusable design-system layer built from shadcn/Radix-style primitives.
- components/layout/*, components/nav-main.tsx, and components/app-sidebar.tsx provide the global shell.
- Feature-specific pages compose these primitives rather than owning low-level UI themselves.
13. Important repo-specific note
- The codebase intentionally uses the spelling semister in route paths and folder names.
- Google Classroom route nesting has some hard-coded intermediate segments in one path, but the deeper pages still resolve dynamic params from the URL.
14. Architecture summary for a diagram
- Think of the repo as four main layers:
- Presentation: App Router pages + reusable UI components
- Business/UI workflows: dashboard section components and forms
- Mutation/data access: server actions + Drizzle schema/DB client
- Platform services: Better Auth, PostgreSQL, Gmail SMTP, and scheduled cron keep-alive
Main entry points: sections/dashboard Admin Sections · app App Router · (private)/dashboard Dashboard · schema.ts Schema
Components 22
Presentation
Next.js App Router pages and shared UI shell
- App Router · Root app shell and top-level routing
app - Files Browse · Hierarchical public browsing for academic files
app/files - Classrooms Browse · Hierarchical public browsing for classroom resources
app/google-classrooms - Auth Pages · Sign-in, sign-up, and password reset pages
app/(auth) - Dashboard · Admin area guarded by role checks
app/(private)/dashboard - Guard Layout · Redirects unauthenticated and non-admin users
app/(private)/dashboard/layout.tsx - Dashboard Shell · Dashboard landing and shared admin navigation
components/layout/dashboard-wrapper.tsx - UI Kit · Reusable primitives and global layout pieces
components/ui - Auth UI · Sign-in, sign-up, sign-out, and reset forms
components/auth
Workflows
Dashboard section components and forms
- Admin Sections · CRUD screens for files, categories, subjects, and classrooms
components/sections/dashboard - File Admin · List and edit flows for files
components/sections/dashboard/file - Category Admin · Admin UI for category management
components/sections/dashboard/category - Subject Admin · Admin UI for subject management
components/sections/dashboard/subject - Classroom Admin · Admin UI for Google Classroom entries
components/sections/dashboard/goolgeClassroom
Data & Auth
Server actions, auth setup, and database schema
- Server Actions · Create and update operations for domain entities
actions - Auth Setup · Server and client auth configuration
lib/auth.ts - Auth Client · Client-side auth helper
lib/auth-client.ts - Database · Central PostgreSQL connection and schema access
drizzle/db.ts - Schema · Auth and domain tables for files, categories, subjects, and classrooms
drizzle/schema.ts
Platform
External services and operational endpoints
- Auth API · Better Auth catch-all API handler
app/api/auth/[...all]/route.ts - Mail Sender · Gmail SMTP password reset delivery
lib/send-mail.ts - Keep-Alive · Protected DB ping endpoint for deployment warmup
app/api/cron/keep-alive/route.ts
Connections 23
- App Router → Files Browse: routes · App Router exposes the public files browsing tree
- App Router → Classrooms Browse: routes · App Router exposes the public classroom browsing tree
- App Router → Auth Pages: routes · App Router exposes authentication pages
- App Router → Dashboard: routes · App Router exposes protected dashboard routes
- Dashboard → Guard Layout: guards · Layout enforces session and role access
- Dashboard → Dashboard Shell: uses · Dashboard routes render through the shared shell
- App Router → UI Kit: composes · App-wide pages share reusable UI primitives
- Auth Pages → Auth UI: renders · Auth pages are backed by dedicated auth forms
- Dashboard → Admin Sections: renders · Route shells delegate CRUD screens to section components
- Admin Sections → File Admin: includes · Files management UI
- Admin Sections → Category Admin: includes · Category management UI
- Admin Sections → Subject Admin: includes · Subject management UI
- Admin Sections → Classroom Admin: includes · Google Classroom management UI
- Admin Sections → Server Actions: mutates via · Admin forms call server actions for CRUD changes
- Files Browse → Schema: filters by · Academic browsing narrows by year, semister, section, category, and files data
- Classrooms Browse → Schema: filters by · Academic browsing narrows by year, semister, section, subject, and classroom files data
- Server Actions → Database: writes · Server actions persist through the database layer
- Auth API → Auth Setup: configures · Auth API is driven by shared Better Auth setup
- Auth Setup → Auth Client: pairs with · Server and client auth helpers form one boundary
- Auth Setup → Schema: uses · Auth depends on user and session tables
- Schema → Database: loads · Database client operates over the application schema
- Mail Sender → Auth Pages: supports · Password reset flow sends email from auth pages
- Keep-Alive → Database: pings · Keep-alive endpoint runs a simple database check