# dair7/logica-juego-amigo-secreto architecture

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

- Interactive diagram: https://gitdiagram.com/dair7/logica-juego-amigo-secreto
- Repository: https://github.com/dair7/logica-juego-amigo-secreto

## Overview

1. **Repo type and runtime**
   - This is a small **client-side static web app** for a Secret Santa draw.
   - It runs entirely in the **browser**; there is **no backend, database, or build pipeline** in the repository structure shown.

2. **Top-level composition**
   - The app is split into three primary concerns:
     - `index.html` for page structure,
     - `style.css` for presentation,
     - `app.js` for behavior and application logic.
   - There is also an `assets/` directory, likely for images or decorative resources used by the UI.

3. **Entry point and UI shell**
   - `index.html` is the entry point and likely wires the page together by loading the stylesheet and JavaScript.
   - It defines the visible interface: input field, add button, list area, and draw action/result area.

4. **Presentation layer**
   - `style.css` controls the visual layout and user experience.
   - Based on the README, the UI is meant to be simple and intuitive, so styling is probably responsible for the form layout, list presentation, and result highlighting.

5. **Application logic**
   - `app.js` contains the core behavior:
     - accepting names from the input,
     - validating them,
     - storing them in memory,
     - rendering the current list,
     - selecting a random winner.
   - This is the main functional boundary of the application.

6. **Data model**
   - The primary runtime state is a **list/array of participant names** maintained in JavaScript memory.
   - The app depends on this in-memory list for both display and draw operations; refreshing the page would reset state unless persistence is implemented, which is not indicated here.

7. **User interaction flow**
   - The normal flow is:
     - user enters a name,
     - the app validates it,
     - the name is added to the list,
     - the list is re-rendered,
     - the user triggers a random draw,
     - the chosen name is shown as the result.
   - The README explicitly mentions protection against empty and duplicate entries, so validation is part of the input boundary.

8. **Validation and control boundaries**
   - The app enforces two important input rules:
     - no blank names,
     - no duplicates.
   - These checks sit between raw user input and the participant list, preventing invalid state from entering the draw logic.

9. **Random selection subsystem**
   - The “sortear amigo” action is a separate logical step from list management.
   - It selects one item at random from the current participant array and publishes the result in the UI, likely with a visual notification.

10. **External dependencies and integration**
   - There are no indications of external APIs, third-party services, or package-managed dependencies.
   - The application is self-contained and likely intended to be opened directly in a browser from the filesystem or served as static files.

11. **Architecture boundary summary**
   - The clearest diagram boundary is:
     - **Browser UI layer**: HTML/CSS rendering and user interaction,
     - **JavaScript logic layer**: validation, list state, and random selection,
     - **Static assets**: optional visual resources.
   - All meaningful data flow stays inside the client runtime.

12. **What matters for a diagram**
   - Show the user interacting with the browser page.
   - Show `app.js` reading input, updating an in-memory list, and producing a rendered list/result.
   - Keep `index.html` and `style.css` as supporting presentation layers, not separate services.

