# semenovamar1a/test-task architecture

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

- Interactive diagram: https://gitdiagram.com/semenovamar1a/test-task
- Repository: https://github.com/semenovamar1a/test-task

## Overview

##### Project type and purpose
- This is a standalone, single‐process, console (CLI) application written in Python.
- Its purpose is to provide CRUD and search operations on a collection of books persisted in a local JSON file.

##### File structure
- Top level only:
- main.py – the single entry point; contains the program loop and dispatches user commands.
- library.json – the persisted data store in JSON format.
- README.md – documentation of functions and data structure.
- No subdirectories or external modules—this is a monolithic script.

##### README for additional insights
- Core functions live in main.py:
- save_json / load_json_or_create (persistence layer)
- add_book, remove_book, search_book, change_status (business logic)
- main loop presenting menu and parsing user input (presentation layer)
- Data model: a dict keyed by book-ID, each value holding title, author, year, status.

##### Capturing essential details
- Six user actions as separate operations in the Business Logic layer.
- Error/fallback path in Data Access: “if library.json missing → create default structure.”
- Persistence calls with method names (`load_json_or_create()`, `save_json()`).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors and Layers
    User["User (Console)"]:::user

    subgraph "Presentation Layer"
        CLI["CLI Menu"]:::presentation
        Controller["Command Controller"]:::presentation
    end

    subgraph "Business Logic Layer"
        AddBook["add_book()"]:::logic
        RemoveBook["remove_book()"]:::logic
        SearchBook["search_book()"]:::logic
        ShowBooks["show_books()"]:::logic
        ChangeStatus["change_status()"]:::logic
    end

    subgraph "Data Access Layer"
        Load["load_json_or_create()"]:::data
        Save["save_json()"]:::data
    end

    DB[(library.json)]:::datastore
    Doc["README.md"]:::doc

    %% Flows
    User -->|"select action"| CLI
    CLI -->|"dispatch command"| Controller
    Controller -->|calls| AddBook
    Controller -->|calls| RemoveBook
    Controller -->|calls| SearchBook
    Controller -->|calls| ShowBooks
    Controller -->|calls| ChangeStatus

    AddBook -->|writes/reads| Load
    AddBook -->|writes| Save
    RemoveBook -->|reads| Load
    RemoveBook -->|writes| Save
    SearchBook -->|reads| Load
    ShowBooks -->|reads| Load
    ChangeStatus -->|reads| Load
    ChangeStatus -->|writes| Save

    Load -->|loads or creates default| DB
    Save -->|persists changes| DB

    %% Documentation link
    Controller --- Doc

    %% Click Events
    click CLI "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click Controller "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click AddBook "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click RemoveBook "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click SearchBook "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click ShowBooks "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click ChangeStatus "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click Load "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click Save "https://github.com/semenovamar1a/test-task/blob/master/main.py"
    click DB "https://github.com/semenovamar1a/test-task/blob/master/library.json"
    click Doc "https://github.com/semenovamar1a/test-task/blob/master/README.md"

    %% Styles
    classDef user fill:#d4f3d4,stroke:#2e7d32,color:#2e7d32;
    classDef presentation fill:#e8f5e9,stroke:#66bb6a,color:#2e7d32;
    classDef logic fill:#e3f2fd,stroke:#42a5f5,color:#1e88e5;
    classDef data fill:#f5f5f5,stroke:#9e9e9e,color:#616161;
    classDef datastore fill:#fff3e0,stroke:#ffa726,color:#ef6c00,stroke-dasharray: 5;
    classDef doc fill:#f3e5f5,stroke:#ab47bc,color:#6a1b9a;
```
