# zalapanda/redmine-time-spender architecture

> Architecture diagram of the GitHub repository zalapanda/redmine-time-spender, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zalapanda/redmine-time-spender
- Repository: https://github.com/zalapanda/redmine-time-spender

## Overview

##### Project Type Analysis
This is a Chrome browser extension that interfaces with Redmine for time tracking, featuring local storage, encryption, and UI components.

##### Main Components

A. Browser Extension Components:
- Popup Interface (Entry point)
- Background Service
- Options Page
- Content Scripts (if any)

B. Data Layer:
- IndexedDB Storage
- Encrypted Cache
- Cookie Storage (for encryption key)

C. External Systems:
- Redmine Server
- Redmine API

##### Component Organization

**[Chrome Browser Environment]**
- UI Layer
- Popup Interface
- Time Entry Management
- Issue Management
- Task Management
- Options Page

- Business Logic Layer
- Background Service
- API Interfaces
- Crypto Service

- Data Layer
- IndexedDB
- Cookie Storage

**[External]**
- Redmine Server

##### Specific Implementation Details

A. UI Components (Rectangle with rounded corners, Blue):
- App.tsx
- Bar.tsx
- Dialog.tsx
- EditEntry.tsx
- EditIssue.tsx
- EditTask.tsx
- Atomic Components (atoms/)

B. Services (Hexagons, Green):
- background.ts
- apis/redmine.ts
- apis/crypto.ts
- apis/database.ts

- IndexedDB
- Cookie Storage

- Redmine Server

- User interactions → UI Components
- UI Components → API Services
- API Services → Storage
- API Services → Redmine Server
- Background Service ↔ Storage
- Background Service ↔ Redmine Server

##### Important Notes

A. Security Flow:
- Encryption/decryption flow
- Where the encryption key is stored and how it's used
- Encrypted vs. non-encrypted data paths

B. Caching Mechanism:
- Flow of data from Redmine to local storage
- What data is cached (projects, issues, activities)
- Refresh/sync mechanisms

C. Key Features to Highlight:
- Time entry management
- Project/issue filtering
- Auto-refresh mechanism
- Search functionality
- Issue creation flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef ui fill:#e1f5fe,stroke:#01579b
    classDef service fill:#e8f5e9,stroke:#1b5e20
    classDef storage fill:#fff3e0,stroke:#e65100
    classDef external fill:#f5f5f5,stroke:#424242
    
    subgraph ChromeEnvironment["Chrome Browser Environment"]
        subgraph UILayer["UI Layer"]
            Popup["Popup Interface"]:::ui
            Options["Options Page"]:::ui
            click Popup "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/popup.ts"
            click Options "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/options.ts"
            
            subgraph PopupComponents["Popup Components"]
                App["Main Application"]:::ui
                Bar["Navigation Bar"]:::ui
                TimeEntry["Time Entry Management"]:::ui
                IssueManagement["Issue Management"]:::ui
                TaskManagement["Task Management"]:::ui
                Dialog["Dialog Component"]:::ui
                Config["Configuration"]:::ui
                Atoms["Atomic Components"]:::ui
                click App "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/App.tsx"
                click Bar "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/Bar.tsx"
                click TimeEntry "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/EditEntry.tsx"
                click IssueManagement "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/EditIssue.tsx"
                click TaskManagement "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/EditTask.tsx"
                click Dialog "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/Dialog.tsx"
                click Config "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/Config.tsx"
                click Atoms "https://github.com/ZalaPanda/redmine-time-spender/tree/main/src/atoms/"
            end
        end

        subgraph BusinessLayer["Business Logic Layer"]
            Background["Background Service"]:::service
            RedmineAPI["Redmine API Interface"]:::service
            CryptoService["Crypto Service"]:::service
            DatabaseService["Database Interface"]:::service
            click Background "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/background.ts"
            click RedmineAPI "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/apis/redmine.ts"
            click CryptoService "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/apis/crypto.ts"
            click DatabaseService "https://github.com/ZalaPanda/redmine-time-spender/blob/main/src/apis/database.ts"
        end

        subgraph DataLayer["Data Layer"]
            IndexedDB[(IndexedDB)]:::storage
            CookieStorage[(Cookie Storage)]:::storage
        end
    end

    subgraph External["External Systems"]
        RedmineServer["Redmine Server"]:::external
    end

    %% Connections
    Popup --> App
    App --> PopupComponents
    App --> BusinessLayer
    Background --> RedmineAPI
    Background --> CryptoService
    Background --> DatabaseService
    
    CryptoService --> CookieStorage
    DatabaseService --> IndexedDB
    RedmineAPI <--> RedmineServer
    
    %% Data Flow
    PopupComponents <--> BusinessLayer
    BusinessLayer <--> DataLayer
    
    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        Service["Service"]:::service
        Storage["Storage"]:::storage
        Ext["External System"]:::external
    end
```
