# tsu56/eatandworkproject architecture

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

- Interactive diagram: https://gitdiagram.com/tsu56/eatandworkproject
- Repository: https://github.com/tsu56/eatandworkproject

## Overview

##### Project type and purpose
- This is a single‐page web application with both frontend and backend elements written in Node.js.

##### File structure
Top level
- app.js            – Node.js entry point (likely uses Express to serve views & static assets)
- package.json      – lists dependencies and dev scripts (`npm run dev`)
- .env              – environment variables (e.g., ArcGIS API key)
- vercel.json       – deployment config
public/
- css/map.css       – custom map styling
- js/arcgis.js      – encapsulates map‐initialization logic
- js/esriAPI.js     – wrapper or loader for ArcGIS JS API
- js/index.js       – client bootstrap, event wiring
- js/tailwindV4.js  – Tailwind CSS integration
- data/*.csv        – raw restaurant & workplace data
utils/
- decrypt.js        – Node helper to decrypt secure values (e.g., API keys)
views/
- index.html        – main HTML template

##### Extract insights from the README
- The app runs on Node.js, serving at localhost:3000 (or port 4001).
- No external database—static CSVs are the “data store.”
- Frontend is a client‐heavy map visualization using Esri/ArcGIS API.

##### Main components
a. Client (Browser)
- Loads index.html
- Executes public/js/*.js (arcgis.js, index.js, esriAPI.js, tailwindV4.js)
- Renders interactive map
- Fetches CSV files from the static server
- Communicates with external ArcGIS/Esri REST services
b. Application Server (Node.js)
- app.js (Express server)
- Serves views/index.html and static assets under public/
- Reads .env and uses utils/decrypt.js to retrieve secure config
c. Data Store (Static)
- CSV files in public/data/
d. External Service
- Esri/ArcGIS JavaScript API & REST endpoints

##### Relationships & interactions
- Browser → Server: GET “/” ➔ serves index.html
- Browser → Server: GET “/css, /js, /data, /img”
- Browser → ArcGIS REST API: map tiles, geocoding, basemaps
- Server → utils/decrypt.js → .env: decrypt and inject API key into esriAPI.js or view

##### Architectural patterns & principles
- Separation of concerns:
- Presentation (views + CSS + client JS)
- Business logic (app.js + utils)
- Data (static CSV)
- Client‐heavy mapping app: all map logic runs in the browser
- Static asset hosting for performance & simplicity
- Environment‐driven configuration for API keys

##### Technologies & frameworks
- Node.js + (assumed) Express
- ArcGIS JavaScript API (via esriAPI.js)
- Tailwind CSS v4
- CSV as static data backend
- Vercel for deployment

##### Detail
- Decrypt utility and .env read to indicate security best practices.
- Caching/static‐file hosting if desired (e.g., Vercel).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    subgraph "Client (Browser)"
        Browser["Client (Browser)\n(Client-side map logic)"]:::frontend
    end

    %% Application Server
    subgraph "Application Server (Node.js App Server)"
        AppJS["app.js\n(Express server)"]:::server
        Pkg["package.json"]:::server
        ENV[".env"]:::server
        Decrypt["utils/decrypt.js"]:::server
        Vercel["vercel.json"]:::server
    end

    %% Static Assets
    subgraph "Static Assets"
        views["index.html"]:::views

        subgraph "CSS"
            mapcss["css/map.css"]:::css
        end

        subgraph "JavaScript"
            arcgisjs["js/arcgis.js"]:::js
            esriAPI["js/esriAPI.js"]:::js
            indexjs["js/index.js"]:::js
            tailwind["js/tailwindV4.js"]:::js
        end

        subgraph "Data (CSV Files)"
            restaurant[(restaurant.csv)]:::datastore
            workplace[(workplace.csv)]:::datastore
            workplaceTypes[(workplace_types.csv)]:::datastore
        end

        subgraph "Media (Images)"
            imgRest["restaurant/type/Rate"]:::media
            imgWorkType["type_workplace/.DS_Store"]:::media
            imgWork["workplace"]:::media
        end
    end

    %% External Services
    subgraph "External Services"
        ArcGIS["Esri/ArcGIS API & REST"]:::external
    end

    %% Connections
    Browser -->|"HTTP GET /"| AppJS
    Browser -->|"HTTP GET /css, /js, /data, /img"| AppJS
    Browser -->|"REST calls"| ArcGIS

    AppJS -->|uses| Decrypt
    Decrypt -->|reads| ENV
    AppJS -->|config| Pkg
    AppJS -->|deploy config| Vercel

    AppJS -->|serves| views
    AppJS -->|serves| mapcss
    AppJS -->|serves| arcgisjs
    AppJS -->|serves| esriAPI
    AppJS -->|serves| indexjs
    AppJS -->|serves| tailwind
    AppJS -->|serves| restaurant
    AppJS -->|serves| workplace
    AppJS -->|serves| workplaceTypes
    AppJS -->|serves| imgRest
    AppJS -->|serves| imgWorkType
    AppJS -->|serves| imgWork

    %% Click Events
    click views "https://github.com/tsu56/eatandworkproject/blob/main/views/index.html"
    click mapcss "https://github.com/tsu56/eatandworkproject/blob/main/public/css/map.css"
    click arcgisjs "https://github.com/tsu56/eatandworkproject/blob/main/public/js/arcgis.js"
    click esriAPI "https://github.com/tsu56/eatandworkproject/blob/main/public/js/esriAPI.js"
    click indexjs "https://github.com/tsu56/eatandworkproject/blob/main/public/js/index.js"
    click tailwind "https://github.com/tsu56/eatandworkproject/blob/main/public/js/tailwindV4.js"
    click AppJS "https://github.com/tsu56/eatandworkproject/blob/main/app.js"
    click Pkg "https://github.com/tsu56/eatandworkproject/blob/main/package.json"
    click ENV "https://github.com/tsu56/eatandworkproject/blob/main/.env"
    click Decrypt "https://github.com/tsu56/eatandworkproject/blob/main/utils/decrypt.js"
    click Vercel "https://github.com/tsu56/eatandworkproject/blob/main/vercel.json"
    click restaurant "https://github.com/tsu56/eatandworkproject/blob/main/public/data/restaurant.csv"
    click workplace "https://github.com/tsu56/eatandworkproject/blob/main/public/data/workplace.csv"
    click workplaceTypes "https://github.com/tsu56/eatandworkproject/blob/main/public/data/workplace_types.csv"
    click imgRest "https://github.com/tsu56/eatandworkproject/tree/main/public/img/restaurant/type/Rate"
    click imgWorkType "https://github.com/tsu56/eatandworkproject/blob/main/public/img/type_workplace/.DS_Store"
    click imgWork "https://github.com/tsu56/eatandworkproject/tree/main/public/img/workplace"

    %% Styles
    classDef frontend fill:#D6EFFF,stroke:#0284C7,stroke-width:2px
    classDef server fill:#DCFCE7,stroke:#22C55E,stroke-width:2px
    classDef views fill:#F0FDF4,stroke:#10B981,stroke-width:2px
    classDef css fill:#FEF3C7,stroke:#EAB308,stroke-width:2px
    classDef js fill:#E0F2FE,stroke:#3B82F6,stroke-width:2px
    classDef datastore fill:#FEF9C3,stroke:#EAB308,stroke-width:2px
    classDef media fill:#EDE9FE,stroke:#8B5CF6,stroke-width:2px
    classDef external fill:#F3F4F6,stroke:#6B7280,stroke-width:2px
```
