# rage/java-programming architecture

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

- Interactive diagram: https://gitdiagram.com/rage/java-programming
- Repository: https://github.com/rage/java-programming

## Overview

##### Project Type & Purpose
- This is a **static site generator** project built with **Gatsby (React + GraphQL)**.
- It combines **course content** (Markdown files under `data/`) with **React templates/plugins** to produce a **static course website**.
- At runtime in the browser, some React components call out to **external learning-platform services** (e.g., moocfi, quiznator).

##### Core Architectural Layers
A. **Content Layer**
- Markdown & JSON in `data/` (e.g. `*.md`, `course-metadata.json`)
- Static assets in `static/` and `data/img/`
B. **Build System**
- **Gatsby Core** (`gatsby-config.js`, `gatsby-node.js`, `gatsby-ssr.js`, `gatsby-browser.js`)
- **Plugins**
- Official/third-party via `package.json`
- Custom under `plugins/gatsby-plugin-top-layout` and `plugins/gatsby-transformer-moocfi-exercises`
C. **GraphQL Schema**
- Auto-generated from filesystem, frontmatter, and transformer plugins
- Queried by page templates to fetch content and metadata
D. **Rendering Layer**
- **Templates** (`src/templates/*.js`): page layouts (e.g. CourseContentTemplate)
- **React Components** (`src/components`, `src/partials`): UI primitives & custom markdown components
- **Context Providers** (`src/contexes`): manage login state, pages, AB testing
- **Services** (`src/services/*.js`): client-side API wrappers (moocfi, quizzes, progress, etc.)
- **Utility Modules** (`src/util/*.js`)
E. **Output**
- Static HTML/CSS/JS assets in `public/` (after `npm run build`)
- Deploy via **Now/Netlify** (see `now.json`) or Docker (see `Dockerfile`)
F. **CI/CD Pipeline**
- **GitHub Actions** (`.github/workflows/main.yml`) runs lint/tests/build/deploy
- Pre-commit/style checks (`bin/check-code-style.sh`)

##### External Dependencies & Runtime Interactions
- **User’s Browser**: loads static site + client JS bundles
- **Authentication & Data APIs**:
- moocfi (login, course progress)
- crowdsorcerer, abstudio (special course features)
- quiznator, quizzes (exercise execution)
- progress (points tracking)

##### Architectural Patterns & Principles
- **Static Site Generation**: separation of build and runtime
- **Plugin Architecture**: extensible data ingestion via Gatsby plugins
- **Component-Based UI**: React + Context API for state
- **Data-Driven Pages**: Markdown + Frontmatter → GraphQL → Templates
- **Single Responsibility**: services modules wrap one external API each

## Diagram (Mermaid)

