# jichao99/check-keywords architecture

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

- Interactive diagram: https://gitdiagram.com/jichao99/check-keywords
- Repository: https://github.com/jichao99/check-keywords

## Overview

##### Main Components
- API Gateway (CheckKeywordsGateway): This project holds the controllers (e.g., CheckController.cs) and is responsible for handling HTTP requests, configuration (via Startup.cs and appsettings.json), and integrating middleware (like Swagger/OpenAPI support) for API documentation.
- Mobile Clients (CheckKeywordsMobile): This solution contains multiple platform-specific projects including Android, iOS, Windows, macOS, and also a Blazor web project packaged under CheckKeywordsMobile. Each sub-project (like CheckKeywordsMobile.Android, CheckKeywordsMobile.iOS, etc.) represents a native viewer that communicates with the API.
- Shared Library (CheckKeywords/Shared): This library defines the core business logic, models (such as CheckResult, KeyWords, LanguageWordsItem), handlers (e.g., CheckKeywordsHandler, JsonHandler, OpenAPIHandler, etc.), and data files (keywords.json). This abstraction is used both by the backend and potentially by other consumers.
- External Clients: For command line interaction (using curl or Powershell) that call the exposed REST endpoints directly.

##### Relationships and Interactions
- All client applications (Blazor web UI, mobile clients, and CLI tools) send HTTP requests to the API Gateway.
- The API Gateway routes these requests to the proper controller action where business logic is executed—often relying on the Shared library for processing the keyword check.
- The Shared library encapsulates the domain logic (keyword checking, file‑based configurations from keywords.json, etc.) and is used throughout the project.
- Mobile and web clients render results returned via the API.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The solution is clearly split into UI (web/mobile), service (gateway/API), and business logic (shared library).
- Multi-platform / Cross-client design: Different client projects (Blazor, Android, iOS, Windows, macOS) are built and deployed according to target platforms, but they all leverage the same backend REST API.
- RESTful communication: The API Gateway exposes RESTful endpoints that are consumed by various clients.
- Testing: Separate test projects are present (under CheckKeywords/Test) to validate functionality, suggesting an emphasis on test-driven development.

