# abelweldaregay/banner-gcal-schedule-importer architecture

> Architecture diagram of the GitHub repository abelweldaregay/banner-gcal-schedule-importer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abelweldaregay/banner-gcal-schedule-importer
- Repository: https://github.com/abelweldaregay/banner-gcal-schedule-importer

## Overview

##### Project Type and Purpose
- This is a Chrome extension designed to automate the process of importing a semester’s course schedule from Banner (the web-based course management system) into Google Calendar or as an ICS file for other calendars.
- The extension extracts schedule data from the Banner schedule details page and uses it to build a new Google Calendar filled with course events. Multiple functionalities are supported: direct Google Calendar import and ICS file export for services like Microsoft Outlook.

##### Analyzing the File Structure
- JavaScript files (background.js, extract_schedule.js, gCalFunctions.js, googleAnalytics.js, googleApiClient.js, popup.js, and ics.js) handling the logic.
- popup.html and style.css providing the UI for user interactions (i.e., the popup when the extension is clicked).
- Other top-level files (README.md, _config.yml, demo video, help.md, privacy.md) are documentation and configuration files, indicating that the extension is well-documented and integrated with a website for help and privacy details.

##### Main Components
a. Extension User Interface
- Represented by popup.html, popup.js, and style.css.

b. Background Scripts and Core Logic
- background.js acts as the persistent background script managing state and initiating various processes.
- extract_schedule.js is the module that extracts schedule data once the user navigates to the Banner schedule details page.

c. Google Calendar and Third-Party Integration
- gCalFunctions.js and googleApiClient.js handle communication with the Google Calendar API to create, edit, or delete calendar events.
- Separate module (ics.js) handles exporting schedule data to an ICS file format, allowing integration with other calendar applications (e.g., MS Outlook).
- googleAnalytics.js is used to track user interactions and usage statistics.

d. Manifest and Configuration
- manifest.json defines the extension’s behavior, its permissions, and its file references. It is a central piece tying everything together.

##### Relationships and Interactions
- The UI (popup.html/popup.js) serves as the entry point when the user interacts with the extension.
- Upon user actions (e.g., clicking “import”), popup.js dispatches commands to background.js.
- background.js acts as the coordinator, triggering extract_schedule.js to retrieve the schedule data from the currently active Banner schedule details page.
- The extracted data is then passed to either:
- gCalFunctions.js (via googleApiClient.js) if the user chooses to create a Google Calendar.
- ics.js to generate an ICS file for download, thereby supporting different calendar systems.
- googleAnalytics.js simultaneously logs user activity, providing insights.
- All components are linked through manifest.json which ties each script and HTML file to the extension’s configuration.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly delineates UI components from background logic and API integration modules.
- Modular Design: Each functionality (schedule extraction, Google Calendar API integration, ICS generation, analytics) is implemented in its own JavaScript file.
- Event-driven architecture: User actions trigger events that are handled by background and specific module scripts, maintaining a responsive and asynchronous flow.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Extension Configuration
    Manifest["manifest.json"]:::config

    %% UI Layer
    subgraph "UI Layer"
        PopupHTML["popup.html"]:::ui
        PopupJS["popup.js"]:::ui
        Style["style.css"]:::ui
    end

    %% Background Processing
    subgraph "Background Processing"
        Background["background.js"]:::logic
    end

    %% Data Extraction Module
    subgraph "Data Extraction"
        Extract["extract_schedule.js"]:::extraction
    end

    %% Google Calendar API Integration
    subgraph "Google Calendar API Integration"
        GCalFunctions["gCalFunctions.js"]:::api
        GoogleApiClient["googleApiClient.js"]:::api
    end

    %% ICS Export Module
    subgraph "ICS Export Module"
        ICS["ics.js"]:::export
    end

    %% Analytics Tracking
    subgraph "Analytics Tracking"
        Analytics["googleAnalytics.js"]:::analytics
    end

    %% Connections
    PopupJS -->|"invoke"| Background
    Background -->|"trigger_extraction"| Extract
    Extract -->|"GCal_import"| GCalFunctions
    Extract -->|"GCal_import"| GoogleApiClient
    Extract -->|"ICS_export"| ICS
    PopupJS -->|"log_event"| Analytics

    %% Manifest configures all components
    Manifest -->|"configures"| PopupHTML
    Manifest -->|"configures"| PopupJS
    Manifest -->|"configures"| Style
    Manifest -->|"configures"| Background
    Manifest -->|"configures"| Extract
    Manifest -->|"configures"| GCalFunctions
    Manifest -->|"configures"| GoogleApiClient
    Manifest -->|"configures"| ICS
    Manifest -->|"configures"| Analytics

    %% Integration between Google Calendar modules
    GCalFunctions -->|"integrates_with"| GoogleApiClient

    %% Click Events
    click PopupHTML "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/popup.html"
    click PopupJS "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/popup.js"
    click Style "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/style.css"
    click Background "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/background.js"
    click Extract "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/extract_schedule.js"
    click GCalFunctions "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/gCalFunctions.js"
    click GoogleApiClient "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/googleApiClient.js"
    click ICS "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/ics.js"
    click Analytics "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/googleAnalytics.js"
    click Manifest "https://github.com/abelweldaregay/banner-gcal-schedule-importer/blob/master/extension/manifest.json"

    %% Styles
    classDef ui fill:#a2d9ce,stroke:#000,stroke-width:1px;
    classDef logic fill:#aed6f1,stroke:#000,stroke-width:1px;
    classDef extraction fill:#f9a825,stroke:#000,stroke-width:1px;
    classDef api fill:#f48fb1,stroke:#000,stroke-width:1px;
    classDef export fill:#c5e1a5,stroke:#000,stroke-width:1px;
    classDef analytics fill:#ffe082,stroke:#000,stroke-width:1px;
    classDef config fill:#d1c4e9,stroke:#000,stroke-width:1px;
```
