# jawhawk/anichinu architecture

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

- Interactive diagram: https://gitdiagram.com/jawhawk/anichinu
- Repository: https://github.com/jawhawk/anichinu

## Overview

##### Project type & purpose (what you’re diagramming)
This repo is a **Chrome extension** (Manifest-based) built with **React + Webpack**. It provides at least two user-facing extension “surfaces”:
- **New Tab override** (a custom Newtab page with anime content and links)
- **Popup UI** (the small extension popup)

There are effectively **two generations of code** in the repo:
- `src/` = **Anichinu v2.0** (React/Webpack; the active architecture per README)
- `Anichinu1.0/` = a **legacy v1.0** extension structure (static HTML/JS/CSS with `popup.html`, `newtab.html`, `scripts/`, `styles/`, and data JSONs)

##### Runtime (what runs in the browser)
**Extension surfaces (UIs)**
- **New Tab app**
- Entry/host: `src/pages/Newtab/index.html`, `index.jsx`, `Newtab.tsx`
- Components:
- `components/AnimeBox.tsx`
- `components/LinkSection.tsx`
- `components/SettingsDrawer.tsx`
- Utilities (important for behavior/data flow):
- `util/fetchImage.ts` (external image retrieval or local asset fetch)
- `util/saveLocalstorage.ts` (persistence layer)
- `util/includesString.ts` (filter/search helper)
- Data bundled with the extension:
- `src/pages/Newtab/assets/aniwatchData.json`
- `src/pages/Newtab/assets/gogoanimeData.json`

- **Popup app**
- Entry/host: `src/pages/Popup/index.html`, `index.jsx`, `Popup.jsx`

**Extension manifest**

**Persistence**
- The v2 code explicitly references local persistence via `saveLocalstorage.ts`, so the minimal accurate “storage” component is **Web Storage (localStorage)**. (If `manifest.json` includes `chrome.storage`, show that too; but from the file tree alone, localStorage is the confirmed persistence mechanism.)

**External resources**
- Since there’s `fetchImage.ts` and JSON lists of content providers, the runtime likely reads local JSON and may fetch remote images/content. Represent this as:
- “External Anime Providers / Image Hosts (HTTP)” (generic cloud)

##### Build/Tooling (what produces the extension)
- Webpack build pipeline:
- `webpack.config.js`
- `utils/build.js`, `utils/env.js`, `utils/webserver.js`
- TypeScript config: `tsconfig.json`
- Package/deps/scripts: `package.json`, `package-lock.json`
- Output: `build/` (implied by README) and packaged zip in `zip/Anichinu-2.0.zip`

##### User opens a new tab
- Chrome → loads extension **New Tab Page** (as configured by `manifest.json`)
- New Tab React app:
- reads **bundled JSON** (`aniwatchData.json`, `gogoanimeData.json`)
- reads/writes **localStorage** (settings/preferences via `saveLocalstorage.ts`)
- optionally calls **External Image Hosts / Providers** via `fetchImage.ts`
- renders UI components (`AnimeBox`, `LinkSection`, `SettingsDrawer`)

- Chrome → loads extension **Popup Page**

##### Build flows (how code becomes an extension)
- Developer → `npm start`:
- Webserver/dev tooling serves + watches
- Webpack bundles Newtab + Popup entrypoints + assets
- Developer → `npm run build` (implied; or equivalent):
- Webpack creates `build/` folder
- Developer → Chrome “Load unpacked extension” uses `build/`

##### Architectural patterns/design principles visible from the repo
- **Local-first data**: content lists are shipped as JSON inside the extension; user preferences are persisted in localStorage.
- **Build-time bundling**: Webpack is essential; without it, the extension doesn’t exist in runnable form.

Following explicitly:
- **Clear labels** with file pointers where it matters:
- “Manifest: `src/manifest.json`”
- “Newtab: `src/pages/Newtab/*`”
- “Popup: `src/pages/Popup/*`”
- Blue rectangles: runtime UI containers (Newtab, Popup)
- Cloud: external providers/image hosts
- Orange gear: webpack/build tooling

