# win3zz/e-newspaper-cms architecture

> Architecture diagram of the GitHub repository win3zz/e-newspaper-cms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/win3zz/e-newspaper-cms
- Repository: https://github.com/win3zz/e-newspaper-cms

## Overview

##### Project Type and Purpose
- Type: A lightweight, single-server PHP-based CMS.
- Purpose: Allow website owners to upload daily newspaper PDFs and serve them to end-users, with a simple MD5-protected admin login.

##### Main Components
a. Client (Web Browser)
- End-user interface for downloading PDFs.
- Administrator interface for login and file upload.
b. Web Server (LAMP stack)
- Apache or Nginx + PHP.
- Serves static assets (HTML/CSS/JS) and executes PHP scripts.
c. PHP Application
- index.html (public front end listing PDFs).
- login.php (authenticates admin via MD5-hashed password).
- admin.php (CRUD interface to MySQL and file upload).
d. File Storage
- uploads/ directory on the server filesystem.
- Stores PDF files (e.g., win.pdf).
e. Database (MySQL)
- Single table `epaper(id, name)`.
- Tracks metadata (filename, display name) for each upload.

##### Component Interactions
- Users → HTTP GET → Web Server → index.html → HTTP fetch CSS/JS → display list of PDFs (links to /uploads/*.pdf).
- Admin → HTTP GET login.php → submits credentials → login.php verifies against MD5 hash → on success, HTTP redirect → admin.php.
- Admin (on admin.php) → submits new PDF → admin.php writes file to uploads/ and inserts a record into `epaper` table.
- Web Server → PHP MySQLi/PDO extension → Create/Read operations on `epaper` table.

##### Architectural Patterns & Design Principles
- Monolithic architecture on a single server.
- Clear separation between static assets (CSS/JS) and dynamic scripts (PHP).
- Simple authentication layer using MD5 hashing (note: MD5 is deprecated in real production).
- File-based storage for large binary objects (PDFs), relational DB for metadata.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Browser["Web Browser\n(Users/Admin)"]:::client

    %% Web Server Boundary
    subgraph "Web Server (Apache + PHP)"
        direction TB
        subgraph "Static Assets"
            direction TB
            Index["index.html"]:::static
            CSS["css/"]:::static
            JS["js/"]:::static
            Fonts["fonts/"]:::static
        end
        subgraph "Dynamic Scripts"
            direction TB
            Login["login.php\n(MD5 Hash Check)"]:::dynamic
            Admin["admin.php"]:::dynamic
        end
    end

    %% Data Stores
    DB["MySQL Database\nepaper table"]:::db
    Storage["File Storage\n/uploads"]:::storage

    %% Connections
    Browser -->|"HTTP GET / POST"| Index
    Browser -->|"HTTP GET / POST"| Login
    Browser -->|"HTTP GET / POST"| Admin

    Index -->|"SQL SELECT epaper"| DB
    Login -->|"Auth Query"| DB
    Admin -->|"SQL INSERT/SELECT"| DB

    Admin -->|"FS write (upload)"| Storage
    Index -->|"FS read (PDF links)"| Storage

    %% Click Events
    click Index "https://github.com/win3zz/e-newspaper-cms/blob/master/index.html"
    click Login "https://github.com/win3zz/e-newspaper-cms/blob/master/login.php"
    click Admin "https://github.com/win3zz/e-newspaper-cms/blob/master/admin.php"
    click CSS "https://github.com/win3zz/e-newspaper-cms/tree/master/css/"
    click JS "https://github.com/win3zz/e-newspaper-cms/tree/master/js/"
    click Fonts "https://github.com/win3zz/e-newspaper-cms/tree/master/fonts/"
    click Storage "https://github.com/win3zz/e-newspaper-cms/tree/master/uploads/"

    %% Styles
    classDef client fill:#CCCCCC,stroke:#333,stroke-width:1px
    classDef static fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef dynamic fill:#87CEEB,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#333,stroke-width:1px
```
