How nahiddhasan/school-app works
Project Type and Purpose
• This is a full-stack Next.js (React) application with:
• A public-facing “school-front” website for notices & general info
• An authenticated “dashboard” area for student admission, result import, reports, settings, etc.
• A headless API layer (Next.js API routes)
• Persistent storage via Prisma and a relational database
• Authentication/session management via NextAuth
Top-Level Components
A. Client (Browser) – React pages & components
B. Next.js Server
1. Page Rendering (SSR/SSG)
2. API Layer (src/app/api/[...nextauth], any other API routes)
3. Middleware
4. Data-access & Business Logic (src/lib, Prisma client)
C. Database – e.g. PostgreSQL (Prisma schema + migrations)
D. Authentication Service – NextAuth (JWT/Session store)
E. File Storage – public/upload (PDFs, CSVs)
F. External Infrastructure – Docker Compose (for local dev), Vercel (for prod)
Relationships & Data Flows
• Browser ↔ Next.js Pages
• User requests pages (public or dashboard) → Next.js handles SSR/SSG or serves client bundle
• Client components fetch data via built-in React server components or call API routes
• Browser → API Routes
• Dashboard UI calls Next.js API endpoints (e.g. for student import, result import, CRUD operations)
• Next.js Server → Database
• Business logic in src/lib uses Prisma Client to read/write data
• Prisma migrations define schema under prisma/
• Next.js Server → NextAuth
• Calls NextAuth route under src/app/api/[...nextauth]
• Session data stored in DB or via JWT, injected via SessionProvider
• Next.js Server → File Storage
• Student/Result import uploads CSV into public/assets or public/upload
• PDF exports saved to public/upload for retrieval
• Local Developer Machine ↔ Docker Compose (PostgreSQL container)
Architectural Patterns & Design Principles
• Separation of concerns:
• UI layer (React components & pages in src/app & src/components)
• API layer (Next.js API routes + src/lib/actions)
• Data layer (Prisma ORM + schema + migrations)
• Server Components vs. Client Components in Next.js 13 app router
• Protected routes: middleware enforces auth before reaching dashboard pages
• Use of providers (SessionProvider, ThemeProvider) to supply context
• Standard CRUD and bulk-import patterns (Forms, DataTables, file uploads)
Diagramming Conventions
• Rectangles for components (UI, API, DB)
• Annotations: note key technologies (Next.js 13, React, Prisma, NextAuth, Tailwind CSS) next to each relevant component