# chawinkn/quaso-grader architecture

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

- Interactive diagram: https://gitdiagram.com/chawinkn/quaso-grader
- Repository: https://github.com/chawinkn/quaso-grader

## Overview

##### Main Components
- Frontend (User Interface): The bulk of the UI is built in the “src/app” directory. This includes user pages (login, registration, profile, dashboard, scoreboard, submissions, etc.) and admin pages (accessible under the dashboard and in dedicated “components/admin” directories).
- API Endpoints: The “src/app/api” directory organizes serverless functions by domain (e.g., announcements, auth, groups, tasks, submissions, score, etc.). These endpoints act as the backend for the application and handle REST/HTTP requests.
- Authentication Module: Integrated via NextAuth.js and implemented in “src/app/api/auth/[...nextauth]”, this module manages user sessions albeit with a note in the README regarding credential session issues.
- Database Layer: The “prisma” directory contains the Prisma schema, migrations, and a seed script. PostgreSQL is used as the production database and is accessed using the Prisma ORM (with utility functions in “src/lib/prisma.ts”).
- Shared Libraries/Utils: Small utility files, such as those in “src/lib” and “src/utils”, support business logic, session management, validation (using zod), and similar tasks.
- Docker & Deployment: Files like Dockerfile, docker-compose.yml, and .env.example highlight how the app is containerized for easier deployment and consistent environment configuration.

##### Relationships and Interactions
- The Frontend communicates with the API endpoints provided under “src/app/api”. Data flows bidirectionally via HTTP requests/responses.
- The API endpoints use Prisma as the ORM to interact with a PostgreSQL database. Indicate that the API layer acts as the middleman between the UI and the database.
- NextAuth.js provides authentication by intercepting requests via dedicated API routes and middleware, thus linking user sessions with the database.
- Docker containerization means that the application (possibly including both frontend server and the database) runs in isolated environments which can be depicted as individual containers communicating over defined networks.
- The “components” and “layout” directories in “src” provide reusable UI elements and layouts, reinforcing that the presentation layer is component-driven.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear delineation exists between UI (presentation), API (business logic), and database (data persistence).
- Containerization: Docker files promote a micro-environment approach where local development mimics production setup.

##### Technologies and Frameworks
- Next.js & React for the UI.
- NextAuth.js for authentication.
- TailwindCSS and shadcn/ui for styling and component structure.
- Prisma as the ORM with PostgreSQL as the underlying database.
- Docker for containerization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        A["Frontend UI (Next.js & React)"]:::frontend
        B["Admin & Reusable UI Components"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        C["API Endpoints (Serverless Functions)"]:::api
        D["Authentication Module (NextAuth.js)"]:::auth
        E["Auth Route (route.ts)"]:::auth
        H["Shared Libraries/Utils"]:::utils
    end

    %% Database Layer
    subgraph "Database Layer"
        F["Database (PostgreSQL via Prisma)"]:::database
        G["Prisma ORM Connector"]:::database
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        I1["Dockerfile"]:::infra
        I2["docker-compose.yml"]:::infra
        I3[".env.example"]:::infra
    end

    %% Connections between Layers
    A -->|"HTTP_request"| C
    B -->|"Enhances_UI"| A
    A -->|"Auth_request"| D
    D -->|"Session_verify"| F
    C -->|"DB_access"| F
    C -->|"ORM_calls"| G
    H ---|"Supports"| C
    H ---|"Supports"| A

    %% Infrastructure links (dotted lines represent containerized environments)
    I1 ---|"Containerizes"| A
    I1 ---|"Containerizes"| C
    I1 ---|"Containerizes"| F
    I2 ---|"Orchestrates"| A
    I2 ---|"Orchestrates"| C
    I2 ---|"Orchestrates"| F
    I3 ---|"Configures"| A
    I3 ---|"Configures"| C
    I3 ---|"Configures"| F

    %% Click Events
    click A "https://github.com/chawinkn/quaso-grader/tree/master/src/app"
    click B "https://github.com/chawinkn/quaso-grader/tree/master/src/components"
    click C "https://github.com/chawinkn/quaso-grader/tree/master/src/app/api"
    click D "https://github.com/chawinkn/quaso-grader/blob/master/src/app/api/auth/[...nextauth]"
    click E "https://github.com/chawinkn/quaso-grader/blob/master/src/app/api/auth/route.ts"
    click F "https://github.com/chawinkn/quaso-grader/tree/master/prisma"
    click G "https://github.com/chawinkn/quaso-grader/blob/master/src/lib/prisma.ts"
    click H "https://github.com/chawinkn/quaso-grader/tree/master/src/lib"
    click I1 "https://github.com/chawinkn/quaso-grader/tree/master/Dockerfile"
    click I2 "https://github.com/chawinkn/quaso-grader/blob/master/docker-compose.yml"
    click I3 "https://github.com/chawinkn/quaso-grader/blob/master/.env.example"

    %% Styling
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef api fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef auth fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef database fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef utils fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef infra fill:#FFA500,stroke:#000,stroke-width:2px;
```
