# fclove01/ig-cookie-easily architecture

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

- Interactive diagram: https://gitdiagram.com/fclove01/ig-cookie-easily
- Repository: https://github.com/fclove01/ig-cookie-easily

## Overview

##### Main Components
- Manifest & Configuration:
- The manifest.json file is the heart of the extension. It defines permissions (e.g., cookie access, tab management), the popup as the main user interface, and background/service configurations if any.
- Popup UI:
- The popup folder contains popup.html, popup.js, and style.css. This is where user interactions occur.
- Cookie Management Logic:
- Located in popup.js, this script handles the cookie retrieval, validation (checking for sessionid or ds_user_id), deletion of old cookies, and re-creation of new ones.
- Browser and Instagram Interaction:
- Although not explicitly part of the source code as a separate module, the extension interacts with the Chrome cookies API to read/write cookies and uses the Chrome tabs API to open a new Instagram tab after setting the cookie.

##### Interaction Flow
- User Action:
- The user can click the GET button to retrieve the current Instagram cookies. The popup.js reads current cookies via the Chrome cookies API and displays them.
- Copy/Log & Cookie Replacement:
- Upon clicking the LOG button, the script validates the provided cookie string (scanning for valid parameters such as sessionid/ds_user_id), clears any existing Instagram cookies, writes the new cookies, and opens a new Instagram tab.
- External API & Permissions:
- Although the extension works locally, it uses Chrome’s APIs to modify cookies and manipulate tabs.

##### Architectural Patterns & Design Principles
- Modular Design:
- Separate files for the manifest (configuration), UI (HTML/CSS), and logic (JavaScript) indicate clear separation of concerns.
- Event-Driven Interaction:
- The popup interface acts as an event handler where user actions (click events) trigger cookie processing and tab management.
- Minimal and Focused:
- Given it's a lightweight extension, its structure encapsulates all functionality within a single popup module rather than a multi-component backend.

##### Architectural Elements
- That this extension is self-contained with all operations occurring locally in the browser via Chrome’s APIs.
- That the design strictly separates the UI (popup) from the business logic (cookie management) while still emphasizing how the extension securely interacts with Instagram’s login process.
- Even though the structure is simple, capture every distinct element and interaction point for clarity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::external
    Manifest("Manifest Configuration"):::configuration

    subgraph "Popup UI Components"
        PopupHTML("Popup UI (popup.html)"):::ui
        PopupStyle("Popup Style (style.css)"):::ui
    end

    PopupScript("Popup Script (popup.js)"):::logic
    ChromeCookies("Chrome Cookies API"):::api
    ChromeTabs("Chrome Tabs API"):::api
    Instagram("Instagram"):::external

    %% Flow arrows
    User -->|"clicks extension"| PopupHTML
    Manifest -->|"defines popup"| PopupHTML
    PopupHTML -->|"triggers events"| PopupScript
    PopupScript -->|"retrieves/deletes/sets cookies"| ChromeCookies
    PopupScript -->|"opens Instagram tab"| ChromeTabs
    ChromeTabs -->|"navigates to"| Instagram

    %% Click Events
    click Manifest "https://github.com/fclove01/ig-cookie-easily/blob/main/manifest.json"
    click PopupHTML "https://github.com/fclove01/ig-cookie-easily/blob/main/popup/popup.html"
    click PopupStyle "https://github.com/fclove01/ig-cookie-easily/blob/main/popup/style.css"
    click PopupScript "https://github.com/fclove01/ig-cookie-easily/blob/main/popup/popup.js"

    %% Styles
    classDef configuration fill:#FDFD96,stroke:#333,stroke-width:2px
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef logic fill:#90EE90,stroke:#333,stroke-width:2px
    classDef api fill:#FFD700,stroke:#333,stroke-width:2px
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px
```
