# shadowisf/examiq architecture

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

- Interactive diagram: https://gitdiagram.com/shadowisf/examiq
- Repository: https://github.com/shadowisf/examiq

## Overview

##### Project type and purpose
- This is a full-stack, server-rendered web application built with Next.js (App Router) and React, backed by Supabase for database and authentication.
- The README and folder names (e.g., src/app, utils/supabase) confirm it’s an exam-management system (“EXAMIQ”) where users sign in, take exams, and view results via course and dashboard pages.

##### File structure
- Top-level files: next.config.ts, middleware.ts, package.json, tsconfig.json → Next.js configuration and global middleware.
- src/app/ → Next.js App Router directory containing page.tsx route handlers and nested folders for sign-in, sign-out, dashboard, course, exam, result, and shared layout/components.
- src/app/utils/supabase/ → Supabase client and server integration (client.ts, server.ts, middleware.ts).
- src/app/utils/default/ → general utilities (ID generator, date formatters, entity reader).
- Each route folder has page.tsx, actions.ts (server-action handlers), and components subfolder for UI widgets.

##### README for additional insights
- It suggests a server-side login flow (“Register and login”), implying use of Supabase Auth via middleware.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    Browser["Browser / React UI"]:::frontend
    Browser -->|"Requests & UI interactions"| Next

    %% Backend
    subgraph "Next.js Server" 
        direction TB
        subgraph "App Router (src/app)" 
            direction TB
            Layout["Root Layout"]:::backend
            Page["Root Page"]:::backend
            Layout --> Page

            subgraph "Sign-In (src/app/signin)"
                direction TB
                SignInPage["SignIn Page"]:::frontend
                SignInActions["SignIn Server Actions"]:::backend
                SignInForm["SignInForm Component"]:::frontend
                SignInPage --> SignInForm
                SignInPage --> SignInActions
            end

            subgraph "Sign-Out (src/app/signout)"
                direction TB
                SignOutPage["SignOut Page"]:::frontend
                SignOutActions["SignOut Server Actions"]:::backend
                SignOutScreen["SignOutScreen Component"]:::frontend
                SignOutPage --> SignOutScreen
                SignOutPage --> SignOutActions
            end

            subgraph "Dashboard (src/app/dashboard)"
                direction TB
                DashboardPage["Dashboard Page"]:::frontend
                DashboardActions["Dashboard Server Actions"]:::backend
                DashboardWidgets["Dashboard Widgets"]:::frontend
                DashboardPage --> DashboardWidgets
                DashboardPage --> DashboardActions
            end

            subgraph "Course Module"
                direction TB
                CourseList["Course Listing"]:::frontend
                subgraph "[id] (src/app/course/[id])"
                    direction TB
                    CoursePage["Course Page"]:::frontend
                    CourseActions["Course Server Actions"]:::backend
                    CourseComponents["Course Components"]:::frontend
                    CoursePage --> CourseComponents
                    CoursePage --> CourseActions
                end
                CourseList --> CoursePage
            end

            subgraph "Exam Module"
                direction TB
                ExamList["Exam Listing"]:::frontend
                subgraph "[id] (src/app/exam/[id])"
                    direction TB
                    ExamPage["Exam Page"]:::frontend
                    ExamActions["Exam Server Actions"]:::backend
                    ExamComponents["Exam Components"]:::frontend
                    ExamPage --> ExamComponents
                    ExamPage --> ExamActions
                end
                ExamList --> ExamPage
            end

            subgraph "Result Module"
                direction TB
                ResultList["Result Listing"]:::frontend
                subgraph "[id] (src/app/result/[id])"
                    direction TB
                    ResultPage["Result Page"]:::frontend
                    ResultActions["Result Server Actions"]:::backend
                    ResultComponents["Result Components"]:::frontend
                    ResultPage --> ResultComponents
                    ResultPage --> ResultActions
                end
                ResultList --> ResultPage
            end
        end

        subgraph "Server Actions"
            direction TB
            SignInActions
            SignOutActions
            DashboardActions
            CourseActions
            ExamActions
            ResultActions
        end

        subgraph "Middleware"
            direction TB
            GlobalMiddleware["Global Middleware"]:::backend
            SupabaseMiddleware["Supabase Auth Middleware"]:::backend
        end

        subgraph "Utilities (src/app/utils)"
            direction TB
            UtilsDefault["Default Utilities"]:::util
            UtilsSupabase["Supabase SDK"]:::util
        end

        Layout -->|uses| GlobalMiddleware
        Layout -->|calls| SupabaseMiddleware
        SignInActions -->|DB/Auth calls| UtilsSupabase
        SignOutActions -->|DB/Auth calls| UtilsSupabase
        DashboardActions -->|data ops| UtilsDefault
        CourseActions -->|data ops| UtilsDefault
        ExamActions -->|data ops| UtilsDefault
        ResultActions -->|data ops| UtilsDefault
    end

    %% External Services
    subgraph "Supabase" 
        direction TB
        Auth["Auth Service"]:::external
        Database["PostgreSQL Database"]:::external
    end

    Next -->|Auth checks| Auth
    Next -->|Data queries| Database

    %% Static Assets
    subgraph "Static Host"
        direction TB
        PublicIcons["Icons"]:::static
        PublicImages["Images"]:::static
        MainStyles["Global Styles & Manifest"]:::static
    end

    Browser -->|loads static| PublicIcons
    Browser -->|loads static| PublicImages
    Browser -->|loads styles| MainStyles

    %% Click events
    click Layout "https://github.com/shadowisf/examiq/blob/main/src/app/layout.tsx"
    click Page "https://github.com/shadowisf/examiq/blob/main/src/app/page.tsx"
    click GlobalMiddleware "https://github.com/shadowisf/examiq/blob/main/middleware.ts"
    click SupabaseMiddleware "https://github.com/shadowisf/examiq/blob/main/src/app/utils/supabase/middleware.ts"
    click UtilsSupabase "https://github.com/shadowisf/examiq/blob/main/src/app/utils/supabase/client.ts"
    click UtilsSupabase "https://github.com/shadowisf/examiq/blob/main/src/app/utils/supabase/server.ts"
    click UtilsDefault "https://github.com/shadowisf/examiq/blob/main/src/app/utils/default/generateID.ts"
    click UtilsDefault "https://github.com/shadowisf/examiq/blob/main/src/app/utils/default/formatDateTimeLocal.ts"
    click UtilsDefault "https://github.com/shadowisf/examiq/blob/main/src/app/utils/default/formatDateTimeUTC.ts"
    click UtilsDefault "https://github.com/shadowisf/examiq/blob/main/src/app/utils/default/readEntities.ts"
    click PublicIcons "https://github.com/shadowisf/examiq/tree/main/public/icons"
    click PublicImages "https://github.com/shadowisf/examiq/tree/main/public/images"
    click MainStyles "https://github.com/shadowisf/examiq/blob/main/src/app/main.scss"
    click MainStyles "https://github.com/shadowisf/examiq/blob/main/src/app/manifest.json"
    click SignInForm "https://github.com/shadowisf/examiq/blob/main/src/app/signin/components/SignInForm.tsx"
    click SignInActions "https://github.com/shadowisf/examiq/blob/main/src/app/signin/actions.ts"
    click SignInPage "https://github.com/shadowisf/examiq/blob/main/src/app/signin/page.tsx"
    click SignOutScreen "https://github.com/shadowisf/examiq/blob/main/src/app/signout/components/SignOutScreen.tsx"
    click SignOutActions "https://github.com/shadowisf/examiq/blob/main/src/app/signout/actions.ts"
    click SignOutPage "https://github.com/shadowisf/examiq/blob/main/src/app/signout/page.tsx"
    click DashboardPage "https://github.com/shadowisf/examiq/blob/main/src/app/dashboard/page.tsx"
    click DashboardActions "https://github.com/shadowisf/examiq/blob/main/src/app/dashboard/actions.ts"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,color:#006064
    classDef backend fill:#e8f5e9,stroke:#2e7d32,color:#2e7d32
    classDef external fill:#fff3e0,stroke:#ef6c00,color:#e65100
    classDef util fill:#fff9c4,stroke:#f9a825,color:#f57f17
    classDef static fill:#e1bee7,stroke:#6a1b9a,color:#4a148c
```