```mermaid
graph TB
  %% Content Layer
  subgraph "Content Layer"
    direction TB
    MD["data/ (Markdown & JSON)"]:::gray
    IMG["data/img/"]:::gray
    STATIC["static/"]:::gray
  end

  %% Build System
  subgraph "Build System"
    direction TB
    subgraph "Gatsby Core"
      direction TB
      GC["gatsby-config.js"]:::blue
      GN["gatsby-node.js"]:::blue
      GS["gatsby-ssr.js"]:::blue
      GB["gatsby-browser.js"]:::blue
    end
    subgraph "Plugins"
      direction TB
      P1["plugins/gatsby-plugin-top-layout"]:::blue
      P2["plugins/gatsby-transformer-moocfi-exercises"]:::blue
      P3["npm-installed plugins"]:::blue
    end
  end

  %% GraphQL Schema
  GQL["GraphQL Schema"]:::blue

  %% Rendering Layer
  subgraph "Rendering Layer"
    direction TB
    subgraph "Page Templates"
      direction TB
      T1["CourseContentTemplate.js"]:::green
      T2["CoursePartOverviewTemplate.js"]:::green
      T3["InfoPageTemplate.js"]:::green
      T4["Layout.js"]:::green
      T5["reboot.css / remark.css / theme.css"]:::green
    end
    subgraph "React Components"
      direction TB
      RC["src/components/"]:::green
    end
    subgraph "Markdown Partials"
      direction TB
      MP["src/partials/"]:::green
    end
    subgraph "Context Providers"
      direction TB
      CP["src/contexes/"]:::green
    end
    subgraph "Services"
      direction TB
      SV["src/services/"]:::green
    end
    subgraph "Utilities"
      direction TB
      UT["src/util/"]:::green
    end
    subgraph "Internationalization"
      direction TB
      I18N["src/i18n.js"]:::green
      LOCALE["src/locales/"]:::green
    end
  end

  %% Output
  OUT["public/ (Static Site Output)"]:::gray

  %% CI/CD & Deployment
  subgraph "CI/CD & Deployment"
    direction TB
    GH[".github/workflows/main.yml"]:::orange
    CS["bin/check-code-style.sh"]:::orange
    NOW["now.json"]:::orange
    DC["Dockerfile"]:::orange
    DEV["develop-loop.sh"]:::orange
  end

  %% Runtime & External
  subgraph "Runtime"
    direction TB
    BROWSER["User's Browser"]:::green
    subgraph "External Services"
      direction TB
      E1["moocfi"]:::gray
      E2["quiznator / quizzes"]:::gray
      E3["crowdsorcerer / abstudio"]:::gray
      E4["progress"]:::gray
    end
  end

  %% Connections
  MD -->|feeds content into| GC
  IMG --> GC
  STATIC --> GC
  P1 --> GC
  P2 --> GC
  P3 --> GC
  GC -->|generates| GQL
  GQL -->|queried by| T1
  GQL -->|queried by| T2
  GQL -->|queried by| T3
  T1 --> OUT
  T2 --> OUT
  T3 --> OUT
  RC --> OUT
  MP --> OUT
  CP --> OUT
  SV --> OUT
  UT --> OUT
  I18N --> OUT
  LOCALE --> OUT

  GH -->|triggers build| GC
  GH -->|deploys| NOW
  GH -->|deploys| DC
  CS --> GH
  DEV --> GC

  BROWSER -->|loads| OUT
  RC --> BROWSER
  CP --> BROWSER
  SV -->|calls| E1
  SV -->|calls| E2
  SV -->|calls| E3
  SV -->|calls| E4

  %% Click Events
  click MD "https://github.com/rage/java-programming/tree/master/data/"
  click IMG "https://github.com/rage/java-programming/tree/master/data/img/"
  click STATIC "https://github.com/rage/java-programming/tree/master/static/"
  click GC "https://github.com/rage/java-programming/blob/master/gatsby-config.js"
  click GN "https://github.com/rage/java-programming/blob/master/gatsby-node.js"
  click GS "https://github.com/rage/java-programming/blob/master/gatsby-ssr.js"
  click GB "https://github.com/rage/java-programming/blob/master/gatsby-browser.js"
  click P1 "https://github.com/rage/java-programming/tree/master/plugins/gatsby-plugin-top-layout/"
  click P2 "https://github.com/rage/java-programming/tree/master/plugins/gatsby-transformer-moocfi-exercises/"
  click T1 "https://github.com/rage/java-programming/blob/master/src/templates/CourseContentTemplate.js"
  click T2 "https://github.com/rage/java-programming/blob/master/src/templates/CoursePartOverviewTemplate.js"
  click T3 "https://github.com/rage/java-programming/blob/master/src/templates/InfoPageTemplate.js"
  click T4 "https://github.com/rage/java-programming/blob/master/src/templates/Layout.js"
  click T5 "https://github.com/rage/java-programming/blob/master/src/templates/reboot.css"
  click RC "https://github.com/rage/java-programming/tree/master/src/components/"
  click MP "https://github.com/rage/java-programming/tree/master/src/partials/"
  click CP "https://github.com/rage/java-programming/tree/master/src/contexes/"
  click SV "https://github.com/rage/java-programming/tree/master/src/services/"
  click UT "https://github.com/rage/java-programming/tree/master/src/util/"
  click I18N "https://github.com/rage/java-programming/blob/master/src/i18n.js"
  click LOCALE "https://github.com/rage/java-programming/tree/master/src/locales/"
  click GH "https://github.com/rage/java-programming/blob/master/.github/workflows/main.yml"
  click CS "https://github.com/rage/java-programming/blob/master/bin/check-code-style.sh"
  click NOW "https://github.com/rage/java-programming/blob/master/now.json"
  click DC "https://github.com/rage/java-programming/tree/master/Dockerfile"
  click DEV "https://github.com/rage/java-programming/blob/master/develop-loop.sh"

  %% Styles
  classDef blue fill:#D0E6FF,stroke:#0055AA,stroke-width:1px
  classDef green fill:#D4F5D4,stroke:#228B22,stroke-width:1px
  classDef gray fill:#F0F0F0,stroke:#808080,stroke-width:1px
  classDef orange fill:#FFE5B4,stroke:#CC6600,stroke-width:1px
```
