# ghovmand/nfoupdater architecture

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

- Interactive diagram: https://gitdiagram.com/ghovmand/nfoupdater
- Repository: https://github.com/ghovmand/nfoupdater

## Overview

##### Main Components

a) Input/Output Components:
- Movie Collection Directory (Input)
- NFO Files (Input/Output)
- Image Files (Output)

b) Processing Components:
- NFO File Parser
- TMDB API Client
- Image Downloader
- NFO File Updater

c) External Services:
- TMDB API Service

**[File System Layer]**

- Movie Collection Directory
- Movie Directory 1
- NFO File
- Movie File
- Poster Image
- Fanart Image
- Movie Directory N

**[Application Layer]**

- NFO Parser (xml2js)
- Movie Metadata Extractor

- TMDB Client (moviedb)
- API Key Configuration

- File Operations
- Directory Scanner (glob)
- Image Downloader
- NFO File Writer

**[External Service Layer]**

- TMDB API

##### Design Elements

Use the following visual elements:
- Blue rectangles for file system components
- Green rectangles for application components
- Yellow rectangles for external services

##### Notes for Implementation

- The sequential nature of the operations
- The dependency on external services
- The file system interaction patterns
- The transformation of data from NFO files through TMDB lookup to updated files

- Text labels
- Grouping of related components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef filesystem fill:#b3d9ff,stroke:#333
    classDef application fill:#90EE90,stroke:#333
    classDef external fill:#ffeb99,stroke:#333
    classDef error fill:#ffcccc,stroke:#333

    %% File System Layer
    subgraph FileSystem[File System Layer]
        MovieCollection[Movie Collection Directory]
        MovieDir1[Movie Directory 1]
        MovieDirN[Movie Directory N]
        NFOFile[NFO File]
        MovieFile[Movie File]
        PosterImage[Poster Image]
        FanartImage[Fanart Image]
    end

    %% Application Layer
    subgraph AppLayer[Application Layer]
        MainApp["Main Application"]:::application
        NFOParser["NFO Parser (xml2js)"]:::application
        TMDBClient["TMDB Client"]:::application
        FileOps["File Operations"]:::application
        ImageDownloader["Image Downloader"]:::application
        NFOWriter["NFO File Writer"]:::application
        DirScanner["Directory Scanner"]:::application
        Config["Configuration"]:::application
    end

    %% External Service Layer
    subgraph ExternalLayer[External Service Layer]
        TMDBAPI["TMDB API"]:::external
    end

    %% Relationships
    MovieCollection --> MovieDir1
    MovieCollection --> MovieDirN
    MovieDir1 --> NFOFile
    MovieDir1 --> MovieFile
    MovieDir1 --> PosterImage
    MovieDir1 --> FanartImage

    MainApp --> NFOParser
    MainApp --> TMDBClient
    MainApp --> FileOps
    FileOps --> ImageDownloader
    FileOps --> NFOWriter
    FileOps --> DirScanner
    TMDBClient --> Config
    TMDBClient -.-> TMDBAPI

    %% Error paths
    ErrorHandler["Error Handler"]:::error
    MainApp -.-> ErrorHandler

    %% Click events
    click MainApp "https://github.com/ghovmand/nfoupdater/blob/master/app.js"
    click Config "https://github.com/ghovmand/nfoupdater/blob/master/package.json"

    %% Legend
    subgraph Legend
        L1["File System Component"]:::filesystem
        L2["Application Component"]:::application
        L3["External Service"]:::external
        L4["Error Handler"]:::error
    end

    %% Class assignments
    class MovieCollection,MovieDir1,MovieDirN,NFOFile,MovieFile,PosterImage,FanartImage filesystem
```
