# amoraschi/amoraschi architecture

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

- Interactive diagram: https://gitdiagram.com/amoraschi/amoraschi
- Repository: https://github.com/amoraschi/amoraschi

## Overview

##### Project Type and Purpose
- This is an open-source Node.js tool that automatically generates and updates your GitHub profile README on a schedule. It fetches data (weather, moon phase, SHA, sun events, etc.), renders charts/SVGs, and rewrites README.md accordingly.

##### File Structure Analysis
- Top level:
- .github/workflows/hourly.yml – GitHub Action scheduled to run hourly
- src/index.js – entry point (orchestrator)
- data/ – persists fetched data between runs
- old/ – legacy modules (generateChart, getMoon, updateWeather, etc.) and tests
- README.md – final output (profile)
- package.json/.lock – Node.js project config
- Pattern: a cron-driven pipeline invoking a central script which calls modular “generator” functions and writes output.

##### README Insights
- No explicit architecture section, but badges and commented sections show this is a dynamic profile readme generator.
- Relies on external data (weather APIs, astronomy APIs, GitHub metadata).

a. Main Components
- GitHub Scheduler (cron in .github/workflows/hourly.yml)
- GitHub Actions Runner (hosted VM)
- Orchestrator (src/index.js)
- Modules:
– getWeather/updateWeather.js
– getMoon.js
– generateSun.js
– generateChart.js
– generateReadme.js
– getSHA.js
- Data Store (data/ folder)
- Output Artifact (README.md + SVGs in repo)
- External Services:
– Weather API
– Astronomy API for moon/sun events
– GitHub API for commit SHA

b. Relationships and Data Flows
1. Scheduler triggers Workflow
2. Runner checks out code and runs `npm install`
3. src/index.js starts and:
- Calls each module in sequence
- Each module reads/writes data in data/
- Modules fetch from External Services
4. generateReadme.js assembles data+SVGs into README.md
5. Runner commits and pushes updated files back to GitHub repo

c. Architectural Patterns
- Pipeline/Batch pattern: a linear sequence of independent modules
- Modular design: each concern (weather, moon phase, charts) lives in its own function
- GitOps: all changes occur via commits through GitHub Actions

d. Key Technologies
- Node.js runtime
- GitHub Actions for scheduling and CI
- External REST APIs (weather, astronomy)
- Local filesystem for caching (data/)
- SVG generation libraries (in generateChart, generateSun)

## Diagram (Mermaid)

```mermaid
graph TB
    %% GitHub CI Layer
    subgraph "GitHub Actions CI"
        direction TB
        Scheduler["GitHub Scheduler"]:::compute
        Runner["GitHub Actions Runner"]:::compute
    end

    %% Orchestration Layer
    Orchestrator["Orchestrator\n(src/index.js)"]:::compute

    %% Data Generators Modules
    subgraph "Data Generators"
        direction TB
        Weather["Weather Module"]:::module
        Moon["Moon Phase Module"]:::module
        Sun["Sun Events Module"]:::module
        Chart["Chart Generation Module"]:::module
        SHA["Commit SHA Module"]:::module
    end

    %% Data Store
    DataStore[(Local Data Store)]:::data

    %% External Services
    subgraph "External Services"
        direction TB
        WeatherAPI["Weather API"]:::external
        AstroAPI["Astronomy API"]:::external
        GitHubAPI["GitHub API"]:::external
    end

    %% Output Artifact
    README["Profile README\n(README.md)"]:::output

    %% GitHub Repo for commit
    Repo["GitHub Repository"]:::external

    %% Connections
    Scheduler -->|triggers| Runner
    Runner -->|runs| Orchestrator

    Orchestrator -->|calls| Weather
    Orchestrator -->|calls| Moon
    Orchestrator -->|calls| Sun
    Orchestrator -->|calls| Chart
    Orchestrator -->|calls| SHA

    Weather -->|fetches| WeatherAPI
    Moon -->|fetches| AstroAPI
    Sun -->|fetches| AstroAPI
    Chart -->|reads data| DataStore
    SHA -->|fetches| GitHubAPI

    Weather -->|caches data| DataStore
    Moon -->|caches data| DataStore
    Sun -->|caches data| DataStore
    Chart -->|caches data| DataStore
    SHA -->|caches data| DataStore

    Orchestrator -->|assembles README| README
    Runner -->|commits & pushes| Repo

    %% Click Events
    click Scheduler "https://github.com/amoraschi/amoraschi/blob/master/.github/workflows/hourly.yml"
    click Orchestrator "https://github.com/amoraschi/amoraschi/blob/master/src/index.js"
    click Weather "https://github.com/amoraschi/amoraschi/blob/master/old/src/updateWeather.js"
    click Moon "https://github.com/amoraschi/amoraschi/blob/master/old/src/getMoon.js"
    click Sun "https://github.com/amoraschi/amoraschi/blob/master/old/src/generateSun.js"
    click Chart "https://github.com/amoraschi/amoraschi/blob/master/old/src/generateChart.js"
    click SHA "https://github.com/amoraschi/amoraschi/blob/master/old/src/getSHA.js"
    click DataStore "https://github.com/amoraschi/amoraschi/tree/master/data/"
    click README "https://github.com/amoraschi/amoraschi/blob/master/README.md"

    %% Styles
    classDef compute fill:#a8f0c6,stroke:#2c7f4e,color:#0a2f1a;
    classDef module fill:#c6e0f5,stroke:#2f5f7f,color:#102a3a;
    classDef external fill:#f5d6c6,stroke:#7f3f2f,color:#3a1a10;
    classDef data fill:#e0e0e0,stroke:#7f7f7f,color:#2a2a2a;
    classDef output fill:#ddb6f5,stroke:#6f2f7f,color:#2a102a;
```