##### Key Technologies, Frameworks, and Libraries
- .NET/ASP.NET Core: Used for the API Gateway and Shared library with controllers and startup configuration.
- Blazor: For building interactive web UIs.
- Mobile Frameworks: Likely Xamarin or MAUI style components for Android, iOS, Windows, and macOS projects.
- JSON processing: The system is migrating to use System.Text.Json.
- Swagger/OpenAPI: For API documentation and client generation integration.
- Testing frameworks: Likely NUnit or xUnit for handling the tests located in the Test project directories.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Clients
    External["CLI / REST Clients"]:::external

    %% API Gateway
    subgraph "API Gateway (CheckKeywordsGateway)"
        A1["CheckController.cs"]:::gateway
        A2["Startup.cs"]:::gateway
        A3["Program.cs"]:::gateway
        A4["appsettings.json"]:::gateway
    end

    %% Web Frontend
    subgraph "Web Frontend (CheckKeywordsBlazor)"
        B1["App.razor"]:::frontend
        B2["Index.razor"]:::frontend
        B3["Index.razor.cs"]:::frontend
        B4["MainLayout.razor"]:::frontend
        B5["NavMenu.razor"]:::frontend
        B6["Program.cs"]:::frontend
    end

    %% Mobile Clients
    subgraph "Mobile Clients (CheckKeywordsMobile)"
        C1["Android"]:::mobile
        C2["iOS"]:::mobile
        C3["Windows"]:::mobile
        C4["macOS"]:::mobile
        C5["WebUI"]:::mobile
    end

    %% Shared Library
    subgraph "Shared Library (CheckKeywords/Shared)"
        D1["CheckKeywords.cs"]:::shared
        D2["CheckKeywordsFactory.cs"]:::shared
        D3["CheckKeywordsHandler.cs"]:::shared
        D4["JsonHandler.cs"]:::shared
        D5["OpenAPIHandler.cs"]:::shared
        D6["SwaggerHandler.cs"]:::shared
        D7["WordsHandler.cs"]:::shared
        D8["CheckResult.cs"]:::shared
        D9["KeyWords.cs"]:::shared
        D10["LanguageWordsItem.cs"]:::shared
        D11["keywords.json"]:::shared
    end

    %% Testing Components
    subgraph "Testing Components (CheckKeywords/Test)"
        E1["CheckKeywordsHandlerTests"]:::testing
        E2["CheckKeywordsTests"]:::testing
        E3["JsonHandlerTests"]:::testing
    end

    %% Connections (HTTP Requests)
    External -->|"HTTP"| A1
    B1 -->|"HTTP"| A1
    C1 -->|"HTTP"| A1

    %% API Gateway using Shared Business Logic
    A1 -->|"uses"| D1

    %% Testing relations (validating functionality)
    E1 ---|"tests"| A1
    E2 ---|"tests"| D1

    %% Click Events for API Gateway
    click A1 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsGateway/Controllers/CheckController.cs"
    click A2 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsGateway/Startup.cs"
    click A3 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsGateway/Program.cs"
    click A4 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsGateway/appsettings.json"

    %% Click Events for Web Frontend
    click B1 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsBlazor/App.razor"
    click B2 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsBlazor/Pages/Index.razor"
    click B3 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsBlazor/Pages/Index.razor.cs"
    click B4 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsBlazor/Shared/MainLayout.razor"
    click B5 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsBlazor/Shared/NavMenu.razor"
    click B6 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/CheckKeywordsBlazor/Program.cs"

    %% Click Events for Mobile Clients
    click C1 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywordsMobile/CheckKeywordsMobile.Android"
    click C2 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywordsMobile/CheckKeywordsMobile.iOS"
    click C3 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywordsMobile/CheckKeywordsMobile.Windows"
    click C4 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywordsMobile/CheckKeywordsMobile.macOS"
    click C5 "https://github.com/jichao99/check-keywords/tree/master/CheckKeywordsMobile/CheckKeywordsMobile/WebUI"

    %% Click Events for Shared Library
    click D1 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/CheckKeywords.cs"
    click D2 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/CheckKeywordsFactory.cs"
    click D3 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/Handlers/CheckKeywordsHandler.cs"
    click D4 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/Handlers/JsonHandler.cs"
    click D5 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/Handlers/OpenAPIHandler.cs"
    click D6 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/Handlers/SwaggerHandler.cs"
    click D7 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/Handlers/WordsHandler.cs"
    click D8 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/Models/CheckResult.cs"
    click D9 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/Models/KeyWords.cs"
    click D10 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/Models/LanguageWordsItem.cs"
    click D11 "https://github.com/jichao99/check-keywords/blob/master/CheckKeywords/Shared/keywords.json"

    %% Click Events for Testing Components
    click E1 "https://github.com/jichao99/check-keywords/tree/master/CheckKeywords/Test/CheckKeywordsHandlerTests"
    click E2 "https://github.com/jichao99/check-keywords/tree/master/CheckKeywords/Test/CheckKeywordsTests"
    click E3 "https://github.com/jichao99/check-keywords/tree/master/CheckKeywords/Test/JsonHandlerTests"

    %% Styles
    classDef gateway fill:#ffe6f0,stroke:#cc0066,stroke-width:2px;
    classDef frontend fill:#e6f0ff,stroke:#0033cc,stroke-width:2px;
    classDef mobile fill:#e6ffe6,stroke:#339900,stroke-width:2px;
    classDef shared fill:#fff5cc,stroke:#cc9900,stroke-width:2px;
    classDef testing fill:#ffe6cc,stroke:#ff6600,stroke-width:2px;
    classDef external fill:#f2f2f2,stroke:#666666,stroke-width:2px;
```
