# kikihun1/mega-schematics-downloader architecture

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

- Interactive diagram: https://gitdiagram.com/kikihun1/mega-schematics-downloader
- Repository: https://github.com/kikihun1/mega-schematics-downloader

## Overview

##### Project type and purpose
- This is a single-project, desktop application built on .NET 6 using WPF (App.xaml, MainWindow.xaml).
- Its purpose is to download schematics and boardviews from a Mega.nz folder, check for updated download links or app updates via a remote server, and save files to the local filesystem.

##### File structure
- Top level:
- .github/ – issue templates
- README.md, .gitignore
- schema/schema.sln – Visual Studio solution
- schema/
- App.xaml & App.xaml.cs – WPF application entry
- MainWindow.xaml & MainWindow.xaml.cs – primary UI
- datas.cs – model classes or data definitions
- Properties/PublishProfiles – ClickOnce and folder-publish settings
- schema.csproj – .NET 6 WPF project file
- No separate frontend/backend; it’s a monolithic desktop app using the MVVM (or code-behind) pattern.

##### README for additional insights
- Describes Mega.nz downloader functionality
- Mentions an external update check against a custom server
- Points to releases page; no other components

##### Main components
a. UI Layer (WPF)
- App.xaml
- MainWindow.xaml (View) & code-behind or ViewModel
b. Business Logic Layer
- DownloadService (handles Mega.nz API calls)
- UpdateCheckService (contacts custom update server)
- Data model (datas.cs)
c. External Services
- Custom update server (could be a simple HTTP endpoint on the developer’s server)
d. Local Resources
- File System (where downloaded schematics are written)
- Configuration/Publish profiles (ClickOnce metadata, user settings)

##### Relationships and interactions
- UI triggers user actions (e.g., “Download”, “Check for update”) → calls Business Logic
- DownloadService calls Mega.nz API → streams data → writes to local filesystem
- UpdateCheckService HTTP GET → custom server → returns new download link or app version → UI displays result
- Data model classes mediate between services and UI

##### Architectural patterns and principles
- MVVM or code-behind separation: Views (XAML) ↔ ViewModels/Controllers ↔ Services ↔ External
- Dependency inversion: UI depends on abstract service interfaces (if implemented)
- Single responsibility: separate DownloadService vs. UpdateCheckService
- PublishProfiles: deployment configuration (ClickOnce vs. folder publish)

##### Relevant technologies, frameworks, libraries
- .NET 6 WPF (Windows Presentation Foundation)
- HttpClient (built-in .NET) for HTTP calls
- ClickOnce or folder publishing for deployment
- Mega.nz API (custom wrapper or direct HTTP calls)

- Clear labels on each component (e.g., “MainWindow.xaml (View)”, “DownloadService”)
- Annotations for technologies (e.g., “WPF”, “HttpClient”, “.NET 6”)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        AppXaml["App.xaml"]:::ui
        AppCode["App.xaml.cs"]:::ui
        MainViewXaml["MainWindow.xaml"]:::ui
        MainViewCode["MainWindow.xaml.cs"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic" 
        direction TB
        DownloadService["DownloadService\n(HttpClient, Mega.nz API)"]:::services
        UpdateCheckService["UpdateCheckService\n(HttpClient, Update Server)"]:::services
    end

    %% External Services
    subgraph "External Services"
        direction TB
        MegaAPI["Mega.nz API"]:::external
        UpdateServer["Custom Update Server"]:::external
    end

    %% Storage
    subgraph "Local Resources"
        direction TB
        FileSystem["Local File System"]:::storage
    end

    %% Project Files
    subgraph "Project Files"
        direction TB
        SolutionFile["schema.sln"]:::project
        ProjectFile["schema.csproj"]:::project
        PublishProfiles["Properties/PublishProfiles"]:::project
        AssemblyInfo["AssemblyInfo.cs"]:::project
        DataModels["datas.cs"]:::project
    end

    %% Connections
    MainViewXaml -->|"code-behind binding"| MainViewCode
    MainViewCode -->|"invokes"| DownloadService
    MainViewCode -->|"invokes"| UpdateCheckService
    DownloadService -->|"GET /folder"| MegaAPI
    MegaAPI -->|"stream data"| FileSystem
    UpdateCheckService -->|"GET /version"| UpdateServer
    UpdateServer -->|"version info"| MainViewCode

    AppXaml --> MainViewXaml

    %% Click Events
    click AppXaml "https://github.com/kikihun1/mega-schematics-downloader/blob/main/schema/schema/App.xaml"
    click AppCode "https://github.com/kikihun1/mega-schematics-downloader/blob/main/schema/schema/App.xaml.cs"
    click MainViewXaml "https://github.com/kikihun1/mega-schematics-downloader/blob/main/schema/schema/MainWindow.xaml"
    click MainViewCode "https://github.com/kikihun1/mega-schematics-downloader/blob/main/schema/schema/MainWindow.xaml.cs"
    click DataModels "https://github.com/kikihun1/mega-schematics-downloader/blob/main/schema/schema/datas.cs"
    click SolutionFile "https://github.com/kikihun1/mega-schematics-downloader/blob/main/schema/schema/schema.sln"
    click ProjectFile "https://github.com/kikihun1/mega-schematics-downloader/blob/main/schema/schema/schema.csproj"
    click PublishProfiles "https://github.com/kikihun1/mega-schematics-downloader/tree/main/schema/schema/Properties/PublishProfiles"
    click AssemblyInfo "https://github.com/kikihun1/mega-schematics-downloader/blob/main/schema/schema/AssemblyInfo.cs"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef services fill:#d4edda,stroke:#333,stroke-width:1px
    classDef external fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef storage fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef project fill:#e8d8f0,stroke:#333,stroke-width:1px
```
