# alantorresdev/challenge-amigo-secreto architecture

> Architecture diagram of the GitHub repository alantorresdev/challenge-amigo-secreto, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alantorresdev/challenge-amigo-secreto
- Repository: https://github.com/alantorresdev/challenge-amigo-secreto

## Overview

1. **Project type and runtime**
   - This is a **static client-side web app** for the “amigo secreto” game.
   - It runs entirely in the browser with **HTML, CSS, and vanilla JavaScript**.
   - There is **no backend, database, or external API** involved.

2. **Top-level structure**
   - `index.html` is the single entry point and defines the page structure.
   - `style.css` handles all visual styling.
   - `app.js` contains the application logic and UI behavior.
   - `assets/` stores static images/icons used by the interface.

3. **Presentation layer**
   - The UI is built as a single-page form-like experience: a text input, a list of added names, and action buttons for adding, drawing, and resetting.
   - The page is designed to display the current participant list and the selected random result directly in the browser.

4. **State management**
   - The app keeps the list of entered names in **memory inside JavaScript**.
   - That state is temporary: it exists only while the page is open.
   - Reloading the page clears the list because there is no persistence layer such as localStorage or a server.

5. **Input and validation flow**
   - The user enters a name in the input field and triggers the “add” action.
   - The JavaScript validates the input to accept **letters and spaces only**.
   - Invalid input produces an **alert** and does not update the stored list.

6. **List rendering flow**
   - When a valid name is added, it is appended to the in-memory collection.
   - The UI is then refreshed to show the full stored list.
   - This creates a simple one-way flow: **input → validation → state update → DOM re-render**.

7. **Random selection flow**
   - The “choose secret friend” action selects one stored name at random from the current list.
   - The result is shown in the interface as the final outcome of the game.
   - The random draw depends entirely on the current in-memory participant list.

8. **Reset behavior**
   - A reset button clears the current game state.
   - That means removing stored names and returning the interface to its initial state.
   - This acts as the app’s only “restart” mechanism since there is no persisted session state.

9. **Separation of responsibilities**
   - `index.html` defines structure and element hooks.
   - `style.css` defines layout, colors, typography, and visual feedback.
   - `app.js` owns all dynamic behavior: validation, list management, random choice, and reset logic.
   - `assets/` is purely static and does not affect logic.

10. **Deployment model**
   - The app can be hosted as a **static site**; the README indicates GitHub Pages deployment.
   - This means the architecture is optimized for file-based delivery, not server rendering or API orchestration.

11. **Important architectural boundary**
   - The main boundary is between **static UI markup/styles** and **runtime JavaScript state/behavior**.
   - All interactivity happens on the client side, so the browser is both the execution environment and the data store.

12. **Diagram takeaway**
   - An accurate architecture diagram should show:
     - User actions flowing into `app.js`
     - `app.js` updating browser-held state and the DOM
     - `index.html` and `style.css` providing the static interface shell
     - `assets/` supplying decorative/media resources
     - No server, database, or network dependency in the core app flow

Main entry points: [`app.js`](https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/app.js) (app.js), [`assets`](https://github.com/alantorresdev/challenge-amigo-secreto/tree/main/assets) (assets), [`index.html`](https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/index.html) (index.html), [`style.css`](https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/style.css) (style.css)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_static["Static UI"]
  node_index_html["index.html<br/>markup<br/>[index.html]"]
  node_style_css["style.css<br/>styles<br/>[style.css]"]
  node_assets[("assets<br/>static media")]
end

subgraph group_runtime["Browser Runtime"]
  node_browser{{"Browser<br/>runtime"}}
  node_app_js["app.js<br/>logic<br/>[app.js]"]
end

node_user(("User<br/>actor"))

node_user -->|"interacts with"| node_browser
node_browser -->|"loads"| node_index_html
node_browser -->|"applies"| node_style_css
node_browser -->|"runs"| node_app_js
node_app_js -->|"updates DOM/state"| node_browser
node_assets -->|"provides media"| node_browser

click node_index_html "https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/index.html"
click node_style_css "https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/style.css"
click node_app_js "https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/app.js"
click node_assets "https://github.com/alantorresdev/challenge-amigo-secreto/tree/main/assets"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_index_html,node_style_css,node_assets toneBlue
class node_browser,node_app_js toneAmber
class node_user toneNeutral
```

## Components

### Static UI

Files that define the page shell, presentation, and media assets.

- [index.html](https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/index.html): markup · Single entry point and page structure. · `index.html`
- [style.css](https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/style.css): styles · Visual design, layout, and feedback. · `style.css`
- [assets](https://github.com/alantorresdev/challenge-amigo-secreto/tree/main/assets): static media · Images and icons used by the interface. · `assets`

### Browser Runtime

Client-side execution and in-memory game state.

- **Browser**: runtime · Executes the app and holds transient state in memory.
- [app.js](https://github.com/alantorresdev/challenge-amigo-secreto/blob/main/app.js): logic · Validation, list management, random draw, and reset behavior. · `app.js`

### Other components

- **User**: actor · Enters names, starts the draw, and resets the game.

## Connections

- User → Browser: interacts with · The player uses the page through the browser UI.
- Browser → index.html: loads · The browser renders the page structure from the HTML entry point.
- Browser → style.css: applies · The browser applies the stylesheet for layout and presentation.
- Browser → app.js: runs · The browser executes the client-side game logic.
- app.js → Browser: updates DOM/state · JavaScript validates input, updates the in-memory list, re-renders the UI, and shows results.
- assets → Browser: provides media · Static icons and images are loaded into the interface.
