# vishal-vp/clock architecture

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

- Interactive diagram: https://gitdiagram.com/vishal-vp/clock
- Repository: https://github.com/vishal-vp/clock

## Overview

##### Project Type Analysis
This is a frontend-only Progressive Web Application built with React, focusing on time-related functionality including a clock and stopwatch features. The project uses SCSS for styling and includes unit tests.

##### Main Components

A. Core Application Layer:
- App Component (Root)
- Service Worker (PWA functionality)
- Hooks Layer (Custom hooks)

B. Feature Components:
- Clock Component
- Stopwatch Component
- Digit Component (Reusable)
- SelectButton Component (Reusable)

C. State Management:
- Custom hooks (useClockSettings, useElapsedTime)
- React's built-in state management

D. Styling System:
- SCSS Modules
- Global Variables

- [Browser/PWA Container]
- [App Component]
- [Clock Component]
- [Digit Component]
- [Stopwatch Component]
- [Digit Component]
- [SelectButton Component]

##### Specific Elements

a) PWA Layer:
- Service Worker connection
- Manifest integration
- Cache handling

b) Component Layer:
- Component hierarchy
- Props and state flow
- Event handling paths

c) Style System:
- SCSS variables flow
- Component-specific styles
- Global styles

##### Notes for Implementation
- Keep the main component flow clear and centered
- Related components visually
- Clear separation between PWA infrastructure and application components
- Reusable components (Digit, SelectButton) with a special border or notation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser
        PWA[PWA Container]
        SW[Service Worker]:::serviceWorker
        click SW "https://github.com/vishal-vp/clock/blob/master/src/serviceWorker.js"
        Manifest[PWA Manifest]:::pwa
        click Manifest "https://github.com/vishal-vp/clock/blob/master/public/manifest.json"
    end

    subgraph AppLayer
        App[App Component]:::core
        click App "https://github.com/vishal-vp/clock/blob/master/src/App.js"
        GlobalStyles[Global Styles]:::styles
        click GlobalStyles "https://github.com/vishal-vp/clock/blob/master/src/sass/_variables.scss"
    end

    subgraph FeatureComponents
        Clock[Clock Component]:::feature
        click Clock "https://github.com/vishal-vp/clock/blob/master/src/components/Clock/index.js"
        Stopwatch[Stopwatch Component]:::feature
        click Stopwatch "https://github.com/vishal-vp/clock/blob/master/src/components/Stopwatch/index.js"
    end

    subgraph SharedComponents
        Digit[Digit Component]:::utility
        click Digit "https://github.com/vishal-vp/clock/blob/master/src/components/Digit/index.js"
        SelectButton[Select Button]:::utility
        click SelectButton "https://github.com/vishal-vp/clock/blob/master/src/components/SelectButton/index.js"
    end

    subgraph CustomHooks
        ClockSettings[useClockSettings]:::hook
        click ClockSettings "https://github.com/vishal-vp/clock/blob/master/src/components/Clock/useClockSettings.js"
        ElapsedTime[useElapsedTime]:::hook
        click ElapsedTime "https://github.com/vishal-vp/clock/blob/master/src/components/Stopwatch/useElapsedTime.js"
    end

    subgraph Styles
        ClockStyles[Clock Styles]:::styles
        click ClockStyles "https://github.com/vishal-vp/clock/blob/master/src/components/Clock/Clock.scss"
        StopwatchStyles[Stopwatch Styles]:::styles
        click StopwatchStyles "https://github.com/vishal-vp/clock/blob/master/src/components/Stopwatch/Stopwatch.scss"
        DigitStyles[Digit Styles]:::styles
        click DigitStyles "https://github.com/vishal-vp/clock/blob/master/src/components/Digit/Digit.scss"
        SelectButtonStyles[SelectButton Styles]:::styles
        click SelectButtonStyles "https://github.com/vishal-vp/clock/blob/master/src/components/SelectButton/SelectButton.scss"
    end

    PWA --> SW
    PWA --> Manifest
    SW --> App
    App --> Clock
    App --> Stopwatch
    Clock --> Digit
    Stopwatch --> Digit
    Clock --> SelectButton
    Stopwatch --> SelectButton
    
    Clock -.-> ClockSettings
    Stopwatch -.-> ElapsedTime
    
    Clock -.-> ClockStyles
    Stopwatch -.-> StopwatchStyles
    Digit -.-> DigitStyles
    SelectButton -.-> SelectButtonStyles
    App -.-> GlobalStyles

    %% Style Definitions
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef feature fill:#4CAF50,stroke:#2E7D32,color:white
    classDef utility fill:#FFC107,stroke:#FFA000,color:black
    classDef hook fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef serviceWorker fill:#FF5722,stroke:#E64A19,color:white
    classDef pwa fill:#795548,stroke:#5D4037,color:white
    classDef styles fill:#9E9E9E,stroke:#616161,color:white

    %% Legend
    subgraph Legend
        L1[Core Component]:::core
        L2[Feature Component]:::feature
        L3[Utility Component]:::utility
        L4[Custom Hook]:::hook
        L5[Service Worker]:::serviceWorker
        L6[PWA Component]:::pwa
        L7[Styles]:::styles
    end
```
