# dogukantopcu/iyte-gms architecture

> Architecture diagram of the GitHub repository dogukantopcu/iyte-gms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dogukantopcu/iyte-gms
- Repository: https://github.com/dogukantopcu/iyte-gms

## Overview

##### Project Type and Purpose
- Full-stack web application for managing graduation processes (student records, transcripts, advisors, ceremonies).
- Built on Next.js with server-side rendering, REST API routes, Prisma ORM, and a PostgreSQL database.
- Integrates with UBYS (university back-office) via REST endpoints.

##### File Structure
- app/… – Next.js “app router” pages & layout components (login, student dashboard, advisor dashboard, student-affairs admin).
- app/api/… – Serverless REST API routes (auth, init, student, ubys/*).
- _components/ & app/(app)/_components – Shared React UI components (tables, cards, buttons, sidebar).
- lib/prisma.ts – Prisma client instantiation.
- prisma/schema.prisma & prisma/migrations – Database schema and migration history.
- context/AuthContext.tsx & middleware.ts – Authentication context and route protection.
- public/ – Static assets (logos, images).
- next.config.js, tailwind.config.js – Framework and styling configurations.

##### README for Additional Insights
- Tech stack: Next.js, Tailwind CSS, Prisma ORM, Neon PostgreSQL, Vercel hosting.
- UBYS API endpoints defined under /api/ubys.
- Authentication via JWT (see prisma migration for jwt_table).

##### Main Components & Relationships

A. Presentation Layer (Client Browser / React UI)
– Next.js pages (Login, Student Dashboard, Advisor Dashboard, Student Affairs Dashboard)
– React components (AdvisorInfoCard, StudentsTable, TranscriptCard, Sidebar, etc.)
– AuthContext – manages user session & injects JWT into requests

B. Application Layer (Next.js Server & API)
– Next.js server runtime handling page rendering & API routes
– API Routes:
- /api/auth – login, JWT issuance
- /api/init/* – seed and initialization endpoints (createInstitutions, admins, students, etc.)
- /api/student/* – internal student creation & existence checks
- /api/ubys/* – proxy/endpoints fetching data from the external UBYS system (admins, advisors, students, transcripts, outlierstudents)

C. Data Layer
– Prisma ORM (lib/prisma.ts)
– Neon PostgreSQL database
- Tables: users (admins, advisors, students), departments, faculties, units, transcripts, jwt_tokens

D. External Services
– UBYS external REST API (institution’s back-office system)

E. Deployment & Hosting
– Vercel (Next.js serverless functions, static asset hosting)

1. Client → Next.js Pages (HTTP/HTTPS)
2. Next.js Pages → API Routes (fetch/axios calls)
3. API Routes → Prisma Client → PostgreSQL (CRUD operations)
4. API Routes (/api/ubys) → External UBYS REST endpoints → API routes → Prisma (caching or mapping)
5. Authentication flow:
- LoginForm → /api/auth → JWT created & stored in jwt_table → JWT stored in client cookie → AuthContext reads JWT → authorizes page access

##### Architectural Patterns & Principles
- Folder-based routing (Next.js App Router) separating pages and API.
- React Context for cross-cutting concerns (authentication).
- Single ORM layer (Prisma) abstracting database schema & queries.
- RESTful API design for internal and external integrations.
- Serverless functions (API routes) isolating business logic.

##### Elements
- Data flow direction.
- Annotations for key technologies (Next.js, Tailwind, Prisma, PostgreSQL).
- Authentication flow (AuthContext, JWT, middleware).

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Presentation Layer
  subgraph "Presentation Layer" 
    direction TB
    Login["Login Page"]:::frontend
    StudentDash["Student Dashboard"]:::frontend
    TranscriptPage["Student Transcript Page"]:::frontend
    AdvisorDash["Advisor Dashboard"]:::frontend
    CeremonyList["Ceremony List Page"]:::frontend
    SystemMgmt["System Management Page"]:::frontend
    UIShared["Shared UI Components"]:::frontend
    AppUI["App-Scoped UI Components"]:::frontend
    SidebarItems["Sidebar Item Variants"]:::frontend
    LoginComponents["Login Form Components"]:::frontend
    AuthContext["AuthContext"]:::frontend
    Middleware["Route Protection Middleware"]:::frontend
  end

  %% Application Layer
  subgraph "Application Layer (Next.js Server & API Routes)"
    direction TB
    AuthAPI["/api/auth"]:::application
    subgraph "Initialization APIs"
      CI["createInstitutions"]:::application
      AdminInit["administrators"]:::application
      AdvisorsInit["advisors"]:::application
      DepartmentsInit["departments"]:::application
      FacultiesInit["faculties"]:::application
      UnitsInit["units"]:::application
      StudentsInit["students"]:::application
    end
    subgraph "Student APIs"
      AddStudent["addStudent"]:::application
      CheckStudent["isExists"]:::application
    end
    subgraph "UBYS Proxy APIs"
      SharedUtils["/api/ubys/_shared"]:::application
      UBYSAdmins["admins"]:::application
      UBYSAdvisors["advisors"]:::application
      UBYSStudents["students"]:::application
      UBYSTrans["transcripts"]:::application
      UBYSOutliers["outlierstudents"]:::application
      FetchInst["fetchInstitutions"]:::application
      FetchAdmins["fetchAdmins"]:::application
    end
  end

  %% Data Layer
  subgraph "Data Layer"
    direction TB
    PrismaClient["Prisma Client"]:::data
    Schema["schema.prisma"]:::data
    Migrations["migrations"]:::data
    SeedScript["Seed Script"]:::data
    Postgres[(Neon PostgreSQL)]:::data
  end

  %% External Services
  UBYS["UBYS External API"]:::external

  %% Deployment & Config
  subgraph "Deployment & Configuration"
    direction TB
    NextConfig["next.config.js"]:::config
    TailwindConfig["tailwind.config.js"]:::config
    GlobalStyles["globals.css"]:::config
    TSConfig["tsconfig.json"]:::config
    StaticAssets["Static Assets"]:::config
  end

  %% Data Flows
  Login -->|"HTTP"| AuthAPI
  StudentDash -->|"HTTP"| AddStudent
  StudentDash -->|"HTTP"| CheckStudent
  TranscriptPage -->|"HTTP"| UBYSTrans
  AdvisorDash -->|"HTTP"| UBYSOutliers
  CeremonyList -->|"HTTP"| StudentsInit
  SystemMgmt -->|"HTTP"| CI
  UIShared --- UIShared
  AppUI --- AppUI
  SidebarItems --- SidebarItems
  LoginComponents --- LoginComponents

  AuthAPI -->|"CRUD"| PrismaClient
  AddStudent -->|"CRUD"| PrismaClient
  CheckStudent -->|"CRUD"| PrismaClient
  CI -->|"CRUD"| PrismaClient
  AdminInit -->|"CRUD"| PrismaClient
  AdvisorsInit -->|"CRUD"| PrismaClient
  DepartmentsInit -->|"CRUD"| PrismaClient
  FacultiesInit -->|"CRUD"| PrismaClient
  UnitsInit -->|"CRUD"| PrismaClient
  StudentsInit -->|"CRUD"| PrismaClient

  SharedUtils -->|"proxy"| UBYSAdmins
  UBYSAdmins -->|"proxy"| UBYS
  UBYSAdvisors -->|"proxy"| UBYS
  UBYSStudents -->|"proxy"| UBYS
  UBYSTrans -->|"proxy"| UBYS
  UBYSOutliers -->|"proxy"| UBYS
  FetchInst -->|"proxy"| UBYS
  FetchAdmins -->|"proxy"| UBYS

  PrismaClient -->|"SQL"| Postgres

  %% Click Events
  click Login "https://github.com/dogukantopcu/iyte-gms/blob/master/app/login/page.tsx"
  click StudentDash "https://github.com/dogukantopcu/iyte-gms/blob/master/app/(app)/student/page.tsx"
  click TranscriptPage "https://github.com/dogukantopcu/iyte-gms/blob/master/app/(app)/student/transcript/page.tsx"
  click AdvisorDash "https://github.com/dogukantopcu/iyte-gms/blob/master/app/(app)/advisor/add-outlier/page.tsx"
  click CeremonyList "https://github.com/dogukantopcu/iyte-gms/blob/master/app/(app)/student-affairs/ceremony-list/page.tsx"
  click SystemMgmt "https://github.com/dogukantopcu/iyte-gms/blob/master/app/(app)/student-affairs/system-management/page.tsx"
  click UIShared "https://github.com/dogukantopcu/iyte-gms/tree/master/_components/"
  click AppUI "https://github.com/dogukantopcu/iyte-gms/tree/master/app/(app)/_components/"
  click SidebarItems "https://github.com/dogukantopcu/iyte-gms/tree/master/app/(app)/_components/sidebar_items/"
  click LoginComponents "https://github.com/dogukantopcu/iyte-gms/tree/master/app/login/_components/"
  click AuthContext "https://github.com/dogukantopcu/iyte-gms/blob/master/app/context/AuthContext.tsx"
  click Middleware "https://github.com/dogukantopcu/iyte-gms/blob/master/app/middleware.ts"
  click AuthAPI "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/auth/route.ts"
  click CI "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/init/createInstitutions/route.ts"
  click AdminInit "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/init/administrators/route.ts"
  click AdvisorsInit "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/init/advisors/route.ts"
  click DepartmentsInit "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/init/departments/route.ts"
  click FacultiesInit "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/init/faculties/route.ts"
  click UnitsInit "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/init/units/route.ts"
  click StudentsInit "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/init/students/route.ts"
  click AddStudent "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/student/addStudent/route.ts"
  click CheckStudent "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/student/isExists/route.ts"
  click SharedUtils "https://github.com/dogukantopcu/iyte-gms/tree/master/app/api/ubys/_shared/"
  click UBYSAdmins "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/ubys/admins/route.ts"
  click UBYSAdvisors "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/ubys/advisors/route.ts"
  click UBYSStudents "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/ubys/students/route.ts"
  click UBYSTrans "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/ubys/transcripts/route.ts"
  click UBYSOutliers "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/ubys/outlierstudents/route.ts"
  click FetchInst "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/ubys/init/fetchInstitutions/route.ts"
  click FetchAdmins "https://github.com/dogukantopcu/iyte-gms/blob/master/app/api/ubys/init/fetchAdmins/route.ts"
  click PrismaClient "https://github.com/dogukantopcu/iyte-gms/blob/master/lib/prisma.ts"
  click Schema "https://github.com/dogukantopcu/iyte-gms/blob/master/prisma/schema.prisma"
  click Migrations "https://github.com/dogukantopcu/iyte-gms/tree/master/prisma/migrations/"
  click SeedScript "https://github.com/dogukantopcu/iyte-gms/blob/master/prisma/seed.ts"
  click NextConfig "https://github.com/dogukantopcu/iyte-gms/blob/master/next.config.js"
  click TailwindConfig "https://github.com/dogukantopcu/iyte-gms/blob/master/tailwind.config.js"
  click GlobalStyles "https://github.com/dogukantopcu/iyte-gms/blob/master/app/globals.css"
  click TSConfig "https://github.com/dogukantopcu/iyte-gms/blob/master/tsconfig.json"
  click StaticAssets "https://github.com/dogukantopcu/iyte-gms/tree/master/public/images/"

  %% Styles
  classDef frontend fill:#bbdefb,stroke:#333,stroke-width:1px
  classDef application fill:#c8e6c9,stroke:#333,stroke-width:1px
  classDef data fill:#ffe0b2,stroke:#333,stroke-width:1px
  classDef external fill:#e1bee7,stroke:#333,stroke-width:1px
  classDef config fill:#eeeeee,stroke:#333,stroke-width:1px
```
