# gunnar97/currency_converter architecture

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

- Interactive diagram: https://gitdiagram.com/gunnar97/currency_converter
- Repository: https://github.com/gunnar97/currency_converter

## Overview

Below are step-by-step guidelines tailored to this specific project:

##### Main Components
- index.html – The HTML file that loads the Vite bundled JavaScript.
- main.jsx – Bootstraps the React application.
- App.jsx – The primary component that aggregates all child components.
- UI Components: Under the “src/components” directory, there are three main feature areas:
- ActualiCourses – Likely related to listing or displaying course content.
- Converter – This is further subdivided into InputAmount, SelectCurrency, and SwitchCurrency, which together form a module for currency conversion.
- Loader – A generic component that probably visualizes loading states.
- State Management:
- CurrencyContext.jsx under “src/context” – Manages shared state relevant to currency data.
- Data and API Management:
- services/api.js – Provides API communication routines.
- hooks/useAxios.jsx – A custom hook intended for handling HTTP requests, likely utilizing Axios.
- Configuration and Tooling:
- Vite configuration (vite.config.js) and ESLint config (.eslintrc.cjs) indicate build and code quality tooling.

##### Establish Relationships and Interactions
- The entry point (index.html) loads the bundled assets generated by Vite (configured in vite.config.js).
- The main.jsx file in “src” is responsible for initializing the React application and rendering App.jsx.
- App.jsx acts as a container for various UI components including ActualiCourses, Converter, and Loader.
- CurrencyContext.jsx wraps around parts of the component tree to provide global currency state and is likely consumed by Converter or ActualiCourses.
- The Converter component uses subcomponents (InputAmount, SelectCurrency, SwitchCurrency) to facilitate user interaction, with state likely being managed via the CurrencyContext.
- The custom hook (useAxios.jsx) and the API service (api.js) work together to fetch and manage data that is then passed down to the UI components.

##### Architectural Patterns/Design Principles
- Component-based Design: Each UI feature is broken down into smaller, reusable components.
- Separation of Concerns: The project separates UI components, state management (via context), and network interactions (services and custom hooks).
- Dependency Injection: Although simple, the use of context to supply global data (like currency info) reflects a clean dependency management setup.
- Modularization: Components and services are organized in grouped directories (e.g., Converter and its subcomponents under one folder) to promote readability and maintainability.

##### Relevant Technologies/Frameworks
- React for the component library.
- Vite as the build tool and development server.
- ESLint configuration to maintain code quality.
- (Optionally) Babel or SWC, as mentioned in the README, for Fast Refresh.
- Axios (or the abstracted useAxios hook) for managing HTTP requests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Section
    subgraph "Client (Browser)"
        index["index.html"]:::entry
    end

    %% Configuration Section
    subgraph "Configuration"
        viteConfig["Vite Config"]:::config
        eslintConfig["ESLint Config"]:::config
    end

    %% React Application Section
    subgraph "React Application"
        main["main.jsx"]:::entry
        app["App.jsx"]:::ui
        subgraph "UI Components"
            actuali["ActualiCourses"]:::ui
            converter["Converter"]:::ui
            loader["Loader"]:::ui
        end
    end

    %% Converter Subcomponents Section
    subgraph "Converter Subcomponents"
        input["InputAmount"]:::ui
        select["SelectCurrency"]:::ui
        switchC["SwitchCurrency"]:::ui
    end

    %% State Management Section
    subgraph "State Management"
        currencyCtx["CurrencyContext"]:::data
    end

    %% Data Layer Section
    subgraph "Data Layer"
        api["api.js"]:::data
        axiosHook["useAxios"]:::data
    end

    %% Connections
    viteConfig -->|"bundles"| index
    index -->|"loads"| main
    viteConfig -->|"configures"| main
    main -->|"bootstraps"| app
    app -->|"renders"| actuali
    app -->|"renders"| converter
    app -->|"renders"| loader
    converter -->|"includes"| input
    converter -->|"includes"| select
    converter -->|"includes"| switchC
    currencyCtx -->|"provides"| actuali
    currencyCtx -->|"provides"| converter
    api -->|"calls"| axiosHook
    axiosHook -->|"updates"| currencyCtx

    %% Click Events
    click index "https://github.com/gunnar97/currency_converter/blob/main//index.html"
    click main "https://github.com/gunnar97/currency_converter/blob/main//src/main.jsx"
    click app "https://github.com/gunnar97/currency_converter/blob/main//src/App.jsx"
    click actuali "https://github.com/gunnar97/currency_converter/blob/main//src/components/ActualiCourses/ActualiCourses.jsx"
    click converter "https://github.com/gunnar97/currency_converter/blob/main//src/components/Converter/Converter.jsx"
    click input "https://github.com/gunnar97/currency_converter/blob/main//src/components/Converter/InputAmount.jsx"
    click select "https://github.com/gunnar97/currency_converter/blob/main//src/components/Converter/SelectCurrency.jsx"
    click switchC "https://github.com/gunnar97/currency_converter/blob/main//src/components/Converter/SwitchCurrency.jsx"
    click loader "https://github.com/gunnar97/currency_converter/blob/main//src/components/Loader/Loader.jsx"
    click currencyCtx "https://github.com/gunnar97/currency_converter/blob/main//src/context/CurrencyContext.jsx"
    click api "https://github.com/gunnar97/currency_converter/blob/main//src/services/api.js"
    click axiosHook "https://github.com/gunnar97/currency_converter/blob/main//src/hooks/useAxios.jsx"
    click viteConfig "https://github.com/gunnar97/currency_converter/blob/main//vite.config.js"
    click eslintConfig "https://github.com/gunnar97/currency_converter/blob/main//.eslintrc.cjs"

    %% Styles
    classDef entry fill:#f9f,stroke:#333,stroke-width:2px;
    classDef ui fill:#bbf,stroke:#333,stroke-width:2px;
    classDef data fill:#cfc,stroke:#333,stroke-width:2px;
    classDef config fill:#ffc,stroke:#333,stroke-width:2px;
```
