# maks0101aps/currency-converter architecture

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

- Interactive diagram: https://gitdiagram.com/maks0101aps/currency-converter
- Repository: https://github.com/maks0101aps/currency-converter

## Overview

Based on an analysis of the file tree and README, this project is a modern, full-stack web application focused on converting currencies in real-time. It leverages a Node.js backend (using Express, Axios, Dotenv) to fetch data from the Open Exchange Rates API and serves a static, responsive frontend (HTML, CSS, JavaScript, Tailwind CSS, Bootstrap, Font Awesome) to the user.

##### Main Components
- Frontend:
- Static assets served from the public directory (index.html, CSS, JS).
- Backend:
- Express Server (located in src/server.js) that handles API requests, serves static files, and initiates Axios calls to external currency APIs.
- Environment configuration is managed via Dotenv (.env and .env.example).
- External Services:
- The Open Exchange Rates API, which provides the real-time currency exchange rate data for conversion.
- Optional/Additional Components:
- Offline caching mechanism for exchange rates (as per README, though implementation details might be within the code logic).
- Easter Eggs feature which could be represented as a separate module or functionality.

##### Relationships and Interactions
- Data Flow:
- Users interact with the frontend via a web browser.
- The frontend (client-side JavaScript) communicates with the Express server for any dynamic requests.
- The Express server fetches real-time exchange data from the external Open Exchange Rates API using Axios.
- Optionally, when offline, the application falls back on cached data—this should be clearly noted, even if internally handled.
- Dependencies:
- The frontend depends on libraries such as Bootstrap, Tailwind CSS, and Font Awesome for UI elements.
- The backend depends on Node.js/Express for server logic and on external libraries (e.g., Axios) to conduct HTTP requests.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Frontend static files are kept separate from backend server code.
- Client-Server Architecture: Clear division between client-side interface (in the public directory) and server-side API/logic (in src).
- Environment-Specific Configuration: Use of environment variables to adjust settings like the server port.
- Extensibility: Simple structure that allows easy additions (e.g., the detection and handling of hidden Easter eggs).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    U["User (Browser)"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (UI & Static Assets)<br/>HTML5, CSS3, JavaScript, Tailwind, Bootstrap, Font Awesome"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend (Express Server)<br/>Node.js, Express, Axios"]:::backend
        Env["Environment Config (Dotenv)"]:::backend
        OPT["Optional Features<br/>(Offline Caching, Easter Eggs)"]:::optional
    end

    %% External Services
    subgraph "External Services"
        API["External Currency API<br/>(Open Exchange Rates)"]:::external
    end

    %% Connections
    U -->|"initiates_request"| FE
    FE -->|"ajax_calls"| BE
    BE -->|"axios_fetch"| API
    API -->|"returns_data"| BE
    BE -->|"serves_data"| FE
    FE -->|"renders_content"| U
    BE -->|"loads_config"| Env
    BE -->|"handles_optional"| OPT

    %% Click Events
    click FE "https://github.com/maks0101aps/currency-converter/tree/main/public"
    click BE "https://github.com/maks0101aps/currency-converter/blob/main/src/server.js"
    click Env "https://github.com/maks0101aps/currency-converter/blob/main/.env.example"

    %% Styles
    classDef user fill:#f8bbd0,stroke:#c2185b,stroke-width:2px;
    classDef frontend fill:#b3e5fc,stroke:#0288d1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;
    classDef external fill:#ffcc80,stroke:#f57c00,stroke-width:2px;
    classDef optional fill:#d1c4e9,stroke:#512da8,stroke-width:2px;
```
