# 349gill/course-mate architecture

> Architecture diagram of the GitHub repository 349gill/course-mate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/349gill/course-mate
- Repository: https://github.com/349gill/course-mate

## Overview

##### Project Type and Overall Purpose
- Project Type: This is a full-stack web application built with Next.js. It uses both client-side rendering (React components) and server-side API routes.

##### Analyzing the File Structure
- Top-Level Files and Configurations: Files such as next.config.mjs, tailwind.config.js, postcss.config.mjs, package.json, and jsconfig.json indicate a Next.js project with customized configurations for linting, styling (Tailwind CSS), and module resolution.
- Public Directory: Contains static assets like JSON files under public/programs (general.json, honors.json, spec.json) which represent degree program configurations in terms of requirements.
- Lib Directory: Contains business logic helper functions (fetchCourses.js and fetchRequirements.js) which likely encapsulate API calls or data processing related to courses.
- Src Directory: Holds all the application code:
- Components (DegreeForm.js, RemainingCourses.js, RenderGraph.js) that build the UI for input, output, and graphical representation using GoJS.
- Pages: Custom Next.js pages including _app.js, _document.js for global setup and the index page for the homepage. Importantly, the api folder (with [course].js) defines the backend endpoint for fetching prerequisites and corequisites.
- Styles and Utils: Global styling in CSS and utility functions.

a. Main Components:
- Frontend Interface:
- UI Components: DegreeForm, RemainingCourses, RenderGraph.
- Pages: The primary pages of the application (index, _app, _document).
- Styling: Managed with Tailwind CSS and global styles.
- Backend API:
- API Routes: The [course].js endpoint that handles queries to get prerequisites and corequisites.
- Handler Functions: Likely using utilities from the lib folder (fetchCourses.js and fetchRequirements.js).
- Static Assets:
- Program Requirements: JSON files under public/programs that define different degree tracks.
- External Libraries/Integrations:
- GoJS: For rendering dynamic graphs that illustrate course prerequisites and progress.
- Next.js Framework: For both client and server-side rendering.

b. Relationships and Interactions:
- A user interacts with the frontend via the DegreeForm component to input completed courses.
- Frontend then makes a request to the backend API (located in src/pages/api/[course].js) to retrieve course dependency information.
- The API uses functions from the lib folder (fetchCourses.js, fetchRequirements.js) to process the request.
- The backend responds with the prerequisites and corequisites data, which is then used by the RemainingCourses component to compute remaining degree requirements.
- Static JSON files serve as a baseline reference for program-specific requirements.

c. Architectural Patterns/Design Principles:
- Separation of Concerns: The clear division between frontend (user interface and visualization) and backend (API for course dependency lookups) promotes scalability and maintainability.
- Modularization: Utility functions in lib and utils further decouple logic, making the application easier to test and extend.
- API-First Communication: The client fetches data through a RESTful API endpoint, emphasizing a service-oriented approach.

d. Relevant Technologies and Frameworks:
- Next.js for application structure and server-side rendering.
- React for building dynamic UI components.
- Tailwind CSS for styling.
- Node.js environment with its npm package management (package.json, package-lock.json) for backend operations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::external

    subgraph "Frontend User Interface"
        direction TB
        DF("DegreeForm"):::ui
        RC("RemainingCourses"):::ui
        RG("RenderGraph"):::ui
        subgraph "Next.js Pages"
            direction TB
            IDX("index.js"):::pages
            APP("_app.js"):::pages
            DOC("_document.js"):::pages
        end
    end

    subgraph "Backend API"
        direction TB
        API("[course].js"):::backend
        subgraph "Business Logic"
            direction TB
            FCH("fetchCourses.js"):::backend
            FRE("fetchRequirements.js"):::backend
            UTILS("utils.js"):::backend
        end
    end

    subgraph "Static Assets"
        direction TB
        GEN("general.json"):::assets
        HON("honors.json"):::assets
        SPC("spec.json"):::assets
    end

    subgraph "Styling & Config"
        direction TB
        TAILWND("tailwind.config.js"):::styling
        GLOBALS("globals.css"):::styling
        POSTCSS("postcss.config.mjs"):::styling
    end

    subgraph "External Integrations"
        direction TB
        NEXT("Next.js Framework"):::external
        T_CSS("Tailwind CSS"):::external
        GOJS("GoJS"):::external
    end

    User -->|"inputs"| DF
    DF -->|"submitRequest"| API
    API -->|"processVia"| FCH
    API -->|"processVia"| FRE
    API -->|"processVia"| UTILS
    API -->|"sendResponse"| RC
    API -->|"sendResponse"| RG
    RG -->|"visualizeWith"| GOJS
    DF ---|"reads"| GEN
    RC ---|"reads"| HON
    RC ---|"reads"| SPC
    IDX ---|"renders"| DF
    IDX ---|"renders"| RC
    IDX ---|"renders"| RG
    TAILWND -->|"styles"| DF
    GLOBALS -->|"styles"| IDX
    NEXT ---|"frameworkFor"| IDX
    NEXT ---|"frameworkFor"| API
    T_CSS ---|"styles"| TAILWND

    click DF "https://github.com/349gill/course-mate/blob/main/src/components/DegreeForm.js"
    click RC "https://github.com/349gill/course-mate/blob/main/src/components/RemainingCourses.js"
    click RG "https://github.com/349gill/course-mate/blob/main/src/components/RenderGraph.js"
    click IDX "https://github.com/349gill/course-mate/blob/main/src/pages/index.js"
    click APP "https://github.com/349gill/course-mate/blob/main/src/pages/_app.js"
    click DOC "https://github.com/349gill/course-mate/blob/main/src/pages/_document.js"
    click API "https://github.com/349gill/course-mate/blob/main/src/pages/api/[course].js"
    click FCH "https://github.com/349gill/course-mate/blob/main/lib/fetchCourses.js"
    click FRE "https://github.com/349gill/course-mate/blob/main/lib/fetchRequirements.js"
    click UTILS "https://github.com/349gill/course-mate/blob/main/src/utils/utils.js"
    click GEN "https://github.com/349gill/course-mate/blob/main/public/programs/general.json"
    click HON "https://github.com/349gill/course-mate/blob/main/public/programs/honors.json"
    click SPC "https://github.com/349gill/course-mate/blob/main/public/programs/spec.json"
    click TAILWND "https://github.com/349gill/course-mate/blob/main/tailwind.config.js"
    click GLOBALS "https://github.com/349gill/course-mate/blob/main/src/styles/globals.css"
    click POSTCSS "https://github.com/349gill/course-mate/blob/main/postcss.config.mjs"

    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef pages fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef backend fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef assets fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef styling fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
