# umutkarakas34/basic-crypto-dashboard architecture

> Architecture diagram of the GitHub repository umutkarakas34/basic-crypto-dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/umutkarakas34/basic-crypto-dashboard
- Repository: https://github.com/umutkarakas34/basic-crypto-dashboard

## Overview

##### Project type and purpose
- This is a full-stack cryptocurrency dashboard (“basic-crypto-dashboard”) with a React frontend and a Go/GraphQL backend.
- It fetches real-time data for the top 10 cryptocurrencies from the CoinGecko API, exposes it over GraphQL, and serves a single-page React app.

##### File structure
- Top-level:
- cmd/cryptotracker.db & cmd/main.go → entry point for the Go server (and a local SQLite DB file).
- gqlgen.yml → GraphQL codegen config.
- internal/ → Go application internals:
· internal/gql/ → GraphQL schema, generated code, resolver logic.
· internal/service/coin_service.go → business logic interacting with external API and DB.
· internal/db/database.go → database connection and persistence layer.
- pkg/models/coin.go → shared data models.
- crypto-tracker/ → likely the React application code (not expanded here).
- images/, README, LICENSE.

##### README for additional insights
- Tech stack: React (frontend), GraphQL, Go (backend).
- External dependency: CoinGecko API for real-time crypto data.
- GraphQL Playground included for testing.

##### Main components & interactions
a. Components
- User / Browser
- React SPA (crypto-tracker/)
- GraphQL API Server (cmd/main.go + gqlgen)
- Service Layer (coin_service.go)
- Database (SQLite file via database.go)
- External Service (CoinGecko API)
- GraphQL Playground (UI facet of the API server)
b. Relationships & data flows
1. User → React SPA: initiates UI interactions and issues GraphQL queries.
2. React SPA → GraphQL Endpoint: sends `coins { … }` query.
3. GraphQL Resolvers (internal/gql/resolver.go) → Service Layer (coin_service).
4. Service Layer → either Database (cache/persistence) or External API (CoinGecko).
5. Service Layer returns domain models (pkg/models) to GraphQL Resolvers → back to SPA.
6. GraphQL Playground communicates directly with the GraphQL Endpoint.
c. Architectural patterns & principles
- Layered architecture (Presentation → API/Resolvers → Service → Persistence/External).
- Code generation (gqlgen) for type safety.
- Clear separation of concerns: UI vs API vs business logic vs data.
d. Key technologies
- React (frontend UI)
- Go + gqlgen (GraphQL backend)
- SQLite (local DB)
- CoinGecko REST API

##### Detailed capture of essential elements
- Break out the `internal/gql`, `internal/service`, and `internal/db` as distinct sub-components in the API tier.
- Gqlgen codegen step (gqlgen.yml) as a build/configuration artifact connected to the GraphQL Server.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier"
        direction TB
        Browser["User / Browser"]:::presentation
        React["React SPA"]:::presentation
    end

    %% API Tier
    subgraph "API Tier"
        direction TB
        API_Server["GraphQL API Server"]:::api
        SchemaDef["Schema Definitions"]:::api
        CodegenConfig["gqlgen.yml (Codegen Config)"]:::api
        GeneratedStubs["Generated Types & Stubs (generated.go)"]:::api
        GeneratedModels["Generated Models (models_gen.go)"]:::api
        Resolvers["GraphQL Resolvers"]:::api
        Playground["GraphQL Playground UI"]:::presentation
    end

    %% Data Tier
    subgraph "Data & Services Tier"
        direction TB
        ServiceLayer["Service Layer"]:::api
        Models["Shared Domain Models"]:::api
        DBConn["DB Connection & Persistence"]:::persistence
        SQLiteDB["SQLite Database"]:::persistence
        CoinGecko["CoinGecko API"]:::external
    end

    %% Connections
    Browser -->|"loads SPA"| React
    React -->|"GraphQL Query"| API_Server
    Playground -->|"GraphQL Query"| API_Server
    API_Server -->|uses schema| SchemaDef
    API_Server -->|driven by codegen| CodegenConfig
    API_Server -->|includes generated code| GeneratedStubs
    API_Server -->|includes generated models| GeneratedModels
    API_Server -->|resolver calls| Resolvers
    Resolvers -->|invokes| ServiceLayer
    ServiceLayer -->|uses| Models
    ServiceLayer -.->|optional cache| DBConn
    DBConn -->|persists to| SQLiteDB
    ServiceLayer -->|"fetches data"| CoinGecko
    ServiceLayer -->|returns models| Resolvers
    Resolvers -->|responds to| React

    %% Click Events
    click React "https://github.com/umutkarakas34/basic-crypto-dashboard/tree/main/crypto-tracker/"
    click API_Server "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/cmd/main.go"
    click CodegenConfig "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/gqlgen.yml"
    click SchemaDef "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/internal/gql/schema.graphqls"
    click GeneratedStubs "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/internal/gql/generated.go"
    click GeneratedModels "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/internal/gql/models_gen.go"
    click Resolvers "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/internal/gql/resolver.go"
    click ServiceLayer "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/internal/service/coin_service.go"
    click DBConn "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/internal/db/database.go"
    click SQLiteDB "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/cmd/cryptotracker.db"
    click Models "https://github.com/umutkarakas34/basic-crypto-dashboard/blob/main/pkg/models/coin.go"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef api fill:#D0FFD8,stroke:#333,stroke-width:1px
    classDef persistence fill:#FFF5BA,stroke:#333,stroke-width:1px
    classDef external fill:#EEEEEE,stroke:#333,stroke-width:1px
```
