# danielho-bs/anonymousmessage architecture

> Architecture diagram of the GitHub repository danielho-bs/anonymousmessage, 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/danielho-bs/anonymousmessage
- Repository: https://github.com/danielho-bs/anonymousmessage

## Overview

##### Main Components
- Client/User Interface – represented by the two HTML files:
- Index.html: Provides the interface where users can post their messages.
- View.html: Displays the existing messages.
- Server-side Logic – represented by Code.gs:
- This script acts as the backend that processes user requests, interacts with the Google Sheets “database,” and serves the appropriate HTML content.
- Data Storage – Google Sheets:
- The project leverages a Google Spreadsheet (with a defined structure, e.g., ‘Timestamp’, ‘Name’, and ‘Message’) as the data store for submitted messages.
- External Platform – Google Apps Script Environment:
- The deployment and execution environment that ties together the HTML front-end and the Google Sheets back-end (accessed via the GAS platform’s built-in services).

##### Out the Relationships and Data Flow
- User Interaction:
- A user interacts via a web browser and accesses the web app.
- From the browser, the user sees either the message posting screen (Index.html) or the view page (View.html).
- Communication with Server:
- The HTML pages communicate with Code.gs, which contains the server-side logic.
- Code.gs processes incoming HTTP requests, retrieves or submits data, and then returns responses that update the UI.
- Data Management:
- Code.gs accesses the Google Sheets API (via the built-in Apps Script services) to read/write messages.
- Any changes in the spreadsheet are reflected on the message view page.

##### Architectural Patterns and Design Principles
- Layer Separation:
- Although the application is small, it clearly separates client-side presentation (HTML files) from server-side business logic (Code.gs).
- Serverless and Managed Infrastructure:
- By using Google Apps Script, the project benefits from a managed serverless environment.
- Simple MVC-Like Flow:
- The HTML pages serve as the Views while Code.gs acts as the Controller managing interactions with the Model (Google Sheet).

##### Relevant Technologies and Frameworks
- Google Apps Script:
- The environment executing Code.gs and managing deployment as a web application.
- Google Sheets:
- Acts as the backend “database” where messages are stored.
- HTML/CSS (and possibly basic client-side JavaScript embedded in the HTML pages):
- Used for the user interface.

## Diagram (Mermaid)

```mermaid
graph TD
    U["User/Browser"]:::user

    subgraph "Frontend UI"
        I["Index.html"]:::frontend
        V["View.html"]:::frontend
    end

    subgraph "Google Apps Script Environment"
        S["Server Logic (Code.gs)"]:::backend
        DB["Google Sheets Database"]:::database
    end

    U -->|"HTTP_Request"| I
    U -->|"HTTP_Request"| V
    I -->|"Submit_Message"| S
    V -->|"Request_Data"| S
    S -->|"Data_Write"| DB
    S -->|"Response_HTML"| I
    S -->|"Response_HTML"| V

    click I "https://github.com/danielho-bs/anonymousmessage/blob/main/Index.html"
    click V "https://github.com/danielho-bs/anonymousmessage/blob/main/View.html"
    click S "https://github.com/danielho-bs/anonymousmessage/blob/main/Code.gs"

    classDef user fill:#f9d6b4,stroke:#333,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#333,stroke-width:2px;
```
