# dylut2000/cryptonana architecture

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

- Interactive diagram: https://gitdiagram.com/dylut2000/cryptonana
- Repository: https://github.com/dylut2000/cryptonana

## Overview

##### Project type and purpose
- This is a single-page application (SPA) built with Angular.
- Its purpose is to display country information (see the README link to “/countries”).
- There is no custom backend in this repo; it’s purely a frontend that likely calls an external REST API for country data.

##### File structure
- Top level:
- angular.json, tsconfig*.json, package.json – Angular CLI & TypeScript configs
- public/ – static assets (favicon, index.html boilerplate)
- src/ – source code
- src/app/ splits into:
- app.component.* – root shell
- app.config.ts & app.routes.ts – central routing & configuration
- pages/ – “feature modules” for top-level views (home, info, notfound)
- services/ – injectable business-logic layers (CountryService, LoaderService)
- ui/ – reusable UI components (cards, search bar, loading indicator)
- src/environments/ – environment‐specific API endpoint settings

##### README for additional insights
- The README simply points you to the live deployment, confirming it’s a frontend-only SPA.

a. Main components to include
- Browser / User Interface (host where the SPA runs)
- Angular App Shell
– Root Module & Component (AppComponent)
– Router (app.routes.ts)
- Feature Pages (HomePageComponent, InfoComponent, NotFoundComponent)
- UI Components (CountryCardComponent, SearchComponent, LoadingComponent)
- Services (CountryService, LoaderService)
- External REST API (e.g., https://restcountries.com or similar)
- Environment Config (environment.ts → provides base API URL)
b. Relationships & interactions
- The browser loads index.html → bootstraps main.ts → AppModule → AppComponent
- Router listens to URL changes → loads Page Components
- Page Components inject CountryService to fetch data from the external API
- CountryService uses Angular HttpClient, configured by environment.ts
- LoaderService provides a UI “spinner” when requests are pending
- Page Components pass raw data to UI Components for rendering
- User actions in UI (e.g., SearchComponent emits events) feed back into Page Component logic
c. Architectural patterns & principles
- Module-based organization (Angular NgModule)
- Separation of concerns:
– Feature pages handle routing & orchestration
– Services handle data retrieval & state (loader)
– UI components are purely presentational
- Reactive data flows (Observables via HttpClient)
- Environment-based configuration for API endpoints
d. Key technologies & frameworks
- Angular (CLI, Router, HttpClient, Components, Services)
- TypeScript
- RxJS (Observables)
- PostCSS (per .postcssrc.json)
- Vercel (deployment via link provided)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Bootstrap Sequence
    Browser["Browser"]:::external
    Index["index.html"]:::module
    Main["main.ts\n(Application Bootstrap)"]:::module
    AppModule["AppComponent\n(Root Component)"]:::module
    Config["app.config.ts"]:::module
    Router["app.routes.ts\n(Router Definition)"]:::module

    Browser -->|"loads"| Index
    Index -->|"bootsraps"| Main
    Main -->|"bootstrap"| AppModule
    AppModule -->|"imports config"| Config
    AppModule -->|"configures router"| Router

    %% Pages
    subgraph "Pages" 
        direction TB
        Home["HomePageComponent"]:::module
        Info["InfoPageComponent"]:::module
        NotFound["NotFoundComponent"]:::module
    end

    Router -->|"route events"| Home
    Router -->|"route events"| Info
    Router -->|"route events"| NotFound

    %% Services
    subgraph "Services"
        direction TB
        CountryService["CountryService"]:::service
        LoaderService["LoaderService"]:::service
    end

    Home -->|"injects"| CountryService
    Info -->|"injects"| CountryService
    Home -->|"injects"| LoaderService
    Info -->|"injects"| LoaderService

    %% Environment
    subgraph "Environment Configuration"
        direction TB
        EnvProd["environment.ts"]:::env
        EnvDev["environment.development.ts"]:::env
    end

    CountryService -->|"uses baseURL from"| EnvProd
    CountryService -->|"uses baseURL from"| EnvDev

    %% External API
    ExternalAPI["External REST API\n(GET /countries)"]:::external
    CountryService -->|"GET /countries"| ExternalAPI

    %% UI Components
    subgraph "UI Components"
        direction TB
        CountryCard["CountryCardComponent"]:::ui
        SearchComp["SearchComponent"]:::ui
        LoadingComp["LoadingComponent"]:::ui
    end

    Home -->|"binds data to"| CountryCard
    Home -->|"passes search events to"| SearchComp
    Home -->|"shows spinner via"| LoadingComp
    Info -->|"binds data to"| CountryCard
    Info -->|"shows spinner via"| LoadingComp

    LoaderService -->|"controls spinner state"| LoadingComp
    SearchComp -->|"emits search event"| Home

    %% Click events
    click AppModule "https://github.com/dylut2000/cryptonana/blob/main/src/app/app.component.ts"
    click Config "https://github.com/dylut2000/cryptonana/blob/main/src/app/app.config.ts"
    click Router "https://github.com/dylut2000/cryptonana/blob/main/src/app/app.routes.ts"
    click Home "https://github.com/dylut2000/cryptonana/blob/main/src/app/pages/home-page/home-page.component.ts"
    click Info "https://github.com/dylut2000/cryptonana/blob/main/src/app/pages/info/info.component.ts"
    click NotFound "https://github.com/dylut2000/cryptonana/blob/main/src/app/pages/notfound/notfound.component.ts"
    click CountryService "https://github.com/dylut2000/cryptonana/blob/main/src/app/services/country.service.ts"
    click LoaderService "https://github.com/dylut2000/cryptonana/blob/main/src/app/services/loader.service.ts"
    click CountryCard "https://github.com/dylut2000/cryptonana/blob/main/src/app/ui/country-card/country-card.component.ts"
    click SearchComp "https://github.com/dylut2000/cryptonana/blob/main/src/app/ui/search/search.component.ts"
    click LoadingComp "https://github.com/dylut2000/cryptonana/blob/main/src/app/ui/loading/loading.component.ts"
    click EnvProd "https://github.com/dylut2000/cryptonana/blob/main/src/environments/environment.ts"
    click EnvDev "https://github.com/dylut2000/cryptonana/blob/main/src/environments/environment.development.ts"
    click Main "https://github.com/dylut2000/cryptonana/blob/main/src/main.ts"
    click Index "https://github.com/dylut2000/cryptonana/blob/main/src/index.html"

    %% Styles
    classDef module fill:#D0E8FF,stroke:#004A9F,color:#000;
    classDef service fill:#DFF2BF,stroke:#4F8A10,color:#000;
    classDef ui fill:#FFE8A1,stroke:#B57C00,color:#000;
    classDef env fill:#F0F0F0,stroke:#888888,color:#000;
    classDef external fill:#F5F5F5,stroke:#BBBBBB,color:#000;
```
