# stephen-sim/typinggame architecture

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

- Interactive diagram: https://gitdiagram.com/stephen-sim/typinggame
- Repository: https://github.com/stephen-sim/typinggame

## Overview

##### Project Type and Purpose
- This is a two-component full-stack desktop/web solution:
- TypingGameAPI: an ASP.NET Core Web API that scrapes online articles (using HTMLAgilityPack) and exposes endpoints to retrieve sentences for the typing test.
- TypingGameApp: a .NET 6 WinForms desktop application that presents the UI (Start Menu, Game Panel, Complete Panel), calls the Web API to fetch text, measures WPM, and displays results.

##### File-Structure Analysis
- Top-level folders:
- TypingGameAPI (with TypingGameAPI.sln)
– Controllers (TypeGameController.cs)
– Models (Article.cs)
– Program.cs (ASP.NET Core host)
– appsettings.json / Development
- TypingGameApp (with TypingGameApp.sln)
– Forms (StartMenuForm, GameForm, CompleteTypeForm)
– Models (Article.cs)
– Services (ArticleService.cs – handles HTTP calls to API)
– Program.cs (WinForms host)
- No database; external dependency is the Dissent Magazine website.

##### Key README Insights
- Architecture: client–server: WinForms UI ←→ Web API ←→ external website.
- Stack: ASP.NET Core Web API, HTMLAgilityPack, .NET WinForms.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% WinForms Client Layer
    subgraph "WinForms App" 
        direction TB
        SLAPP["TypingGameApp.sln"]:::client
        SM["StartMenuForm"]:::client
        GF["GameForm"]:::client
        CF["CompleteTypeForm"]:::client
        BF["BaseForm"]:::client
        AS["ArticleService"]:::client
    end

    %% Backend API Layer
    subgraph "Web API" 
        direction TB
        SLAPI["TypingGameAPI.sln"]:::backend
        AProg["Program.cs"]:::backend
        ASet["appsettings.json"]:::backend
        ADev["appsettings.Development.json"]:::backend
        ALaunch["launchSettings.json"]:::backend
        TC["TypeGameController"]:::backend
        SMod["Scraper Module\n(HTMLAgilityPack)"]:::backend
        AM["Article Model"]:::backend
    end

    %% External Source
    DM["Dissent Magazine\nWebsite"]:::external

    %% Data Flows
    User(("User")):::client
    User --> SM
    SM --> AS
    AS -->|"GET /api/typing"| TC
    TC -->|"calls Scraper"| SMod
    SMod -->|"HTTP GET"| DM
    DM -->|"HTML"| SMod
    SMod -->|"parsed sentences"| AM
    AM --> TC
    TC -->|"returns JSON"| AS
    AS --> GF
    GF --> CF
    CF -->|"displays WPM"| User

    %% Click Events
    click SLAPP "https://github.com/stephen-sim/typinggame/blob/master/TypingGameApp/TypingGameApp.sln"
    click SM "https://github.com/stephen-sim/typinggame/blob/master/TypingGameApp/TypingGameApp/Forms/StartMenuForm.cs"
    click GF "https://github.com/stephen-sim/typinggame/blob/master/TypingGameApp/TypingGameApp/Forms/GameForm.cs"
    click CF "https://github.com/stephen-sim/typinggame/blob/master/TypingGameApp/TypingGameApp/Forms/CompleteTypeForm.cs"
    click BF "https://github.com/stephen-sim/typinggame/blob/master/TypingGameApp/TypingGameApp/Forms/BaseForm.cs"
    click AS "https://github.com/stephen-sim/typinggame/blob/master/TypingGameApp/TypingGameApp/Services/ArticleService.cs"
    click SLAPI "https://github.com/stephen-sim/typinggame/blob/master/TypingGameAPI/TypingGameAPI.sln"
    click TC "https://github.com/stephen-sim/typinggame/blob/master/TypingGameAPI/TypingGameAPI/Controllers/TypeGameController.cs"
    click AM "https://github.com/stephen-sim/typinggame/blob/master/TypingGameAPI/TypingGameAPI/Models/Article.cs"
    click AProg "https://github.com/stephen-sim/typinggame/blob/master/TypingGameAPI/TypingGameAPI/Program.cs"
    click ASet "https://github.com/stephen-sim/typinggame/blob/master/TypingGameAPI/TypingGameAPI/appsettings.json"
    click ADev "https://github.com/stephen-sim/typinggame/blob/master/TypingGameAPI/TypingGameAPI/appsettings.Development.json"
    click ALaunch "https://github.com/stephen-sim/typinggame/blob/master/TypingGameAPI/TypingGameAPI/Properties/launchSettings.json"

    %% Styles
    classDef client fill:#D0E6FF,stroke:#000,stroke-width:1px
    classDef backend fill:#D0FFD8,stroke:#000,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#000,stroke-width:1px
```
