# fahadyousafmahar/chromeurdu architecture

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

- Interactive diagram: https://gitdiagram.com/fahadyousafmahar/chromeurdu
- Repository: https://github.com/fahadyousafmahar/chromeurdu

## Overview

1. **Project purpose**
   - Chrome extension whose core job is to make Urdu text render with Nastaleeq fonts on websites.
   - The main architectural concern is not a backend or data service, but **browser-side DOM/style injection**.

2. **Extension shell**
   - `manifest.json` is the central wiring file for the Chrome Extension: it defines permissions, content scripts, assets, and any UI entry points.
   - This repo appears to be a **pure client-side extension** with no server component.

3. **Injection layer**
   - `src/inject/inject.js` is the main runtime script that likely runs inside web pages as a content script.
   - Its role is to detect page context and attach the extension’s styling or UI into the current tab.

4. **Global styling for injected pages**
   - `src/inject/inject.css` provides the base CSS used by the injected page-level experience.
   - This is likely the shared styling applied regardless of the target site.

5. **Site-specific adaptations**
   - `src/inject/google.css`, `src/inject/twitter.css`, and `src/inject/whatsapp.css` indicate special handling for specific sites.
   - Architecturally, this suggests a **per-domain override model**: common behavior plus tailored CSS fixes for major websites with different layouts and font rendering quirks.

6. **Embedded app/UI surface**
   - `src/inject/app/index.html` plus the `js`, `css`, and `img` subfolders form a small front-end app bundled into the extension.
   - This is likely the extension’s popup or injected control panel, used to toggle behavior or expose settings/help.

7. **App behavior scripts**
   - `src/inject/app/js/index.js` and `src/inject/app/js/popup.js` separate general UI logic from popup-specific behavior.
   - That separation implies two layers: a reusable app shell and a popup/controller entry point.

8. **Localization**
   - `_locales/en/messages.json` shows the extension uses Chrome’s built-in i18n mechanism.
   - This means user-facing labels/messages are externalized, enabling future translation support without changing the code structure.

9. **Static assets**
   - `icons/` contains extension icons used by Chrome in the toolbar, store listing, or installed-extension UI.
   - `src/inject/app/img/` contains images used by the embedded UI.

10. **Main data flow**
   - Chrome loads the extension from `manifest.json`.
   - On matching pages, `inject.js` runs in the page context and applies the relevant CSS.
   - For specific domains, the extension swaps in or adds the site-specific CSS file.
   - The extension UI provides user interaction, likely without needing any persistent backend state.

11. **Boundaries**
   - The key boundary is between the **browser page DOM** and the **extension’s injected assets**.
   - Another boundary is between **shared styling** and **site-specific styling**, which is important for understanding maintainability and troubleshooting rendering issues.

12. **Operational model**
   - This is a lightweight extension architecture: no API calls, no database, no build-time service dependencies visible in the tree.
   - The “system” is essentially Chrome + extension manifest + injected scripts/styles + localized UI assets.

13. **What an architecture diagram should emphasize**
   - Chrome browser as the host environment.
   - `manifest.json` as the orchestration point.
   - Content script / injected layer as the main execution path.
   - Shared CSS plus per-site CSS branches.
   - Optional extension UI/popup assets.
   - Localization and icons as supporting resources.

