# iseshu/movierulz architecture

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

- Interactive diagram: https://gitdiagram.com/iseshu/movierulz
- Repository: https://github.com/iseshu/movierulz

## Overview

##### Project type and purpose
- This is a lightweight, single-endpoint, serverless “Movierulz Unofficial API” written in Python.
- Purpose: Expose a REST-style HTTP interface that, upon request, scrapes movierulz website pages and returns structured JSON (search results, magnet links, quality info).

##### File structure
- Top-level files only:
- app.py – the entire HTTP handler and scraping code.
- requirements.txt – lists Python dependencies (e.g., Flask or FastAPI, requests, BeautifulSoup).
- vercel.json – deployment config for Vercel’s serverless platform.
- README.md – project overview and usage.
- Architectural hint: single serverless function running on Vercel; no internal database; relies on external website as data source; minimal “service” boundaries.

##### README for additional insights
- Confirms it’s open-sourced, lightweight, supports search, returns magnet/dood links.
- No built-in cache or persistence.
- Deployed on Vercel with zero-config serverless.

a. Client / Consumer
- Origin: browser, mobile app, other servers.
- Initiates HTTP requests (e.g., GET /search?query=…).
b. API Gateway / Edge (Vercel)
- Receives incoming HTTP request.
- Invokes the serverless function defined in app.py.
c. Serverless Function (app.py)
- HTTP framework layer (Flask, FastAPI) – parses path/params, handles routing.
- Business logic layer – constructs target movierulz URL, issues HTTP requests.
- Scraper module – uses requests + BeautifulSoup (or similar) to fetch & parse HTML.
- Response builder – extracts title, magnet links, quality, dood URLs, serializes to JSON.
d. External Data Source (movierulz.com)
- Unstable HTML pages.
- No formal API; scraper must handle layout changes.
e. (Optional) CDN / Cache – if added later for rate-limiting or performance.

##### Architectural patterns & design principles
- Serverless microservice: single responsibility, auto-scaling, pay-per-use.
- Layered design within app.py:
- Presentation (HTTP interface)
- Application (routing & orchestration)
- Integration (HTTP client to external site)
- Parsing (HTML → JSON transformation)
- Stateless: each function invocation stands alone.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Nodes
    Client["Client<br/>(Browser, App)"]:::client
    VercelEdge["Vercel Edge / API Gateway"]:::service
    movierulz["movierulz.com<br/>(External Site)"]:::external

    subgraph "Serverless Function (app.py)" 
        direction TB
        Router["Router"]:::code
        Scraper["Scraper"]:::code
        Parser["Parser"]:::code
        Responder["Responder"]:::code
    end

    subgraph "Project Files"
        direction TB
        AppFile["app.py"]:::code
        VercelConfig["vercel.json"]:::service
        Dependencies["requirements.txt"]:::code
        Documentation["README.md"]:::docs
    end

    %% Flows
    Client -->|"HTTP GET /search?query=..."| VercelEdge
    VercelEdge -->|"Invoke handler"| Router
    Router -->|"Construct URL"| Scraper
    Scraper -->|"HTTP GET HTML"| movierulz
    movierulz -->|"HTML Response"| Scraper
    Scraper -->|"Raw HTML"| Parser
    Parser -->|"Structured Data"| Responder
    Responder -->|"JSON Response"| VercelEdge
    VercelEdge -->|"HTTP 200 JSON"| Client

    %% Click Events
    click AppFile "https://github.com/iseshu/movierulz/blob/main/app.py"
    click VercelConfig "https://github.com/iseshu/movierulz/blob/main/vercel.json"
    click Dependencies "https://github.com/iseshu/movierulz/blob/main/requirements.txt"
    click Documentation "https://github.com/iseshu/movierulz/blob/main/README.md"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:1px
    classDef service fill:#bbf,stroke:#333,stroke-width:1px
    classDef code fill:#a2fca2,stroke:#333,stroke-width:1px
    classDef external fill:#ccc,stroke:#333,stroke-width:1px
    classDef docs fill:#ffe4b5,stroke:#333,stroke-width:1px
```