Main entry points: [`challenge-amigo-secreto_esp-main/index.html`](https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/index.html) (Page shell), [`challenge-amigo-secreto_esp-main/app.js`](https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/app.js) (App logic), [`challenge-amigo-secreto_esp-main/style.css`](https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/style.css) (Styles), [`challenge-amigo-secreto_esp-main/assets`](https://github.com/dair7/logica-juego-amigo-secreto/tree/main/challenge-amigo-secreto_esp-main/assets) (Assets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser UI"]
  node_index_html["Page shell<br/>entry html<br/>[index.html]"]
  node_style_css["Styles<br/>css<br/>[style.css]"]
  node_assets["Assets"]
  node_input["Name input<br/>ui control"]
  node_add_btn["Add button<br/>ui control"]
  node_list_view["Name list<br/>view state"]
  node_draw_btn["Draw action<br/>ui control"]
  node_result_view["Result area<br/>view state"]
end

subgraph group_logic["App Logic"]
  node_app_js["App logic<br/>client js<br/>[app.js]"]
  node_validation["Validation<br/>input rules"]
  node_participants[("Participants<br/>memory array")]
  node_rendering["Render flow<br/>dom updates"]
  node_random_draw["Random draw<br/>selection logic"]
end

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

node_user -->|"opens"| node_index_html
node_index_html -->|"includes"| node_style_css
node_index_html -->|"loads"| node_app_js
node_index_html -->|"contains"| node_input
node_index_html -->|"contains"| node_add_btn
node_index_html -->|"contains"| node_list_view
node_index_html -->|"contains"| node_draw_btn
node_index_html -->|"contains"| node_result_view
node_app_js -->|"checks"| node_validation
node_validation -->|"guards"| node_participants
node_app_js -->|"stores"| node_participants
node_add_btn -->|"submits"| node_app_js
node_input -->|"provides"| node_validation
node_app_js -->|"updates"| node_rendering
node_rendering -->|"draws"| node_list_view
node_draw_btn -->|"starts"| node_random_draw
node_random_draw -->|"reads"| node_participants
node_random_draw -->|"publishes"| node_result_view
node_style_css -->|"styles"| node_input
node_style_css -->|"styles"| node_list_view
node_style_css -->|"styles"| node_result_view
node_assets -.->|"supports"| node_index_html

click node_index_html "https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/index.html"
click node_style_css "https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/style.css"
click node_app_js "https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/app.js"
click node_assets "https://github.com/dair7/logica-juego-amigo-secreto/tree/main/challenge-amigo-secreto_esp-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,node_input,node_add_btn,node_list_view,node_draw_btn,node_result_view toneBlue
class node_app_js,node_validation,node_participants,node_rendering,node_random_draw toneAmber
class node_user toneNeutral
```

## Components

### Browser UI

Static page and presentation layer

- [Page shell](https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/index.html): entry html · Main document that loads the app · `challenge-amigo-secreto_esp-main/index.html`
- [Styles](https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/style.css): css · Visual layout and UI presentation · `challenge-amigo-secreto_esp-main/style.css`
- [Assets](https://github.com/dair7/logica-juego-amigo-secreto/tree/main/challenge-amigo-secreto_esp-main/assets): static assets · Optional images or decorative resources · `challenge-amigo-secreto_esp-main/assets`
- **Name input**: ui control · Captures participant names from the page
- **Add button**: ui control · Submits a new participant name
- **Name list**: view state · Displays current participants
- **Draw action**: ui control · Starts the random selection
- **Result area**: view state · Shows the selected secret santa

### App Logic

Client-side state and interaction handling

- [App logic](https://github.com/dair7/logica-juego-amigo-secreto/blob/main/challenge-amigo-secreto_esp-main/app.js): client js · Handles input, list state, rendering, and draw actions · `challenge-amigo-secreto_esp-main/app.js`
- **Validation**: input rules · Rejects blank and duplicate names
- **Participants**: memory array · In-memory list of names used for rendering and draw
- **Render flow**: dom updates · Refreshes the list and result in the page
- **Random draw**: selection logic · Chooses one participant at random

### Other components

- **User**: actor · Enters names and triggers the draw

## Connections

- User → Page shell: opens · Loads the static page in the browser
- Page shell → Styles: includes · Applies the page styling
- Page shell → App logic: loads · Attaches the client-side behavior
- Page shell → Name input: contains · Renders the input boundary
- Page shell → Add button: contains · Renders the add control
- Page shell → Name list: contains · Renders the participant list area
- Page shell → Draw action: contains · Renders the draw control
- Page shell → Result area: contains · Renders the output area
- App logic → Validation: checks · Validates raw name input
- Validation → Participants: guards · Prevents invalid state from entering the list
- App logic → Participants: stores · Maintains participants in memory
- Add button → App logic: submits · Sends a new name for processing
- Name input → Validation: provides · Supplies the raw participant name
- App logic → Render flow: updates · Triggers page refresh after state changes
- Render flow → Name list: draws · Shows the current participant list
- Draw action → Random draw: starts · Requests a random secret santa selection
- Random draw → Participants: reads · Selects from the current list
- Random draw → Result area: publishes · Displays the chosen name
- Styles → Name input: styles · Formats the input field and controls
- Styles → Name list: styles · Formats the participant list
- Styles → Result area: styles · Highlights the draw result
- Assets → Page shell: supports · Provides optional static resources
