# alexanderthebored/mangaview architecture

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

- Interactive diagram: https://gitdiagram.com/alexanderthebored/mangaview
- Repository: https://github.com/alexanderthebored/mangaview

## Overview

##### Project type and purpose
- MangaView (“Alexandria”) is a lightweight full-stack web application for browsing, reading, and managing manga.
- Frontend: vanilla HTML/CSS/JavaScript (multiple pages + JS modules).
- Backend: Node.js + Express (currently in progress) providing static‐file serving and REST style endpoints for authentication, sessions, and future manga APIs.

##### File structure
- Top-level static assets:
- CSS/ – layout & component styles (carousel.css, header.css, etc.)
- JS/ – modular scripts (auth.js, carousel.js, reader.js, session.js)
- HTML pages: index.html, home.html, browse.html, latest.html, reader.html, login.html, signup.html, admin.html, header.html
- Server:
- server.js – Express entry point
- package.json + package-lock.json – dependencies (express, express-session, bcrypt planned)
- structure.txt – potential notes on organization
- README.md – high-level overview & roadmap

##### Key insights from README
- Static/dynamic separation: vanilla frontend + Express backend
- Planned REST APIs under `/api/manga/:id/chapter/:num` for chapter data
- Authentication (bcrypt password hashing) & session management (`express-session`)
- Data storage: currently flat JSON, migrating to SQLite or MongoDB

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Browser" 
        direction TB
        subgraph "Static Pages" 
            direction TB
            Index["index.html"]:::frontend
            Home["home.html"]:::frontend
            Browse["browse.html"]:::frontend
            Latest["latest.html"]:::frontend
            ReaderPage["reader.html"]:::frontend
            LoginPage["login.html"]:::frontend
            SignupPage["signup.html"]:::frontend
            Admin["admin.html"]:::frontend
            Header["header.html"]:::frontend
        end
        subgraph "CSS Modules" 
            direction TB
            CarouselCSS["carousel.css"]:::frontend
            HeaderCSS["header.css"]:::frontend
            LogoCSS["logo.css"]:::frontend
            StylesCSS["styles.css"]:::frontend
        end
        subgraph "JS Modules" 
            direction TB
            AuthJS["auth.js"]:::frontend
            CarouselJS["carousel.js"]:::frontend
            ReaderJS["reader.js"]:::frontend
            SessionJS["session.js"]:::frontend
        end
        LocalStorage["localStorage"]:::frontend
    end

    %% Backend Layer
    subgraph "Web Server (Node.js + Express)" 
        direction TB
        Server["server.js"]:::backend
        StaticMiddleware["Static-file Middleware"]:::backend
        subgraph "API Routes" 
            direction TB
            AuthRoutes["/login, /signup"]:::backend
            SessionMW["express-session"]:::backend
            MangaAPI["/api/manga/:id/chapter/:num"]:::backend
        end
        PackageJSON["package.json"]:::backend
        PackageLock["package-lock.json"]:::backend
    end

    %% Data Store Layer
    subgraph "Data Store" 
        direction TB
        JSONStore["Flat JSON Files"]:::datastore
        FutureDB["SQLite / MongoDB"]:::datastore
    end

    %% External Services
    subgraph "External Libraries & Services" 
        direction TB
        Bcrypt["bcrypt"]:::external
        CDN["CDN / Hosting"]:::external
    end

    %% Data Flows
    Index -->|"GET index.html"| StaticMiddleware
    Home -->|"GET home.html"| StaticMiddleware
    Browse -->|"GET browse.html"| StaticMiddleware
    Latest -->|"GET latest.html"| StaticMiddleware
    ReaderPage -->|"GET reader.html"| StaticMiddleware
    LoginPage -->|"GET login.html"| StaticMiddleware
    SignupPage -->|"GET signup.html"| StaticMiddleware
    Admin -->|"GET admin.html"| StaticMiddleware
    StaticMiddleware -->|Static Files| Index

    AuthJS -->|"POST /login, /signup"| AuthRoutes
    AuthRoutes -->|verify| Bcrypt
    AuthRoutes -->|read/write| JSONStore
    AuthRoutes -->|set cookie| SessionMW
    SessionMW -->|cookie| Index

    ReaderJS -->|"GET /api/manga/:id/chapter/:num"| MangaAPI
    MangaAPI -->|read| JSONStore
    MangaAPI -->|future read| FutureDB
    MangaAPI -->|respond JSON| ReaderJS

    SessionJS -->|store token| LocalStorage
    LocalStorage -.->|read welcome| Home

    CarouselJS -->|manipulate DOM| Home

    %% Relationships to server files
    Server --> StaticMiddleware
    Server --> AuthRoutes
    Server --> SessionMW
    Server --> MangaAPI

    Server --> PackageJSON
    Server --> PackageLock

    %% External integrations
    AuthRoutes --> Bcrypt
    SessionMW --> CDN

    %% Click Events
    click Index "https://github.com/alexanderthebored/mangaview/blob/main/index.html"
    click Home "https://github.com/alexanderthebored/mangaview/blob/main/home.html"
    click Browse "https://github.com/alexanderthebored/mangaview/blob/main/browse.html"
    click Latest "https://github.com/alexanderthebored/mangaview/blob/main/latest.html"
    click ReaderPage "https://github.com/alexanderthebored/mangaview/blob/main/reader.html"
    click LoginPage "https://github.com/alexanderthebored/mangaview/blob/main/login.html"
    click SignupPage "https://github.com/alexanderthebored/mangaview/blob/main/signup.html"
    click Admin "https://github.com/alexanderthebored/mangaview/blob/main/admin.html"
    click Header "https://github.com/alexanderthebored/mangaview/blob/main/header.html"
    click CarouselCSS "https://github.com/alexanderthebored/mangaview/blob/main/CSS/carousel.css"
    click HeaderCSS "https://github.com/alexanderthebored/mangaview/blob/main/CSS/header.css"
    click LogoCSS "https://github.com/alexanderthebored/mangaview/blob/main/CSS/logo.css"
    click StylesCSS "https://github.com/alexanderthebored/mangaview/blob/main/CSS/styles.css"
    click AuthJS "https://github.com/alexanderthebored/mangaview/blob/main/JS/auth.js"
    click CarouselJS "https://github.com/alexanderthebored/mangaview/blob/main/JS/carousel.js"
    click ReaderJS "https://github.com/alexanderthebored/mangaview/blob/main/JS/reader.js"
    click SessionJS "https://github.com/alexanderthebored/mangaview/blob/main/JS/session.js"
    click Server "https://github.com/alexanderthebored/mangaview/blob/main/server.js"
    click PackageJSON "https://github.com/alexanderthebored/mangaview/blob/main/package.json"
    click PackageLock "https://github.com/alexanderthebored/mangaview/blob/main/package-lock.json"
    click README "https://github.com/alexanderthebored/mangaview/blob/main/README.md"
    click Structure "https://github.com/alexanderthebored/mangaview/blob/main/structure.txt"
    click Assets "https://github.com/alexanderthebored/mangaview/tree/main/assets/"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#D0F5D0,stroke:#28a745,stroke-width:1px
    classDef datastore fill:#FFE4C4,stroke:#d2691e,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#666666,stroke-width:1px
```
