# safal-gautamm/cs50p architecture

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

- Interactive diagram: https://gitdiagram.com/safal-gautamm/cs50p
- Repository: https://github.com/safal-gautamm/cs50p

## Overview

##### Project type and purpose
- This is a terminal-based, single-service CLI application (“MovieVault”) written in Python.
- It provides CRUD-like operations on an in-memory collection of movies, persisting data in a CSV file, and exposes commands via the command line.

##### Main components
a. CLI Interface & Argument Parser
- Leverages Python’s argparse to parse subcommands (e.g., add, list, view).
- Entry point: project.py.
b. Application Core (MovieManager Service)
- Encapsulates business logic: adding, listing, retrieving.
- Performs validation and error handling (defensive programming).
c. Persistence Layer
- Reads from / writes to movies.csv using Python’s csv module.
- Abstracted behind service methods (single responsibility).
d. Unit Testing Harness
- test_project.py uses pytest to exercise core service methods and CLI entry points.
e. External Libraries & Environment
- argparse (command‐line parsing)
- csv (file I/O)
- pytest (testing)

##### Component interactions & data flow
1. User invokes project.py with arguments on the CLI
↓
2. argparse dispatches to the appropriate command handler in the Application Core
↓
3. Core logic calls Persistence Layer to load or update movies.csv
↓
4. Persistence Layer performs CSV read/write, returns data structures (lists/dicts)
↓
5. Core returns results back to CLI for console output
6. Unit Tests invoke core methods & simulate CLI calls, asserting expected outputs

##### Architectural patterns and design principles
- Separation of Concerns:
– CLI parsing, business logic, and persistence are distinct modules.
- Single Responsibility:
– Each function does one thing—parsing VS data management.
- Defensive Programming:
– Input validation, try/except around file operations.
- Layered Architecture (loosely):
– Presentation (CLI) → Service (MovieManager) → Infrastructure (CSV persistence).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI Interface\n(argparse)"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        Service["MovieManager Service"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        Persistence["CSV Persistence Module\n(csv)"]:::data
        DataStore["movies.csv"]:::data
    end

    %% Testing Layer
    subgraph "Testing Layer"
        Tests["pytest Tests"]:::test
    end

    %% Documentation & Dependencies
    subgraph "Support Files"
        Doc["Documentation\nREADME.md"]:::support
        ExtDeps["External Dependencies\nrequirements.txt"]:::support
    end

    %% Connections
    CLI -->|"parse_args()"| Service
    Service -->|"load(), save()"| Persistence
    Persistence -->|"read/write"| DataStore
    Tests -->|"invoke CLI"| CLI
    Tests -->|"test core methods"| Service

    %% Legend
    subgraph Legend
        P["Presentation Layer"]:::presentation
        B["Business Logic"]:::logic
        D["Data Layer"]:::data
        T["Testing Layer"]:::test
        S["Support Files"]:::support
    end

    %% Click Events
    click CLI "https://github.com/safal-gautamm/cs50p/blob/main/Final project/project.py"
    click Service "https://github.com/safal-gautamm/cs50p/blob/main/Final project/project.py"
    click Persistence "https://github.com/safal-gautamm/cs50p/blob/main/Final project/project.py"
    click DataStore "https://github.com/safal-gautamm/cs50p/blob/main/Final project/movies.csv"
    click Tests "https://github.com/safal-gautamm/cs50p/blob/main/Final project/test_project.py"
    click ExtDeps "https://github.com/safal-gautamm/cs50p/blob/main/Final project/requirements.txt"
    click Doc "https://github.com/safal-gautamm/cs50p/blob/main/Final project/README.md"

    %% Styles
    classDef presentation fill:#D0E6FF,stroke:#555,stroke-width:1px
    classDef logic fill:#D0FFD6,stroke:#555,stroke-width:1px
    classDef data fill:#FFE4B0,stroke:#555,stroke-width:1px
    classDef test fill:#F0F0F0,stroke:#555,stroke-width:1px
    classDef support fill:#E8E8E8,stroke:#555,stroke-width:1px
```
