# youssefbakrey/web_offlinea architecture

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

- Interactive diagram: https://gitdiagram.com/youssefbakrey/web_offlinea
- Repository: https://github.com/youssefbakrey/web_offlinea

## Overview

Bartender accepts a URL through its PHP service, checks it, asks the internal Flask scraper to render it as a PDF, then redirects the user to the generated file. The Flask service also records URL history and submitted secrets, exposes logs, and provides a token-protected secrets endpoint. Database initialization seeds a secret from the flag file. The README is empty; edges below are based on the shown PHP and Python excerpts, so unsampled page behavior is not inferred.

Main entry points: [`challenge/service/bartender.php`](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/service/bartender.php) (URL gate), [`challenge/internal/app.py`](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py) (Flask API), [`challenge/service/pdfs`](https://github.com/youssefbakrey/web_offlinea/tree/main/challenge/service/pdfs) (PDF files), [`challenge/internal/init_db.py`](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/init_db.py) (Database setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web entry"]
  node_php_gate["URL gate<br/>[bartender.php]"]
  node_landing["Landing page<br/>[index.html]"]
end

subgraph group_scraping["Scrape service"]
  node_flask_api["Flask API<br/>[app.py]"]
  node_url_safety["URL safety checks<br/>[app.py]"]
  node_browser_render["Browser rendering<br/>[app.py]"]
  node_history_logs["History logs<br/>[app.py]"]
  node_secrets_endpoint["Secret access<br/>[app.py]"]
end

subgraph group_state["Persistent state"]
  node_database_init["Database setup<br/>[init_db.py]"]
  node_history_db[("SQLite store")]
end

subgraph group_outputs["User outputs"]
  node_pdf_files["PDF files"]
  node_log_template["Log template<br/>[bartender.html]"]
  node_rejection_pdf["Rejection PDF<br/>[no_way.pdf]"]
end

node_visitor(("Visitor"))

node_visitor -->|"submits URL"| node_php_gate
node_visitor -->|"opens page"| node_landing
node_php_gate -->|"requests scrape"| node_flask_api
node_php_gate -->|"redirects on failure"| node_rejection_pdf
node_php_gate -->|"redirects to result"| node_pdf_files
node_flask_api -->|"checks URL"| node_url_safety
node_flask_api -->|"renders URL"| node_browser_render
node_url_safety -->|"permits fetch"| node_browser_render
node_browser_render -->|"writes PDF"| node_pdf_files
node_browser_render -->|"records URL"| node_history_db
node_flask_api -->|"stores secret"| node_history_db
node_history_logs -->|"reads history"| node_history_db
node_history_logs -->|"renders logs"| node_log_template
node_secrets_endpoint -->|"reads secrets"| node_history_db
node_database_init -->|"creates and seeds"| node_history_db

click node_php_gate "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/service/bartender.php"
click node_landing "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/service/index.html"
click node_flask_api "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py"
click node_url_safety "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py"
click node_browser_render "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py"
click node_history_logs "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py"
click node_secrets_endpoint "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py"
click node_database_init "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/init_db.py"
click node_pdf_files "https://github.com/youssefbakrey/web_offlinea/tree/main/challenge/service/pdfs"
click node_log_template "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/templates/bartender.html"
click node_rejection_pdf "https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/service/pdfs/no_way.pdf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_php_gate,node_landing toneBlue
class node_flask_api,node_url_safety,node_browser_render,node_history_logs,node_secrets_endpoint toneAmber
class node_database_init,node_history_db toneMint
class node_pdf_files,node_log_template,node_rejection_pdf toneRose
class node_visitor toneIndigo
```

## Components

### Web entry

- [URL gate](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/service/bartender.php): `challenge/service/bartender.php`
- [Landing page](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/service/index.html): `challenge/service/index.html`

### Scrape service

- [Flask API](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py): `challenge/internal/app.py`
- [URL safety checks](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py): `challenge/internal/app.py`
- [Browser rendering](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py): `challenge/internal/app.py`
- [History logs](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py): `challenge/internal/app.py`
- [Secret access](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/app.py): `challenge/internal/app.py`

### Persistent state

- [Database setup](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/init_db.py): `challenge/internal/init_db.py`
- **SQLite store**

### User outputs

- [PDF files](https://github.com/youssefbakrey/web_offlinea/tree/main/challenge/service/pdfs): `challenge/service/pdfs`
- [Log template](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/internal/templates/bartender.html): `challenge/internal/templates/bartender.html`
- [Rejection PDF](https://github.com/youssefbakrey/web_offlinea/blob/main/challenge/service/pdfs/no_way.pdf): `challenge/service/pdfs/no_way.pdf`

### Other components

- **Visitor**

## Connections

- Visitor → URL gate: submits URL (evidence: `challenge/service/bartender.php`)
- Visitor → Landing page: opens page
- URL gate → Flask API: requests scrape (evidence: `challenge/service/bartender.php`)
- URL gate → Rejection PDF: redirects on failure (evidence: `challenge/service/bartender.php`)
- URL gate → PDF files: redirects to result (evidence: `challenge/service/bartender.php`)
- Flask API → URL safety checks: checks URL (evidence: `challenge/internal/app.py`)
- Flask API → Browser rendering: renders URL (evidence: `challenge/internal/app.py`)
- URL safety checks → Browser rendering: permits fetch (evidence: `challenge/internal/app.py`)
- Browser rendering → PDF files: writes PDF (evidence: `challenge/internal/app.py`)
- Browser rendering → SQLite store: records URL (evidence: `challenge/internal/app.py`)
- Flask API → SQLite store: stores secret (evidence: `challenge/internal/app.py`)
- History logs → SQLite store: reads history (evidence: `challenge/internal/app.py`)
- History logs → Log template: renders logs (evidence: `challenge/internal/app.py`)
- Secret access → SQLite store: reads secrets (evidence: `challenge/internal/app.py`)
- Database setup → SQLite store: creates and seeds (evidence: `challenge/internal/init_db.py`)
