# astatochek/angular-currency-rates architecture

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

- Interactive diagram: https://gitdiagram.com/astatochek/angular-currency-rates
- Repository: https://github.com/astatochek/angular-currency-rates

## Overview

##### Component Breakdown

a. Top Level:
- AppComponent (root)
└── MainComponent (primary container)

b. Feature Components (shown as child nodes):
- CardComponent
- DropdownComponent
- RateComponent
- TokenInputComponent

##### Service Layer
- ApiService (core API communication)
- CurrencyService (currency-related operations)
- TokenService (token management)

##### Data Flow and Models
- Models (shown as rounded rectangles):
- Currency
- Token
- ApiResponse

##### External Integration
An external system block showing:
- Currency Rate API (external service)
- HTTP Interceptor (request.interceptor)

- Blue: Components
- Green: Services
- Yellow: Models
- Gray: External Systems
- Red: Interceptors

Specific Instructions:

- [External API] ↔ [Interceptor] ↔ [Services] ↔ [Components] → [User Interface]

3. A special note about the request.interceptor, as it handles all HTTP communications.

4. Relationship between services and their corresponding components using connecting lines.

Key Architectural Points to Highlight:

##### Component Architecture
- How the MainComponent orchestrates other components
- Modular structure of feature components

##### Service Pattern
- Demonstrate how services act as singletons for the application
- Separation of concerns between different services

##### Data Flow
- How data flows from the API through services to components
- How user interactions trigger API calls

##### Cross-Cutting Concerns
- How the interceptor handles request/response lifecycle
- Integration points with external currency API

- Component symbols
- Service symbols
- Relationship types

Level of Detail:
- Keep component internals abstract
- Service interactions
- Data flow patterns
- Clear boundaries between layers

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        API[External Currency Rate API]
    end

    subgraph Interceptors
        INT["Request Interceptor"]:::interceptor
    end

    subgraph Services
        AS["API Service"]:::service
        CS["Currency Service"]:::service
        TS["Token Service"]:::service
    end

    subgraph Models
        CM["Currency Model"]:::model
        TM["Token Model"]:::model
        ARM["API Response Model"]:::model
    end

    subgraph Components
        AC["App Component"]:::component
        MC["Main Component"]:::component
        CC["Card Component"]:::component
        DC["Dropdown Component"]:::component
        RC["Rate Component"]:::component
        TIC["Token Input Component"]:::component
    end

    %% Relationships
    API --> INT
    INT --> AS
    AS --> CS
    AS --> TS

    CS --> MC
    TS --> MC
    
    MC --> CC
    MC --> DC
    MC --> RC
    MC --> TIC

    CS --> CM
    TS --> TM
    AS --> ARM

    %% Click Events
    click AC "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/app.component.ts"
    click MC "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/components/main/main.component.ts"
    click CC "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/components/card/card.component.ts"
    click DC "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/components/dropdown/dropdown.component.ts"
    click RC "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/components/rate/rate.component.ts"
    click TIC "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/components/token-input/token-input.component.ts"
    click AS "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/services/api.service.ts"
    click CS "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/services/currency.service.ts"
    click TS "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/services/token.service.ts"
    click CM "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/models/currency.ts"
    click TM "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/models/token.ts"
    click ARM "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/models/api.response.ts"
    click INT "https://github.com/astatochek/angular-currency-rates/blob/main/src/app/interceptors/request.interceptor.ts"

    %% Styles
    classDef component fill:#2196F3,stroke:#1565C0,color:white
    classDef service fill:#4CAF50,stroke:#2E7D32,color:white
    classDef model fill:#FFC107,stroke:#FFA000,color:black
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef interceptor fill:#F44336,stroke:#C62828,color:white

    %% Legend
    subgraph Legend
        C1["Component"]:::component
        S1["Service"]:::service
        M1["Model"]:::model
        E1["External System"]:::external
        I1["Interceptor"]:::interceptor
    end
```