##### Specific callouts for this repo (don’t miss these)
- **Newtab is the “main app”**: it has richer structure (TSX + components + utilities + assets), so allocate more detail there than Popup.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% System Context (Runtime)
  %% =========================
  subgraph "Runtime (in Chrome)"
    direction TB

    User["User"]:::actor
    Chrome["Chrome Browser"]:::host

    subgraph "Anichinu v2.0 Chrome Extension (built artifacts run)"
      direction TB

      ManifestV2["Manifest (v2.0)"]:::manifest

      subgraph "Extension Surfaces (UIs)"
        direction TB

        subgraph "New Tab Override (React App)"
          direction TB
          NewtabApp["Newtab Page (Container)"]:::ui
          NewtabEntryHtml["Newtab Host HTML"]:::doc
          NewtabEntryJs["Newtab JS Entry"]:::code
          NewtabRoot["Newtab Root (TSX)"]:::code

          subgraph "Newtab Components"
            direction TB
            AnimeBox["AnimeBox"]:::component
            LinkSection["LinkSection"]:::component
            SettingsDrawer["SettingsDrawer"]:::component
          end

          subgraph "Newtab Utilities"
            direction TB
            FetchImage["fetchImage()"]:::util
            SaveLocalstorage["saveLocalstorage()"]:::util
            IncludesString["includesString()"]:::util
          end

          subgraph "Newtab Bundled Data"
            direction TB
            AniwatchJson["aniwatchData.json"]:::data
            GogoanimeJson["gogoanimeData.json"]:::data
          end
        end

        subgraph "Popup (React App)"
          direction TB
          PopupApp["Popup Page (Container)"]:::ui
          PopupEntryHtml["Popup Host HTML"]:::doc
          PopupEntryJs["Popup JS Entry"]:::code
          PopupRoot["Popup Root (JSX)"]:::code
        end
      end

      BundledAssetsV2["Bundled Assets (images, etc.)"]:::assets
      LocalStorage[("Web Storage: localStorage")]:::storage
    end

    ExternalHosts["External Anime Providers / Image Hosts (HTTP)"]:::external
  end

  %% =========================
  %% Build & Tooling (Dev/CI)
  %% =========================
  subgraph "Build & Tooling (Developer machine)"
    direction TB

    Developer["Developer"]:::actor

    PackageJson["NPM Scripts / Metadata"]:::tool
    Lockfile["Dependency Lockfile"]:::tool
    TSConfig["TypeScript Config"]:::tool

    subgraph "Webpack Toolchain"
      direction TB
      WebpackConfig["Webpack Config"]:::tool
      BuildScript["Build Script"]:::tool
      EnvScript["Env Setup"]:::tool
      WebServer["Dev Webserver"]:::tool
    end

    BuildOutput["build/ (extension output)"]:::artifact
    ZipArtifact["zip/Anichinu-2.0.zip"]:::artifact
  end

  %% =========================
  %% Legacy v1.0 (Archived)
  %% =========================
  subgraph "Legacy / Archived (Anichinu v1.0)"
    direction TB
    LegacyRoot["Anichinu1.0 (legacy extension)"]:::legacy
    LegacyManifest["Manifest (v1.0)"]:::manifest
    LegacyNewtab["newtab.html (v1.0)"]:::legacyDoc
    LegacyPopup["popup.html (v1.0)"]:::legacyDoc
    LegacyScripts["scripts/ (v1.0)"]:::legacy
    LegacyStyles["styles/ (v1.0)"]:::legacy
    LegacyData["anime_data/ (v1.0 JSON)"]:::legacyData
    LegacyAssets["assets/ (v1.0)"]:::legacy
  end

  %% =========================
  %% Runtime Relationships
  %% =========================
  User -->|"opensNewTab()"| Chrome
  User -->|"clicksExtensionIcon()"| Chrome

  Chrome -->|"loadsOverrideFromManifest"| ManifestV2
  ManifestV2 -->|"newtabOverride"| NewtabApp
  ManifestV2 -->|"popupEntry"| PopupApp

  NewtabApp -->|"rendersVia"| NewtabEntryHtml
  NewtabEntryHtml -->|"boots"| NewtabEntryJs
  NewtabEntryJs -->|"mounts"| NewtabRoot

  NewtabRoot -->|"composes"| AnimeBox
  NewtabRoot -->|"composes"| LinkSection
  NewtabRoot -->|"composes"| SettingsDrawer

  NewtabRoot -->|"readsBundledData"| AniwatchJson
  NewtabRoot -->|"readsBundledData"| GogoanimeJson

  NewtabRoot -->|"filters/searches"| IncludesString
  NewtabRoot -->|"fetchesImages"| FetchImage
  NewtabRoot -->|"persistsPrefs"| SaveLocalstorage

  SaveLocalstorage -->|"read/write"| LocalStorage
  FetchImage -->|"HTTP(S)"| ExternalHosts

  NewtabApp -->|"uses"| BundledAssetsV2
  PopupApp -->|"uses"| BundledAssetsV2

  PopupApp -->|"rendersVia"| PopupEntryHtml
  PopupEntryHtml -->|"boots"| PopupEntryJs
  PopupEntryJs -->|"mounts"| PopupRoot

  %% =========================
  %% Build-time Relationships (dashed)
  %% =========================
  Developer -.->|"npmInstall"| PackageJson
  PackageJson -.->|"resolves"| Lockfile

  Developer -.->|"npmStart"| WebServer
  Developer -.->|"npmRunBuild"| BuildScript

  TSConfig -.->|"typechecks"| BuildScript
  EnvScript -.->|"providesEnv"| BuildScript
  WebpackConfig -.->|"bundles"| BuildScript

  WebServer -.->|"uses"| WebpackConfig
  BuildScript -.->|"emits"| BuildOutput
  BuildOutput -.->|"packagesTo"| ZipArtifact

  Chrome -.->|"loadUnpackedExtensionFrom"| BuildOutput

  %% =========================
  %% Legacy Relationships
  %% =========================
  LegacyRoot -->|"declares"| LegacyManifest
  LegacyRoot -->|"hosts"| LegacyNewtab
  LegacyRoot -->|"hosts"| LegacyPopup
  LegacyRoot -->|"contains"| LegacyScripts
  LegacyRoot -->|"contains"| LegacyStyles
  LegacyRoot -->|"contains"| LegacyData
  LegacyRoot -->|"contains"| LegacyAssets

  %% =========================
  %% Click Events (component mapping)
  %% =========================
  click ManifestV2 "https://github.com/jawhawk/anichinu/blob/main/src/manifest.json"
  click NewtabApp "https://github.com/jawhawk/anichinu/tree/main/src/pages/Newtab/"
  click NewtabEntryHtml "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/index.html"
  click NewtabEntryJs "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/index.jsx"
  click NewtabRoot "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/Newtab.tsx"
  click AnimeBox "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/components/AnimeBox.tsx"
  click LinkSection "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/components/LinkSection.tsx"
  click SettingsDrawer "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/components/SettingsDrawer.tsx"
  click AniwatchJson "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/assets/aniwatchData.json"
  click GogoanimeJson "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/assets/gogoanimeData.json"
  click FetchImage "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/util/fetchImage.ts"
  click SaveLocalstorage "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/util/saveLocalstorage.ts"
  click IncludesString "https://github.com/jawhawk/anichinu/blob/main/src/pages/Newtab/util/includesString.ts"
  click PopupApp "https://github.com/jawhawk/anichinu/tree/main/src/pages/Popup/"
  click PopupEntryHtml "https://github.com/jawhawk/anichinu/blob/main/src/pages/Popup/index.html"
  click PopupEntryJs "https://github.com/jawhawk/anichinu/blob/main/src/pages/Popup/index.jsx"
  click PopupRoot "https://github.com/jawhawk/anichinu/blob/main/src/pages/Popup/Popup.jsx"
  click BundledAssetsV2 "https://github.com/jawhawk/anichinu/tree/main/src/assets/"
  click WebpackConfig "https://github.com/jawhawk/anichinu/blob/main/webpack.config.js"
  click BuildScript "https://github.com/jawhawk/anichinu/blob/main/utils/build.js"
  click EnvScript "https://github.com/jawhawk/anichinu/blob/main/utils/env.js"
  click WebServer "https://github.com/jawhawk/anichinu/blob/main/utils/webserver.js"
  click TSConfig "https://github.com/jawhawk/anichinu/blob/main/tsconfig.json"
  click PackageJson "https://github.com/jawhawk/anichinu/blob/main/package.json"
  click Lockfile "https://github.com/jawhawk/anichinu/blob/main/package-lock.json"
  click ZipArtifact "https://github.com/jawhawk/anichinu/blob/main/zip/Anichinu-2.0.zip"
  click LegacyRoot "https://github.com/jawhawk/anichinu/tree/main/Anichinu1.0/"
  click LegacyManifest "https://github.com/jawhawk/anichinu/blob/main/Anichinu1.0/manifest.json"
  click LegacyNewtab "https://github.com/jawhawk/anichinu/blob/main/Anichinu1.0/newtab.html"
  click LegacyPopup "https://github.com/jawhawk/anichinu/blob/main/Anichinu1.0/popup.html"
  click LegacyScripts "https://github.com/jawhawk/anichinu/tree/main/Anichinu1.0/scripts/"
  click LegacyData "https://github.com/jawhawk/anichinu/tree/main/Anichinu1.0/anime_data/"
  click LegacyStyles "https://github.com/jawhawk/anichinu/tree/main/Anichinu1.0/styles/"
  click LegacyAssets "https://github.com/jawhawk/anichinu/tree/main/Anichinu1.0/assets/"

  %% =========================
  %% Styles (color-coded)
  %% =========================
  classDef actor fill:#0b1320,stroke:#9fb3c8,color:#e6f0ff,stroke-width:1px
  classDef host fill:#111827,stroke:#60a5fa,color:#e5e7eb,stroke-width:1px
  classDef manifest fill:#e0f2fe,stroke:#0284c7,color:#0f172a,stroke-width:1px
  classDef ui fill:#dbeafe,stroke:#2563eb,color:#0f172a,stroke-width:1px
  classDef component fill:#bfdbfe,stroke:#1d4ed8,color:#0f172a,stroke-width:1px
  classDef util fill:#cffafe,stroke:#0891b2,color:#0f172a,stroke-width:1px
  classDef data fill:#fef9c3,stroke:#ca8a04,color:#0f172a,stroke-width:1px
  classDef doc fill:#f1f5f9,stroke:#64748b,color:#0f172a,stroke-width:1px
  classDef code fill:#ecfccb,stroke:#65a30d,color:#0f172a,stroke-width:1px
  classDef assets fill:#ede9fe,stroke:#6d28d9,color:#0f172a,stroke-width:1px
  classDef storage fill:#fff7ed,stroke:#ea580c,color:#0f172a,stroke-width:1px
  classDef external fill:#e5e7eb,stroke:#334155,color:#0f172a,stroke-width:1px
  classDef tool fill:#ffedd5,stroke:#f97316,color:#0f172a,stroke-width:1px
  classDef artifact fill:#dcfce7,stroke:#16a34a,color:#0f172a,stroke-width:1px
  classDef legacy fill:#f3f4f6,stroke:#9ca3af,color:#111827,stroke-width:1px,stroke-dasharray: 4 3
  classDef legacyDoc fill:#f3f4f6,stroke:#9ca3af,color:#111827,stroke-width:1px,stroke-dasharray: 4 3
  classDef legacyData fill:#f3f4f6,stroke:#9ca3af,color:#111827,stroke-width:1px,stroke-dasharray: 4 3
```
