# lorenzodifuccia/safaribooks architecture

> Architecture diagram of the GitHub repository lorenzodifuccia/safaribooks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lorenzodifuccia/safaribooks
- Repository: https://github.com/lorenzodifuccia/safaribooks

## Overview

- User credentials → Authentication Service → Safari Books Online API
- Book ID → Book Information Retriever → Safari Books Online API
- Content Downloader → File System (for chapters, CSS, images)
- File System → EPUB Generator → Final EPUB file

- Cookie management between components
- File system access patterns

##### Technical Details to Highlight

- Python 3 environment
- External dependencies (lxml, requests)
- Cookie-based session management
- File system operations

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef critical fill:#e74c3c,stroke:#c0392b,color:white

    %% User Interface Layer
    CLI["Command Line Interface"]:::ui
    SSO["SSO Authentication Handler"]:::ui
    REG["User Registration"]:::ui

    %% Core Services
    subgraph Services
        AUTH["Authentication Service"]:::service
        BOOK["Book Information Retriever"]:::service
        DOWN["Content Downloader"]:::service
        EPUB["EPUB Generator"]:::service
    end

    %% External Systems
    API["Safari Books Online API"]:::external
    FS["File System"]:::external

    %% Storage
    COOK[("cookies.json")]:::storage
    ASSETS[("Book Assets")]:::storage
    OUTPUT[("EPUB Output")]:::storage

    %% Dependencies
    DEP["Dependencies Manager"]:::ui

    %% Relationships
    CLI --> AUTH
    CLI --> BOOK
    SSO --> AUTH
    REG --> AUTH
    AUTH --> API
    AUTH --> COOK
    BOOK --> API
    BOOK --> DOWN
    DOWN --> API
    DOWN --> ASSETS
    DOWN --> FS
    ASSETS --> EPUB
    EPUB --> OUTPUT
    OUTPUT --> FS

    %% Click events for component mapping
    click CLI "https://github.com/lorenzodifuccia/safaribooks/blob/master/safaribooks.py"
    click SSO "https://github.com/lorenzodifuccia/safaribooks/blob/master/sso_cookies.py"
    click REG "https://github.com/lorenzodifuccia/safaribooks/blob/master/register_user.py"
    click DEP "https://github.com/lorenzodifuccia/safaribooks/tree/master/Pipfile"

    %% Legend
    subgraph Legend
        UI["User Interface"]:::ui
        SRV["Services"]:::service
        EXT["External Systems"]:::external
        STR["Storage"]:::storage
    end
```
