# luminousyinyang/cop4331-small-project architecture

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

- Interactive diagram: https://gitdiagram.com/luminousyinyang/cop4331-small-project
- Repository: https://github.com/luminousyinyang/cop4331-small-project

## Overview

##### Main Components
- API/Backend: Represented by the API directory containing create.php, delete.php, login.php, retrieve.php, signup.php, and update.php. These scripts form the backend endpoints that handle business logic for contact management and user sessions.
- Frontend Client: Shown in the public folder with home.html and index.html, along with associated JavaScript and CSS files. The public/js folder contains page-specific scripts (home.js, index.js, modal.js) that likely handle user interactions and Ajax requests.
- Additional JavaScript Libraries: The separate js directory (with code.js and md5.js) may house common functions or utilities (e.g., md5.js for password hashing before transmission) used across the frontend or API calls.

##### Relationships and Interactions
- The common JavaScript utilities (from the js folder) support the frontend operations and possibly pre-process data (e.g., using md5 to hash passwords before calling API/login.php). Show this as a separate module or library that supports the Frontend Client.

##### Architectural Patterns and Design Principles
- Even though not formally implemented, note the use of separation of concerns: the API (backend logic) is kept separate from the presentation layer (frontend HTML/CSS/JS).
- That the frontend is built to be dynamic (based on JavaScript interactions) and makes use of common libraries for utility functions.

##### Relevant Technologies, Frameworks, or Libraries
- Technologies:
- PHP is used for server-side processing in the API.
- HTML, CSS, and JavaScript for the frontend.
- md5.js is likely used for password hashing or data integrity checks.

- The Frontend Client (HTML pages and associated JavaScript/CSS)
- The API Server (listing out individual endpoints)
- Shared JavaScript Utilities (common libraries like md5.js)
- The Database (even if implicit, to represent persistent storage)
- Data flow from the Frontend to specific API endpoints
- Communication between API endpoints and the Database
- The support role of the utility scripts to the frontend operations
- Visual distinctions:

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Client (HTML/CSS/JS)"
        subgraph "HTML & Styles"
            homeHTML["home.html"]:::frontend
            indexHTML["index.html"]:::frontend
            homeCSS["home.css"]:::frontend
            indexCSS["index.css"]:::frontend
        end
        subgraph "Frontend JavaScript"
            homeJS["home.js"]:::frontend
            indexJS["index.js"]:::frontend
            modalJS["modal.js"]:::frontend
        end
    end

    subgraph "API Endpoints (PHP)"
        createPHP["create.php"]:::backend
        deletePHP["delete.php"]:::backend
        loginPHP["login.php"]:::backend
        retrievePHP["retrieve.php"]:::backend
        signupPHP["signup.php"]:::backend
        updatePHP["update.php"]:::backend
    end

    subgraph "Shared JS Utilities"
        codeJS["code.js"]:::utility
        md5JS["md5.js"]:::utility
    end

    DB["Database"]:::database

    %% AJAX calls from Frontend JavaScript to API Endpoints
    homeJS -->|"AJAX-login"| loginPHP
    homeJS -->|"AJAX-signup"| signupPHP
    indexJS -->|"AJAX-retrieve"| retrievePHP
    indexJS -->|"AJAX-create"| createPHP
    indexJS -->|"AJAX-delete"| deletePHP
    modalJS -->|"AJAX-update"| updatePHP

    %% API Endpoints interacting with the Database
    createPHP -->|"DB-query"| DB
    deletePHP -->|"DB-query"| DB
    loginPHP -->|"DB-query"| DB
    retrievePHP -->|"DB-query"| DB
    signupPHP -->|"DB-query"| DB
    updatePHP -->|"DB-query"| DB

    %% Shared JS Utilities supporting Frontend JavaScript
    codeJS -->|"utility"| homeJS
    codeJS -->|"utility"| indexJS
    codeJS -->|"utility"| modalJS
    md5JS -->|"hashing"| homeJS
    md5JS -->|"hashing"| indexJS
    md5JS -->|"hashing"| modalJS

    %% UI Loading relationships
    homeHTML -->|"loads"| homeJS
    indexHTML -->|"loads"| indexJS

    %% Click Events
    click createPHP "https://github.com/luminousyinyang/cop4331-small-project/blob/main/API/create.php"
    click deletePHP "https://github.com/luminousyinyang/cop4331-small-project/blob/main/API/delete.php"
    click loginPHP "https://github.com/luminousyinyang/cop4331-small-project/blob/main/API/login.php"
    click retrievePHP "https://github.com/luminousyinyang/cop4331-small-project/blob/main/API/retrieve.php"
    click signupPHP "https://github.com/luminousyinyang/cop4331-small-project/blob/main/API/signup.php"
    click updatePHP "https://github.com/luminousyinyang/cop4331-small-project/blob/main/API/update.php"
    click homeHTML "https://github.com/luminousyinyang/cop4331-small-project/blob/main/public/home.html"
    click indexHTML "https://github.com/luminousyinyang/cop4331-small-project/blob/main/public/index.html"
    click homeCSS "https://github.com/luminousyinyang/cop4331-small-project/blob/main/public/styles/home.css"
    click indexCSS "https://github.com/luminousyinyang/cop4331-small-project/blob/main/public/styles/index.css"
    click homeJS "https://github.com/luminousyinyang/cop4331-small-project/blob/main/public/js/home.js"
    click indexJS "https://github.com/luminousyinyang/cop4331-small-project/blob/main/public/js/index.js"
    click modalJS "https://github.com/luminousyinyang/cop4331-small-project/blob/main/public/js/modal.js"
    click codeJS "https://github.com/luminousyinyang/cop4331-small-project/blob/main/js/code.js"
    click md5JS "https://github.com/luminousyinyang/cop4331-small-project/blob/main/js/md5.js"

    %% Style definitions
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#F08080,stroke:#000,stroke-width:2px;
    classDef utility fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
