# zakariaaitali/leetcode-solutions architecture

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

- Interactive diagram: https://gitdiagram.com/zakariaaitali/leetcode-solutions
- Repository: https://github.com/zakariaaitali/leetcode-solutions

## Overview

##### Project type and purpose
- This is primarily an **open-source tooling and content repository** for organizing and publishing LeetCode solutions.
- It contains:
- A collection of solved problem modules (organized by difficulty).
- Two Python utility scripts (`create_solution_folder.py`, `update_readme.py`) that automate folder creation and README updates.
- Standard repo artifacts (`.gitignore`, `LICENSE`, `README.md`).

##### File structure
- Top-level:
- `easy/`, `medium/`, `hard/`: each subfolder holds one solved problem in its own directory (problem README + solution).
- `scripts/`: holds automation scripts.
- `README.md`: project overview and a dynamic table of solved problems.
- `.gitignore`, `LICENSE`: standard repo config.
- The presence of the `scripts` folder indicates a small automation layer that interacts with the file tree and documentation.

##### README for additional insights
- The README describes:
- Directory structure by difficulty level.
- A Solutions Table in Markdown, mapping problem IDs to solution file paths.
- Notes on languages (Python) and future expansion.
- It implies a workflow: as more problems are solved, the scripts will be used to:
1. Create a new problem folder (`create_solution_folder.py`).
2. Update the central table in `README.md` (`update_readme.py`).

##### Main components
a. **Developer** (actor)
- Interacts with the local file system and runs scripts.
b. **File System / Git Repository** (central data store)
- Holds solution directories, `README.md`, scripts, and configuration.
c. **Scripts** (automation layer)
- `create_solution_folder.py`: scaffolds a new problem folder structure based on input (problem ID, title, difficulty).
- `update_readme.py`: parses existing directories and regenerates the Solutions Table in `README.md`.
d. **Documentation** (`README.md`)
- Serves as the presentation layer for the repository.
e. **External Systems**
- (Optional) Git hosting service (GitHub) for collaboration and version control.
- (Optional) CI/CD pipeline if future automation is added.

##### Relationships and interactions
- **Developer → Scripts**: runs commands to scaffold new solution or regenerate the README table.
- **Scripts → File System**: create folders and files, and rewrite `README.md`.
- **File System → Documentation**: solution folders feed into the dynamic table.
- **Git**: tracks all changes (commits/pushes).

##### Architectural patterns and design principles
- **Separation of Concerns**:
- Solutions (content) are separate from automation logic (scripts) and documentation (`README.md`).
- **Convention over Configuration**:
- Uniform naming conventions (lowercase, kebab-case) drive script behavior.
- **Automation-first Workflow**:
- All repetitive tasks (folder creation, table updates) delegated to scripts.

##### Detailed call-outs (optional)
- Naming convention rule (lowercase, dashes) as a design constraint.
- Where future enhancements (e.g., adding more languages or CI hooks) could slot in as additional components.

##### Final advice
- **all top-level directories** and **scripts** distinctly.
- How **README.md** is both a consumer and product of the automation layer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors
    Developer["Developer"]:::external

    %% Automation Layer
    subgraph "Automation Layer"
        direction TB
        Create["create_solution_folder.py"]:::automation
        Update["update_readme.py"]:::automation
    end

    %% File System / Repository
    subgraph "Git Repository" 
        direction TB
        Repository[(Git Repo Storage)]:::storage

        subgraph "Solutions (Content Repository)" 
            direction TB
            subgraph "easy/"
                direction TB
                Easy3392["3392-count-subarrays-of-length-three-with-a-condition"]:::content
                Easy3392Sol["solution.py"]:::content
                Easy3392Read["README.md"]:::doc
            end
            subgraph "medium/"
                direction TB
                Med2962["2962-count-subarrays-where-max-element-appears-at-least-k-times"]:::content
                Med2962Sol["solution.py"]:::content
                Med2962Read["README.md"]:::doc
            end
            subgraph "hard/"
                direction TB
                Hard2302["2302-count-subarrays-with-score-less-than-k"]:::content
                Hard2302Sol["solution.py"]:::content
                Hard2302Read["README.md"]:::doc
            end
        end

        subgraph "Documentation"
            direction TB
            MainRead["README.md"]:::doc
        end

        subgraph "Config Files"
            direction TB
            Gitignore[".gitignore"]:::config
            License["LICENSE"]:::config
        end
    end

    %% External Git Host
    GitHost[(Git Hosting Service)]:::external

    %% Relationships
    Developer -->|"runs scaffold"| Create
    Developer -->|"runs update"| Update
    Create -->|"writes folders/files"| Repository
    Update -->|"regenerates table"| MainRead
    Repository -->|"contains content & docs"| MainRead
    Developer -->|"commit & push/pull"| GitHost

    %% Click Events
    click Create "https://github.com/zakariaaitali/leetcode-solutions/blob/main/scripts/create_solution_folder.py"
    click Update "https://github.com/zakariaaitali/leetcode-solutions/blob/main/scripts/update_readme.py"
    click MainRead "https://github.com/zakariaaitali/leetcode-solutions/blob/main/README.md"
    click Easy3392Read "https://github.com/zakariaaitali/leetcode-solutions/blob/main/easy/3392-count-subarrays-of-length-three-with-a-condition/README.md"
    click Med2962Read "https://github.com/zakariaaitali/leetcode-solutions/blob/main/medium/2962-count-subarrays-where-max-element-appears-at-least-k-times/README.md"
    click Hard2302Read "https://github.com/zakariaaitali/leetcode-solutions/blob/main/hard/2302-count-subarrays-with-score-less-than-k/README.md"
    click Easy3392Sol "https://github.com/zakariaaitali/leetcode-solutions/blob/main/easy/3392-count-subarrays-of-length-three-with-a-condition/solution.py"
    click Med2962Sol "https://github.com/zakariaaitali/leetcode-solutions/blob/main/medium/2962-count-subarrays-where-max-element-appears-at-least-k-times/solution.py"
    click Hard2302Sol "https://github.com/zakariaaitali/leetcode-solutions/blob/main/hard/2302-count-subarrays-with-score-less-than-k/solution.py"
    click Gitignore "https://github.com/zakariaaitali/leetcode-solutions/blob/main/.gitignore"
    click License "https://github.com/zakariaaitali/leetcode-solutions/tree/main/LICENSE"

    %% Styles
    classDef automation fill:#f9f,stroke:#333,stroke-width:1px
    classDef content fill:#9f9,stroke:#333,stroke-width:1px
    classDef doc fill:#ff9,stroke:#333,stroke-width:1px
    classDef config fill:#ccc,stroke:#333,stroke-width:1px
    classDef external fill:#cff,stroke:#333,stroke-width:1px
    classDef storage fill:#ccf,stroke:#333,stroke-width:1px
```
