# yannick-nq/secret-friend-game architecture

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

- Interactive diagram: https://gitdiagram.com/yannick-nq/secret-friend-game
- Repository: https://github.com/yannick-nq/secret-friend-game

## Overview

##### Project Type and Purpose
- This is a single-page web application (front-end only) for conducting a "Secret Friend" (Amigo Secreto) lottery. The app allows users to add or remove friends and then randomly select a secret friend, displaying the result with animations.
- The README and file tree reveal that this is not a full-stack or multi-service project but a lightweight interactive web app built primarily with HTML, CSS, and JavaScript.

##### Analyzing the File Structure
- The top-level files include:
- README.md – which gives the project details, screenshots, and instructions.
- index.html – the main entry point for the front-end interface.
- style.css – providing the styling for the interface.
- app.js – the core JavaScript file containing the logic for managing the list of friends, handling events (adding, removing, sorting), and displaying modals.
- The assets directory includes fonts and images used within the UI.
- Because there are no back-end directories (like “backend”, “server”, “api”, etc.), the application’s logic and data management are encapsulated on the client side.

##### Key Components
a. User Interface (UI):
- This is represented by the HTML (index.html) and CSS (style.css).
- Components such as the form for friend entry, buttons with animations, participant cards, and modals for displaying the secret friend.
- Assets (fonts and images) support the UI visuals and styling.
b. Business/Presentation Logic:
- app.js contains the logic to add and remove friends, process the list, and perform the random selection (sorteo).
- Event handling as well as business rules (e.g., ensuring proper input format and triggering appropriate animations).
c. External and Static Resources:
- The assets folder holds static resources including fonts (e.g., “DragonHunter”) and images used in the interface, along with any SVG references.
- Although not connected to an external API, these assets are essential to the user experience.

##### Relationships and Architectural Interaction
- The style layer (style.css) will apply to both static HTML elements and dynamically generated nodes, so represent it as an underlying layer affecting the UI.
- That assets are loaded by the HTML file and used by both CSS and JavaScript to display the correct images and fonts.

##### Architectural Patterns or Principles
- While not explicitly using a strict MVC framework, the project naturally separates concerns:
- The HTML/CSS act as the “View”.
- The JavaScript (app.js) functions as the “Controller”, handling user events and managing the application’s state.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        UI["index.html (UI)"]:::ui
        CSS["style.css (Styling)"]:::css
    end

    subgraph "Business Logic"
        JS["app.js (Logic)"]:::js
    end

    subgraph "Static Resources"
        ASSETS["assets (Static Resources)"]:::assets
    end

    UI -->|"triggersEvents"| JS
    JS -->|"updatesDOM"| UI
    CSS -->|"appliesStyles"| UI
    UI -->|"loadsAssets"| ASSETS
    CSS -->|"usesAssets"| ASSETS
    JS -->|"referencesAssets"| ASSETS

    click UI "https://github.com/yannick-nq/secret-friend-game/blob/main/index.html"
    click CSS "https://github.com/yannick-nq/secret-friend-game/blob/main/style.css"
    click JS "https://github.com/yannick-nq/secret-friend-game/blob/main/app.js"
    click ASSETS "https://github.com/yannick-nq/secret-friend-game/tree/main/assets"

    classDef ui fill:#A3E4D7,stroke:#1ABC9C,stroke-width:2px;
    classDef css fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef js fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef assets fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
```
