# knit-zhang/rust-basic architecture

> Architecture diagram of the GitHub repository knit-zhang/rust-basic, 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/knit-zhang/rust-basic
- Repository: https://github.com/knit-zhang/rust-basic

## Overview

##### Main Components
- Exercise Manager: Represent the core logic that drives the learning experience. This includes modules in the src directory such as main.rs, run.rs, verify.rs, exercise.rs, project.rs, and ui.rs. These files together form the CLI tool that navigates, executes, and tests the exercises.
- Exercises Repository: Emphasize the “exercises” folder, which is organized into subdirectories for topics (e.g., generics, hashmaps, iterators, lifetimes, macros, etc.). Each topic’s folder has its own README file and multiple exercise files (e.g., generics1.rs, hashmaps1.rs, etc.) that the exercise manager loads and verifies.
- Testing and CI Infrastructure: Include the “tests” folder that contains integration tests, fixtures for simulating various exercise states and error conditions, and the GitHub workflows (in .github/workflows) that drive CI for automatic verification. Also, note configuration files like Cargo.toml, Cargo.lock, and several CI-related files (.github/result, .github/classroom).
- Development Environment & Tooling: Identify ancillary configurations—such as the .devcontainer, .vscode, shell.nix, flake.nix, and other environment setup scripts along with docs (CHANGELOG, CONTRIBUTING, AUTHORS) that enable consistent development, local testing, and deployment across various environments (Linux, MacOS, Windows, Codespaces).

##### Out the Relationships and Data Flow
- The manager then invokes the Testing framework (via functions in verify.rs and integration tests) to check whether exercises pass. Illustrate this as a bidirectional flow between the “Exercise Runner” and the “Testing/CI Infrastructure”.
- The development environment components are “helper modules” that provide configurations for local containerized setups, editors, and shell environments.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project splits responsibilities between the CLI tool (running, verifying, providing hints) and the content (exercises organized by topic).
- Modular Structure: The src directory’s multiple modules indicate a layered design—UI, execution, verification—each with a clear role.
- Extensibility: The modular approach in the “exercises” folders fosters easy addition of new topics and exercises.
- Testing & CI: Automated testing components reinforce a test-driven flow where code changes are immediately validated via CI pipelines.

##### Relevant Technologies
- Rust language specifics: Cargo (for package management), along with Rust’s testing framework.
- Git and GitHub: Source control plus GitHub Classroom and GitHub Actions for CI.
- Containerization and development environment configuration: Use of .devcontainer and shell.nix files to standardize development.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User (CLI)"]:::external

    subgraph "Exercise Manager (CLI Core)"
      direction TB
      E1["main.rs"]:::cli
      E2["run.rs"]:::cli
      E3["verify.rs"]:::cli
      E4["exercise.rs"]:::cli
      E5["project.rs"]:::cli
      E6["ui.rs"]:::cli
    end

    ExRepo["Exercises Repository"]:::repo
    TestCI["Testing & CI Infrastructure"]:::test
    ExternalCI["External CI Environment"]:::external
    DevEnv["Development Environment & Tooling"]:::dev

    User -->|"runs"| E1
    E1 -->|"loads_exercises"| ExRepo
    E3 <-->|"verify_exercises"| TestCI
    TestCI -->|"CI_workflows"| ExternalCI
    DevEnv -->|"configs_cli"| E1
    DevEnv -->|"configs_ci"| TestCI

    click E1 "https://github.com/knit-zhang/rust-basic/blob/main/src/main.rs"
    click E2 "https://github.com/knit-zhang/rust-basic/blob/main/src/run.rs"
    click E3 "https://github.com/knit-zhang/rust-basic/blob/main/src/verify.rs"
    click E4 "https://github.com/knit-zhang/rust-basic/blob/main/src/exercise.rs"
    click E5 "https://github.com/knit-zhang/rust-basic/blob/main/src/project.rs"
    click E6 "https://github.com/knit-zhang/rust-basic/blob/main/src/ui.rs"
    click ExRepo "https://github.com/knit-zhang/rust-basic/tree/main/exercises/"
    click TestCI "https://github.com/knit-zhang/rust-basic/tree/main/tests/"
    click DevEnv "https://github.com/knit-zhang/rust-basic/tree/main/.devcontainer/"

    classDef cli fill:#abd1ff,stroke:#004488,stroke-width:2px;
    classDef repo fill:#ffe4a1,stroke:#cc8800,stroke-width:2px;
    classDef test fill:#c1f0c1,stroke:#228822,stroke-width:2px;
    classDef dev fill:#e0c3f9,stroke:#9933cc,stroke-width:2px;
    classDef external fill:#f9d4a3,stroke:#d2691e,stroke-width:2px;
```
