How umutkarakas34/basic-crypto-dashboard works
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.