# dfinity-education/blockchain-and-cryptocurrency architecture

> Architecture diagram of the GitHub repository dfinity-education/blockchain-and-cryptocurrency, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dfinity-education/blockchain-and-cryptocurrency
- Repository: https://github.com/dfinity-education/blockchain-and-cryptocurrency

## Overview

##### Project type and purpose
– This is an educational/training repository for a blockchain course built on the DFINITY Internet Computer. It combines Markdown-based course modules (Module 1–4), Motoko smart‐contract code under src/, and deployment configuration (dfx.json). Students learn blockchain fundamentals, ERC-20-style tokens, and payment channels by iterating through these modules.

##### File structure
Top-level files & dirs:
- module-*.md + README.md – course content
- images/ – illustrations used in modules
- src/ – Motoko code:
– Main.mo (entry point / canister logic)
– Types.mo (type definitions)
– User.mo (user/account logic)
- dfx.json – Internet Computer canister configuration
- vendor/ – third-party Motoko libraries
- package-lock.json – Node/dfx CLI dependencies
Patterns & indicators:
– src/ organizes core smart‐contract code
– module-*.md and images/ hold pedagogical content
– dfx.json drives canister build & deployment

##### README insights
– High-level flow: Module 1 introduces blockchain theory; Module 2 builds an ERC-20 token in Motoko; Module 3–4 implement and complete a payment channel.

a. Main components
- Course Content Layer
– Markdown modules (Module 1–4)
– images/ assets
- Code Layer (Motoko Canister Code)
– src/Main.mo
– src/Types.mo
– src/User.mo
– vendor/ (external libs)
- Deployment & Runtime
– dfx CLI & dfx.json (local emulator / build pipelines)
– Internet Computer network (IC canister host)
- Developer Environment
– Node.js/npm (package-lock.json)
– Git repo (version control)

b. Relationships & interactions
– Developer invokes dfx CLI → reads dfx.json → compiles src/**/*.mo + vendor libs → produces canister WASM blobs
→ deploys to local sandbox or IC network
– At runtime, users interact with deployed canister APIs (entrypoints defined in Main.mo) via web UI or canister calls (not explicitly in this repo but implied)
– Course modules reference source code snippets/images and guide students through editing src/ files and re-deploying.

c. Architectural patterns & principles
– Modular code separation: Types.mo for data models, User.mo for account logic, Main.mo for orchestrating token/payment-channel flows
– Configuration as code: dfx.json defines multiple canisters (token, payment channel) if extended
– Content‐code separation: pedagogical MD files are distinct from runtime codebase

d. Key technologies/frameworks
– Motoko (smart contract language)
– DFINITY Internet Computer (canister platform)
– dfx CLI (build & deploy tool)
– Node.js/npm (dependency management)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Course Content Layer"
        MD1["module-1.md"]
        MD2["module-2.md"]
        MD3["module-3.md"]
        MD4["module-4.md"]
        README["README.md"]
        IMAGES["images/"]
    end
    class MD1,MD2,MD3,MD4,README,IMAGES content

    subgraph "Code Layer"
        ORCH["src/Main.mo"]
        DATA["src/Types.mo"]
        LOGIC["src/User.mo"]
        VEND["vendor/"]
    end
    class ORCH,DATA,LOGIC,VEND code

    subgraph "Build & Deployment"
        CLI["dfx CLI"]
        CFG["dfx.json"]
    end
    class CLI,CFG tools

    subgraph "Developer Environment"
        NPM["package-lock.json"]
    end
    class NPM env

    subgraph "Runtime Environment"
        IC["Internet Computer Network / Local Sandbox"]
    end
    class IC network

    User["Student"]:::external

    User --> MD1
    User --> MD2
    User --> MD3
    User --> MD4
    User --> ORCH

    MD1 --> ORCH
    MD2 --> ORCH
    MD2 --> DATA
    MD3 --> LOGIC
    MD4 --> LOGIC

    ORCH --> CLI
    DATA --> CLI
    LOGIC --> CLI
    VEND --> CLI
    CFG --> CLI
    NPM --> CLI

    CLI --> IC

    classDef content fill:#cce5ff,stroke:#3399ff
    classDef code fill:#d4edda,stroke:#28a745
    classDef tools fill:#fff3cd,stroke:#ffcd39
    classDef env fill:#e2e3e5,stroke:#6c757d
    classDef network fill:#d6d8f9,stroke:#6f42c1
    classDef external fill:#f8d7da,stroke:#dc3545

    click MD1 "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/module-1.md"
    click MD2 "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/module-2.md"
    click MD3 "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/module-3.md"
    click MD4 "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/module-4.md"
    click README "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/README.md"
    click IMAGES "https://github.com/dfinity-education/blockchain-and-cryptocurrency/tree/main/images/"
    click ORCH "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/src/Main.mo"
    click DATA "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/src/Types.mo"
    click LOGIC "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/src/User.mo"
    click VEND "https://github.com/dfinity-education/blockchain-and-cryptocurrency/tree/main/vendor/"
    click CFG "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/dfx.json"
    click NPM "https://github.com/dfinity-education/blockchain-and-cryptocurrency/blob/main/package-lock.json"
```
