# vihanga-bandara/g9-ss architecture

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

- Interactive diagram: https://gitdiagram.com/vihanga-bandara/g9-ss
- Repository: https://github.com/vihanga-bandara/g9-ss

## Overview

Tatou is a web platform for uploading PDFs, issuing watermarked copies, and reading watermark secrets. Its main workflow runs from an authenticated browser request through Flask routes and service logic, into PDF storage and watermark processing, with results returned as PDFs or JSON. The repository also includes account flows, PDF structure exploration, a command-line watermarking interface, multiple watermark algorithms, and optional RMAP distribution. Relationships below use the shown source references and README; several route and algorithm details are indexed but not excerpted.

Main entry points: [`server/src/server.py`](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/server.py) (Flask app), [`server/src/watermarking_utils.py`](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_utils.py) (Method registry), [`server/src/watermark_service.py`](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermark_service.py) (Watermark service), [`server/src/document_service.py`](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/document_service.py) (Document service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask app<br/>[server.py]"]
  node_pages["Web pages<br/>[pages.py]"]
  node_auth_routes["Account routes<br/>[auth.py]"]
  node_doc_routes["Document routes<br/>[documents.py]"]
  node_wm_routes["Watermark routes<br/>[watermarks.py]"]
end

subgraph group_services["Domain services"]
  node_auth["Authentication<br/>[auth_service.py]"]
  node_documents["Document service"]
  node_wm_service["Watermark service"]
  node_database[("Application database<br/>[tatou.sql]")]
  node_pdf_files[("PDF storage")]
  node_errors["Service errors<br/>[service_errors.py]"]
end

subgraph group_watermark["Watermarking"]
  node_method_contract["Method contract"]
  node_wm_utils["Method registry"]
  node_dwt["DWT-SVD method<br/>[dwt_svd_v2.py]"]
  node_repeated["Repeated text method"]
  node_eof_method["EOF methods<br/>[add_after_eof.py]"]
  node_ghost["Ghost text method<br/>[ghost_text.py]"]
  node_cli["Watermark CLI"]
  node_pdf_explorer["PDF explorer"]
end

subgraph group_distribution["Distribution tools"]
  node_rmap_routes["RMAP routes<br/>[rmap_routes.py]"]
  node_rmap_client["RMAP client"]
end

node_browser(("Browser user"))

node_browser -->|"sends requests"| node_app
node_app -->|"registers pages"| node_pages
node_app -->|"registers routes"| node_auth_routes
node_app -->|"registers routes"| node_doc_routes
node_app -->|"registers routes"| node_wm_routes
node_app -->|"configures"| node_auth
node_app -->|"configures"| node_documents
node_app -->|"configures"| node_wm_service
node_app -->|"optionally registers"| node_rmap_routes
node_auth_routes -->|"calls"| node_auth
node_doc_routes -->|"calls"| node_documents
node_doc_routes -->|"checks tokens"| node_auth
node_wm_routes -->|"calls"| node_wm_service
node_auth -->|"reads and writes"| node_database
node_documents -->|"reads and writes"| node_database
node_documents -->|"stores PDFs"| node_pdf_files
node_wm_service -->|"reads and writes"| node_database
node_wm_service -->|"gets source PDF"| node_documents
node_wm_service -->|"applies methods"| node_wm_utils
node_wm_service -->|"stores versions"| node_pdf_files
node_app -->|"handles"| node_errors
node_auth -->|"raises"| node_errors
node_documents -->|"validates PDFs"| node_method_contract
node_wm_utils -->|"dispatches methods"| node_method_contract
node_wm_utils -->|"registers method"| node_dwt
node_wm_utils -->|"registers method"| node_repeated
node_wm_utils -->|"registers method"| node_eof_method
node_wm_utils -->|"registers method"| node_ghost
node_cli -->|"uses registry"| node_wm_utils
node_wm_utils -->|"provides exploration"| node_pdf_explorer
node_rmap_routes -->|"issues watermark"| node_wm_service
node_rmap_client -.->|"exchanges messages"| node_rmap_routes

click node_app "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/server.py"
click node_pages "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/pages.py"
click node_auth_routes "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/auth.py"
click node_doc_routes "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/documents.py"
click node_wm_routes "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarks.py"
click node_auth "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/auth_service.py"
click node_documents "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/document_service.py"
click node_wm_service "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermark_service.py"
click node_database "https://github.com/vihanga-bandara/g9-ss/blob/main/db/tatou.sql"
click node_errors "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/service_errors.py"
click node_method_contract "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_method.py"
click node_wm_utils "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_utils.py"
click node_dwt "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/dwt_svd_v2.py"
click node_repeated "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/TeosRepeatedWatermark.py"
click node_eof_method "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/add_after_eof.py"
click node_ghost "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/ghost_text.py"
click node_cli "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_cli.py"
click node_rmap_routes "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/rmap_routes.py"
click node_rmap_client "https://github.com/vihanga-bandara/g9-ss/tree/main/server/clients"
click node_pdf_explorer "https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_utils.py"

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_app,node_pages,node_auth_routes,node_doc_routes,node_wm_routes,node_browser toneBlue
class node_auth,node_documents,node_wm_service,node_database,node_pdf_files,node_errors toneAmber
class node_method_contract,node_wm_utils,node_dwt,node_repeated,node_eof_method,node_ghost,node_cli,node_pdf_explorer toneMint
class node_rmap_routes,node_rmap_client toneRose
```

## Components

### Web application

- [Flask app](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/server.py): `server/src/server.py`
- [Web pages](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/pages.py): `server/src/pages.py`
- [Account routes](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/auth.py): `server/src/auth.py`
- [Document routes](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/documents.py): `server/src/documents.py`
- [Watermark routes](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarks.py): `server/src/watermarks.py`

### Domain services

- [Authentication](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/auth_service.py): `server/src/auth_service.py`
- [Document service](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/document_service.py): `server/src/document_service.py`
- [Watermark service](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermark_service.py): `server/src/watermark_service.py`
- [Application database](https://github.com/vihanga-bandara/g9-ss/blob/main/db/tatou.sql): `db/tatou.sql`
- **PDF storage**
- [Service errors](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/service_errors.py): `server/src/service_errors.py`

### Watermarking

- [Method contract](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_method.py): `server/src/watermarking_method.py`
- [Method registry](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_utils.py): `server/src/watermarking_utils.py`
- [DWT-SVD method](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/dwt_svd_v2.py): `server/src/dwt_svd_v2.py`
- [Repeated text method](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/TeosRepeatedWatermark.py): `server/src/TeosRepeatedWatermark.py`
- [EOF methods](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/add_after_eof.py): `server/src/add_after_eof.py`
- [Ghost text method](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/ghost_text.py): `server/src/ghost_text.py`
- [Watermark CLI](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_cli.py): `server/src/watermarking_cli.py`
- [PDF explorer](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/watermarking_utils.py): `server/src/watermarking_utils.py`

### Distribution tools

- [RMAP routes](https://github.com/vihanga-bandara/g9-ss/blob/main/server/src/rmap_routes.py): `server/src/rmap_routes.py`
- [RMAP client](https://github.com/vihanga-bandara/g9-ss/tree/main/server/clients): `server/clients`

### Other components

- **Browser user**

## Connections

- Browser user → Flask app: sends requests (evidence: `README.md`)
- Flask app → Web pages: registers pages (evidence: `server/src/server.py`)
- Flask app → Account routes: registers routes (evidence: `server/src/server.py`)
- Flask app → Document routes: registers routes (evidence: `server/src/server.py`)
- Flask app → Watermark routes: registers routes (evidence: `server/src/server.py`)
- Flask app → Authentication: configures (evidence: `server/src/server.py`)
- Flask app → Document service: configures (evidence: `server/src/server.py`)
- Flask app → Watermark service: configures (evidence: `server/src/server.py`)
- Flask app → RMAP routes: optionally registers (evidence: `server/src/server.py`)
- Account routes → Authentication: calls (evidence: `server/src/auth.py`)
- Document routes → Document service: calls (evidence: `server/src/documents.py`)
- Document routes → Authentication: checks tokens (evidence: `server/src/documents.py`)
- Watermark routes → Watermark service: calls (evidence: `server/src/watermarks.py`)
- Authentication → Application database: reads and writes (evidence: `server/src/auth_service.py`)
- Document service → Application database: reads and writes (evidence: `server/src/document_service.py`)
- Document service → PDF storage: stores PDFs (evidence: `server/src/document_service.py`)
- Watermark service → Application database: reads and writes (evidence: `server/src/watermark_service.py`)
- Watermark service → Document service: gets source PDF (evidence: `server/src/watermark_service.py`)
- Watermark service → Method registry: applies methods (evidence: `server/src/watermark_service.py`)
- Watermark service → PDF storage: stores versions (evidence: `server/src/watermark_service.py`)
- Flask app → Service errors: handles (evidence: `server/src/server.py`)
- Authentication → Service errors: raises (evidence: `server/src/auth_service.py`)
- Document service → Method contract: validates PDFs (evidence: `server/src/document_service.py`)
- Method registry → Method contract: dispatches methods (evidence: `server/src/watermarking_utils.py`)
- Method registry → DWT-SVD method: registers method (evidence: `server/src/watermarking_utils.py`)
- Method registry → Repeated text method: registers method (evidence: `server/src/watermarking_utils.py`)
- Method registry → EOF methods: registers method (evidence: `server/src/watermarking_utils.py`)
- Method registry → Ghost text method: registers method (evidence: `server/src/watermarking_utils.py`)
- Watermark CLI → Method registry: uses registry (evidence: `server/src/watermarking_cli.py`)
- Method registry → PDF explorer: provides exploration (evidence: `server/src/watermarking_utils.py`)
- RMAP routes → Watermark service: issues watermark (evidence: `server/src/rmap_routes.py`)
- RMAP client → RMAP routes: exchanges messages