Main entry points: [`manifest.json`](https://github.com/fahadyousafmahar/chromeurdu/blob/master/manifest.json) (Manifest), [`src/inject/inject.js`](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/inject.js) (Inject script), [`src/inject/app/index.html`](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/index.html) (App shell), [`src/inject/app/js/index.js`](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/js/index.js) (App logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host Environment"]
  node_chrome["Chrome<br/>browser host"]
end

subgraph group_core["Extension Core"]
  node_manifest["Manifest<br/>[manifest.json]"]
  node_inject_js["Inject script<br/>content script<br/>[inject.js]"]
  node_inject_css["Base CSS<br/>shared styling<br/>[inject.css]"]
  node_google_css["Google fixes<br/>site override css<br/>[google.css]"]
  node_twitter_css["Twitter fixes<br/>site override css<br/>[twitter.css]"]
  node_whatsapp_css["WhatsApp fixes<br/>site override css<br/>[whatsapp.css]"]
end

subgraph group_ui["Extension UI"]
  node_app_html["App shell<br/>embedded ui html<br/>[index.html]"]
  node_app_js["App logic<br/>ui controller<br/>[index.js]"]
  node_popup_js["Popup logic<br/>popup controller<br/>[popup.js]"]
  node_app_css["App styles<br/>ui stylesheet<br/>[index.css]"]
end

subgraph group_assets["Support Assets"]
  node_locale_en["English strings<br/>localization bundle<br/>[messages.json]"]
  node_icons["Icons<br/>extension assets"]
  node_app_img["UI images<br/>image assets"]
end

node_chrome -->|"loads"| node_manifest
node_manifest -->|"registers"| node_inject_js
node_manifest -->|"includes"| node_inject_css
node_manifest -->|"includes"| node_google_css
node_manifest -->|"includes"| node_twitter_css
node_manifest -->|"includes"| node_whatsapp_css
node_manifest -->|"exposes"| node_app_html
node_manifest -->|"localizes"| node_locale_en
node_manifest -->|"references"| node_icons
node_inject_js -->|"applies"| node_inject_css
node_inject_js -->|"switches to"| node_google_css
node_inject_js -->|"switches to"| node_twitter_css
node_inject_js -->|"switches to"| node_whatsapp_css
node_inject_js -->|"mounts"| node_app_html
node_app_html -->|"drives"| node_app_js
node_app_html -->|"drives"| node_popup_js
node_app_html -->|"styles"| node_app_css
node_app_html -->|"uses"| node_app_img
node_app_js -.->|"shares code"| node_popup_js

click node_manifest "https://github.com/fahadyousafmahar/chromeurdu/blob/master/manifest.json"
click node_inject_js "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/inject.js"
click node_inject_css "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/inject.css"
click node_google_css "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/google.css"
click node_twitter_css "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/twitter.css"
click node_whatsapp_css "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/whatsapp.css"
click node_app_html "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/index.html"
click node_app_js "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/js/index.js"
click node_popup_js "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/js/popup.js"
click node_app_css "https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/css/index.css"
click node_locale_en "https://github.com/fahadyousafmahar/chromeurdu/blob/master/_locales/en/messages.json"
click node_icons "https://github.com/fahadyousafmahar/chromeurdu/tree/master/icons"
click node_app_img "https://github.com/fahadyousafmahar/chromeurdu/tree/master/src/inject/app/img"

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_chrome toneBlue
class node_manifest,node_inject_js,node_inject_css,node_google_css,node_twitter_css,node_whatsapp_css toneAmber
class node_app_html,node_app_js,node_popup_js,node_app_css toneMint
class node_locale_en,node_icons,node_app_img toneRose
```

## Components

### Host Environment

Chrome executes the extension and injects assets into page contexts.

- **Chrome**: browser host · Host environment that loads the extension and provides page DOM access.

### Extension Core

Manifest wiring plus the main content-script injection path.

- [Manifest](https://github.com/fahadyousafmahar/chromeurdu/blob/master/manifest.json): extension manifest · Central configuration for permissions, content scripts, and extension entry points. · `manifest.json`
- [Inject script](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/inject.js): content script · Runs in page context to apply the Urdu Nastaleeq rendering behavior. · `src/inject/inject.js`
- [Base CSS](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/inject.css): shared styling · Common styles used by the injected page-level experience. · `src/inject/inject.css`
- [Google fixes](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/google.css): site override css · Domain-specific styling adjustments for Google pages. · `src/inject/google.css`
- [Twitter fixes](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/twitter.css): site override css · Domain-specific styling adjustments for Twitter pages. · `src/inject/twitter.css`
- [WhatsApp fixes](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/whatsapp.css): site override css · Domain-specific styling adjustments for WhatsApp pages. · `src/inject/whatsapp.css`

### Extension UI

Bundled in-extension interface and popup logic.

- [App shell](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/index.html): embedded ui html · Bundled extension UI surface for controls or popup content. · `src/inject/app/index.html`
- [App logic](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/js/index.js): ui controller · Reusable JavaScript for the embedded extension app. · `src/inject/app/js/index.js`
- [Popup logic](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/js/popup.js): popup controller · Popup-specific behavior for the extension UI. · `src/inject/app/js/popup.js`
- [App styles](https://github.com/fahadyousafmahar/chromeurdu/blob/master/src/inject/app/css/index.css): ui stylesheet · Styles for the embedded extension app UI. · `src/inject/app/css/index.css`

### Support Assets

Localized messages and icon/image resources.

- [English strings](https://github.com/fahadyousafmahar/chromeurdu/blob/master/_locales/en/messages.json): localization bundle · Chrome i18n messages used for extension labels and text. · `_locales/en/messages.json`
- [Icons](https://github.com/fahadyousafmahar/chromeurdu/tree/master/icons): extension assets · Toolbar and extension UI icons. · `icons`
- [UI images](https://github.com/fahadyousafmahar/chromeurdu/tree/master/src/inject/app/img): image assets · Images used by the embedded app UI. · `src/inject/app/img`

## Connections

- Chrome → Manifest: loads · Chrome reads the manifest to install and run the extension.
- Manifest → Inject script: registers · Manifest declares the page injection runtime.
- Manifest → Base CSS: includes · Manifest makes the shared injected styles available.
- Manifest → Google fixes: includes · Manifest provides site-specific styling for Google pages.
- Manifest → Twitter fixes: includes · Manifest provides site-specific styling for Twitter pages.
- Manifest → WhatsApp fixes: includes · Manifest provides site-specific styling for WhatsApp pages.
- Manifest → App shell: exposes · Manifest wires the bundled UI surface into the extension.
- Manifest → English strings: localizes · Manifest points Chrome to the message catalog.
- Manifest → Icons: references · Manifest uses extension icons for browser surfaces.
- Inject script → Base CSS: applies · Runtime injection uses the shared base styling.
- Inject script → Google fixes: switches to · Adds site-specific CSS when the active domain needs Google fixes.
- Inject script → Twitter fixes: switches to · Adds site-specific CSS when the active domain needs Twitter fixes.
- Inject script → WhatsApp fixes: switches to · Adds site-specific CSS when the active domain needs WhatsApp fixes.
- Inject script → App shell: mounts · Can attach the extension UI into the page or extension surface.
- App shell → App logic: drives · The shell loads the reusable UI logic.
- App shell → Popup logic: drives · The shell loads popup-specific behavior.
- App shell → App styles: styles · The shell is styled by the bundled UI stylesheet.
- App shell → UI images: uses · The UI shell consumes bundled image assets.
- App logic → Popup logic: shares code · Popup behavior builds on the common app logic.
