How med10s/ensaf-academia works
Project type and purpose
• This is a full-stack academic platform built with Next.js 13 (app-directory), TypeScript, Tailwind CSS, Drizzle ORM, and Supabase.
• It provides student and professor portals, an admin console (with academies, courses, user management, statistics, email-logs), and authentication flows (login, register, password reset, email verification).
File structure
• “app/” holds Next.js server- and client-side pages and layouts: public pages (/, /about, /courses, /dashboard, /profile), auth (/auth/*), and an admin namespace (/admin/*).
• “components/” contains reusable UI and layout primitives, organized by domain (Header, dashboard cards, admin tables, auth forms, providers, ui/*).
• “services/” implements business logic and data access via action functions (academy-actions, auth-actions, email-actions, etc.), split into server-only and shared.
• “lib/” and “utils/” provide low-level wrappers: Supabase clients (admin and server), Drizzle database schema and migrations, email-service, i18n, helpers.
• Config and orchestration files: middleware.ts (route-level auth guard), next.config.mjs, drizzle.config.ts, supabase/init.sql, scripts/test-db-connection.js, Tailwind and PostCSS configs.
README
• Confirms the platform’s academic scope for ENSAF students and professors.
• Mentions .env.local configuration for Supabase credentials, SMTP/email provider, and any third-party API keys.
a. Main components:
• Client (Browser): React client components, navigation, forms.
• Next.js Application Server:
• Server Components (data fetching via services)
• Client Components (UI hydration)
• Middleware (route guards, auth checks)
• API Routes or Server Actions (when invoked from the UI)
• Service Layer: services/actions/* modules containing domain logic.
• Data Layer:
• Supabase Auth & Database (PostgreSQL) accessed via Supabase SDK
• Drizzle ORM for migrations and type-safe queries
• External Services:
• Email Service (SMTP or SendGrid, wrapped in lib/email/email-service.ts)
• (Potential) Storage if using Supabase Storage for images
b. Relationships and interactions:
• Browser ↔ Next.js Server: HTTP(S) requests (page loads, form submissions, client RPC calls).
• Next.js Server → Middleware → Services: incoming requests pass through middleware for auth/session, then reach server or client components that call service functions.
• Services → Supabase SDK or Drizzle → PostgreSQL: business logic functions perform queries, mutations, and migrations.
• Services → Email Service: to send verification, password reset, notifications.
c. Architectural patterns / design principles:
• Layered architecture (Presentation → Business Logic → Data Access).
• Domain-driven modules in “services/actions”.
• Server/Client component separation offered by Next.js 13.
• Centralized state and queries via React-Query provider (components/providers/react-query-provider.tsx).
• Authentication via Supabase middleware and AuthProvider.
d. Relevant technologies:
• Next.js 13 (app dir, server components)
• React + TypeScript
• Drizzle ORM + raw SQL migrations
• Supabase SDK for Auth & Database
• Tailwind CSS + PostCSS
• React-Query, Sonner (toasts), ReCaptcha
• Node.js email library (in lib/email)
Final advice
• Be as granular as practical: group related pages under “App Pages” but call out the /admin and /auth sub-domains.
• How services map to database tables and external providers.
• Flow of authentication/session context via middleware and providers.
• Don’t omit the Drizzle/SQL migration pipeline—even if it only runs at build/deploy time, it’s a core part of the data-schema lifecycle.
• Use consistent iconography and labeling so any new engineer can trace a user’s request from the browser all the way to the database and back.