# advplyr/audiobookshelf architecture

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

- Interactive diagram: https://gitdiagram.com/advplyr/audiobookshelf
- Repository: https://github.com/advplyr/audiobookshelf

## Overview

##### Main Components

a. Frontend Layer:
- Vue.js/Nuxt.js based web client (/client directory)
- Progressive Web App (PWA) capabilities
- Mobile apps (Android/iOS) integration points
- Web socket connections for real-time updates

b. Backend Layer:
- Node.js server (/server directory)
- Core server components (Server.js, Auth.js, Database.js)
- Controllers for different functionalities
- Managers for specific features
- File system handlers

c. Storage Layer:
- Database storage (SQLite/embedded)
- File system storage for media files
- Backup storage system
- Cache management system

d. External Services Integration:
- Metadata providers (Audible, Google Books, etc.)
- RSS feed services
- Email services
- Chromecast integration

##### Key Relationships to Highlight

a. Data Flow:
- Client-server communication via REST API and WebSocket
- Media streaming pathways
- Metadata synchronization
- User authentication flow

b. Component Interactions:
- Library scanning and monitoring
- Media processing pipeline
- Backup and restoration processes
- Podcast feed management

##### Architectural Patterns to Emphasize

- MVC pattern in the backend structure
- Component-based architecture in the frontend
- Event-driven architecture for real-time updates
- Service-oriented architecture for external integrations

**[Client Layer]**

- Web Client (Vue.js/Nuxt.js)
- Mobile Apps
- Progressive Web App

**[API Gateway / WebSocket]**

**[Server Layer]**

- Authentication & Authorization
- Core Services
- Library Management
- Media Processing
- User Management
- Podcast Management

- Support Services
- Backup Manager
- Cache Manager
- Task Manager
- Notification Manager

**[Storage Layer]**

- Database (SQLite)
- File System
- Cache Storage

**[External Services]**
- Metadata Providers
- RSS Feeds
- Email Services
- Chromecast

##### Important Implementation Details

- Separation between the client (/client) and server (/server) codebases
- Managers (/server/managers) that handle specific functionality
- Controllers (/server/controllers) that manage API endpoints
- Model structure (/server/models) for data organization
- Providers (/server/providers) for external service integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef support fill:#e67e22,stroke:#d35400,color:white

    %% Frontend Layer
    subgraph Frontend
        WebClient["Web Client (Vue/Nuxt)"]
        Components["UI Components"]
        Pages["Pages/Routes"]
        Store["Store Management"]
        Assets["Assets"]
    end
    
    %% Backend Core
    subgraph Core
        Server["Main Server"]
        Auth["Authentication"]
        DB["Database"]
        Socket["WebSocket Authority"]
        Watcher["File Watcher"]
    end
    
    %% Controllers
    subgraph Controllers
        LibController["Library Controller"]
        UserController["User Controller"]
        MediaController["Media Controller"]
        PodController["Podcast Controller"]
    end
    
    %% Managers
    subgraph Managers
        BackupMgr["Backup Manager"]
        CacheMgr["Cache Manager"]
        EmailMgr["Email Manager"]
        NotifMgr["Notification Manager"]
        TaskMgr["Task Manager"]
        RssMgr["RSS Feed Manager"]
    end
    
    %% Storage Layer
    subgraph Storage
        SQLite["SQLite Database"]
        FileSystem["File System"]
        Cache["Cache Storage"]
    end
    
    %% External Services
    subgraph External
        MetadataProviders["Metadata Providers"]
        RSSFeeds["RSS Feeds"]
        EmailService["Email Services"]
        Chromecast["Chromecast"]
    end

    %% Relationships
    WebClient --> Socket
    Socket --> Server
    Server --> Auth
    Server --> DB
    Server --> Watcher
    
    Controllers --> Server
    Managers --> Server
    
    Server --> Storage
    
    Managers --> External

    %% Click Events
    click WebClient "https://github.com/advplyr/audiobookshelf/tree/master/client"
    click Components "https://github.com/advplyr/audiobookshelf/tree/master/client/components"
    click Pages "https://github.com/advplyr/audiobookshelf/tree/master/client/pages"
    click Store "https://github.com/advplyr/audiobookshelf/tree/master/client/store"
    click Assets "https://github.com/advplyr/audiobookshelf/tree/master/client/assets"
    
    click Server "https://github.com/advplyr/audiobookshelf/blob/master/server/Server.js"
    click Auth "https://github.com/advplyr/audiobookshelf/blob/master/server/Auth.js"
    click DB "https://github.com/advplyr/audiobookshelf/blob/master/server/Database.js"
    click Socket "https://github.com/advplyr/audiobookshelf/blob/master/server/SocketAuthority.js"
    click Watcher "https://github.com/advplyr/audiobookshelf/blob/master/server/Watcher.js"
    
    click LibController "https://github.com/advplyr/audiobookshelf/blob/master/server/controllers/LibraryController.js"
    click UserController "https://github.com/advplyr/audiobookshelf/blob/master/server/controllers/UserController.js"
    click MediaController "https://github.com/advplyr/audiobookshelf/blob/master/server/controllers/LibraryItemController.js"
    click PodController "https://github.com/advplyr/audiobookshelf/blob/master/server/controllers/PodcastController.js"
    
    click BackupMgr "https://github.com/advplyr/audiobookshelf/blob/master/server/managers/BackupManager.js"
    click CacheMgr "https://github.com/advplyr/audiobookshelf/blob/master/server/managers/CacheManager.js"
    click EmailMgr "https://github.com/advplyr/audiobookshelf/blob/master/server/managers/EmailManager.js"
    click NotifMgr "https://github.com/advplyr/audiobookshelf/blob/master/server/managers/NotificationManager.js"
    click TaskMgr "https://github.com/advplyr/audiobookshelf/blob/master/server/managers/TaskManager.js"
    click RssMgr "https://github.com/advplyr/audiobookshelf/blob/master/server/managers/RssFeedManager.js"
    
    click MetadataProviders "https://github.com/advplyr/audiobookshelf/tree/master/server/providers"
    
    %% Styling Classes
    class WebClient,Components,Pages,Store,Assets frontend
    class Server,Auth,DB,Socket,Watcher backend
    class LibController,UserController,MediaController,PodController backend
    class BackupMgr,CacheMgr,EmailMgr,NotifMgr,TaskMgr,RssMgr support
    class SQLite,FileSystem,Cache storage
    class MetadataProviders,RSSFeeds,EmailService,Chromecast external
```
