# gautam-safal/movievault architecture

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

- Interactive diagram: https://gitdiagram.com/gautam-safal/movievault
- Repository: https://github.com/gautam-safal/movievault

## Overview

##### Project type and purpose
- This is a standalone CLI tool (“Movie Vault”) written in Python.
- It lets the user search, view, add, list, and remove movies by title/year via the OMDb REST API and stores a local “vault” in a binary file.

##### File structure
- Top-level files only:
- main.py (the entrypoint / CLI dispatcher)
- movies.bin (binary persistence store)
- requirement.txt (dependencies: requests, python-dotenv)
- .gitignore & README.md
- No frontend/backend split — it’s a single process, layered internally.

##### README for additional insights
- Uses `requests` to call OMDb API
- Uses `python-dotenv` to load `API_KEY` from `.env`
- Data persistence is in a single binary file (`movies.bin`)
- CLI commands correspond to operations in main.py

a. Main components
1. User (terminal)
2. CLI Command Parser (argparse or click in main.py)
3. Controller/Dispatcher (routes CLI commands to handlers)
4. Service Layer
– OMDb API Client (HTTP client via `requests`)
– Vault Manager (local storage handler for movies.bin)
5. Persistence Store (movies.bin file)
6. External OMDb API (http://www.omdbapi.com)
7. Configuration Loader (`dotenv` for API_KEY)
b. Relationships & interactions
- User → CLI Parser → Controller
- Controller → Service Layer
- OMDb API Client ↔ External OMDb API
- Vault Manager ↔ movies.bin
- Service Layer uses Configuration Loader to fetch API_KEY
- Controller sends output back to User
c. Architectural patterns & principles
- Layered architecture (Presentation → Controller → Services → Persistence)
- Single-process, synchronous I/O
- Separation of concerns: CLI parsing, API integration, storage
d. Key technologies
- Python 3.7+
- requests (HTTP client)
- python-dotenv (environment variable loader)
- binary file I/O (pickle or custom serialization)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Actors and external
    User((User)):::user

    %% Internal modules
    CLIParser["CLI Command Parser"]:::internal
    Controller["Controller/Dispatcher"]:::internal
    ConfigLoader["Configuration Loader"]:::config
    OMDbClient["OMDb API Client"]:::internal
    VaultManager["Vault Manager"]:::internal

    %% Storage and external services
    MoviesBin[(movies.bin)]:::storage
    ExternalAPI((External OMDb API)):::external

    %% Flow
    User -->|"CLI input"| CLIParser
    CLIParser -->|"parseCommands()"| Controller

    Controller -->|"get API_KEY"| ConfigLoader
    ConfigLoader --> Controller

    Controller -->|"searchMovie(), viewMovie() etc"| OMDbClient
    OMDbClient -->|"HTTP request/response"| ExternalAPI

    Controller -->|"addMovie(), listMovies(), removeMovie() etc"| VaultManager
    VaultManager -->|"read/write"| MoviesBin

    Controller -->|"output results"| User

    %% Click Events
    click CLIParser "https://github.com/gautam-safal/movievault/blob/main/main.py"
    click Controller "https://github.com/gautam-safal/movievault/blob/main/main.py"
    click ConfigLoader "https://github.com/gautam-safal/movievault/blob/main/main.py"
    click OMDbClient "https://github.com/gautam-safal/movievault/blob/main/main.py"
    click VaultManager "https://github.com/gautam-safal/movievault/blob/main/main.py"
    click MoviesBin "https://github.com/gautam-safal/movievault/blob/main/movies.bin"

    %% Styles
    classDef internal fill:#add8e6,stroke:#000,stroke-width:1px
    classDef external fill:#90ee90,stroke:#000,stroke-width:1px
    classDef storage fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef config fill:#ffe4b5,stroke:#000,stroke-width:1px
    classDef user fill:#ffa500,stroke:#000,stroke-width:1px
```
