# nikhil1479/usepopcorn architecture

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

- Interactive diagram: https://gitdiagram.com/nikhil1479/usepopcorn
- Repository: https://github.com/nikhil1479/usepopcorn

## Overview

##### Project Type and Purpose
- This is a front-end only, single-page React application (bootstrapped with Create React App) that presents movie data, allows star ratings, and persists user selections in localStorage. There is no traditional backend service in the repo; all logic lives in the client.

##### Core Architectural Layers
a. CI/CD Layer
- GitHub repository with three workflows:
– node.js.yml (install, lint, test)
– jira-issue-check.yml (PR validation against Jira)
– EmailNotificationonMasterPushorPullRequest.yml (email alerts)
- Artifacts: package.json scripts (start, test, build, eject)
b. Build & Deployment Layer
- “npm run build” invokes react-scripts → Webpack + Babel → outputs static files into /build
- Deployment target: any static host (e.g., GitHub Pages, S3, Netlify)
c. Runtime (Client) Layer
- Browser loads index.html + CSS + JS bundles
- React app bootstraps in src/index.js → renders <App/> into DOM
- Application UI composed of React components and custom hooks
- Data persistence via window.localStorage
- (Optionally) external movie API calls if useMovies hook is extended

##### Main Components & Interactions
- Browser Client
→ serves HTML/CSS/JS → React runtime
- React Application
- App.js
- UI Components: StarRating.js, MovieData.js, _codux boards
- Custom Hooks:
– useKey.js (keyboard shortcuts)
– useLocalStorage.js (persist state)
– useMovies.js (fetch/serve movie list)
- Styling: App.css, index.css
- Data Store
- Browser localStorage (via useLocalStorage hook)
- External Services (if any)
- Third-party movie API (not in code but common extension)

Data Flow Example:
User clicks rating → StarRating component fires event → useLocalStorage updates persisted state → App re-renders MovieData → UI reflects new rating

##### Architectural Patterns & Principles
- Component-Based UI (React)
- Unidirectional Data Flow (props & hooks)
- Separation of Concerns:
- UI components vs. data hooks vs. styling
- CI/CD pipelines separated from client runtime
- Progressive Web App readiness (manifest.json, service worker stubs via CRA)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Layer
    subgraph "CI/CD Layer"
        direction TB
        NodeJS["Node.js Workflow"]:::ci
        JiraCheck["Jira Issue Check Workflow"]:::ci
        EmailNotif["Email Notification Workflow"]:::ci
        PackageJSON["package.json Scripts & Dependencies"]:::ci
    end

    %% Build & Deployment Layer
    subgraph "Build & Deployment Layer"
        direction TB
        NpmBuild["npm run build (react-scripts)"]:::ci
        WebpackBabel["Webpack + Babel"]:::ci
        BuildStatic["Static CSS/JS Bundles"]:::ci
        BuildHTML["HTML & Manifest"]:::ci
    end

    %% Client Runtime Layer
    subgraph "Client Runtime Layer"
        direction TB
        subgraph "Browser"
            direction TB
            PublicHTML["public/index.html"]:::ci
            PublicManifest["public/manifest.json"]:::ci
        end

        subgraph "React Core"
            direction TB
            EntryPoint["src/index.js"]:::ci
            AppComp["App Component (App.js)"]:::react
        end

        subgraph "UI Components"
            direction TB
            MovieData["MovieData Component"]:::react
            StarRating["StarRating Component"]:::react
        end

        subgraph "Custom Hooks"
            direction TB
            UseKey["useKey Hook"]:::hooks
            UseLocalStorage["useLocalStorage Hook"]:::hooks
            UseMovies["useMovies Hook"]:::hooks
        end

        LocalStorage[(localStorage)]:::storage
        ExternalAPI["External Movie API"]:::external
    end

    %% Connections CI/CD -> Build
    NodeJS -->|runs| NpmBuild
    JiraCheck -->|validates PRs| NodeJS
    EmailNotif -->|alerts| NodeJS
    PackageJSON -->|defines scripts| NpmBuild

    %% Build flow
    NpmBuild --> WebpackBabel
    WebpackBabel --> BuildStatic
    WebpackBabel --> BuildHTML

    %% Deployment flow (to static host)
    BuildStatic -->|serves| PublicHTML
    BuildHTML -->|includes| PublicManifest

    %% Runtime flow
    PublicHTML -->|loads| EntryPoint
    PublicManifest -->|PWA| EntryPoint
    EntryPoint -->|renders| AppComp
    AppComp -->|composes| MovieData
    AppComp -->|composes| StarRating
    AppComp -->|uses| UseKey
    AppComp -->|uses| UseLocalStorage
    AppComp -->|uses| UseMovies

    MovieData -->|props/events| UseLocalStorage
    StarRating -->|GET/SET rating| UseLocalStorage
    UseMovies -->|fetch| ExternalAPI
    UseLocalStorage -->|persist| LocalStorage

    %% Click Events
    click NodeJS "https://github.com/nikhil1479/usepopcorn/blob/master/.github/workflows/node.js.yml"
    click JiraCheck "https://github.com/nikhil1479/usepopcorn/blob/master/.github/workflows/jira-issue-check.yml"
    click EmailNotif "https://github.com/nikhil1479/usepopcorn/blob/master/.github/workflows/EmailNotificationonMasterPushorPullRequest.yml"
    click BuildStatic "https://github.com/nikhil1479/usepopcorn/tree/master/build/static/"
    click BuildHTML "https://github.com/nikhil1479/usepopcorn/blob/master/build/index.html"
    click BuildHTML "https://github.com/nikhil1479/usepopcorn/blob/master/build/manifest.json"
    click PublicHTML "https://github.com/nikhil1479/usepopcorn/blob/master/public/index.html"
    click PublicManifest "https://github.com/nikhil1479/usepopcorn/blob/master/public/manifest.json"
    click EntryPoint "https://github.com/nikhil1479/usepopcorn/blob/master/src/index.js"
    click PackageJSON "https://github.com/nikhil1479/usepopcorn/blob/master/package.json"
    click AppComp "https://github.com/nikhil1479/usepopcorn/blob/master/src/App.js"
    click MovieData "https://github.com/nikhil1479/usepopcorn/blob/master/src/MovieData.js"
    click StarRating "https://github.com/nikhil1479/usepopcorn/blob/master/src/StarRating.js"
    click UseKey "https://github.com/nikhil1479/usepopcorn/blob/master/src/useKey.js"
    click UseLocalStorage "https://github.com/nikhil1479/usepopcorn/blob/master/src/useLocalStorage.js"
    click UseMovies "https://github.com/nikhil1479/usepopcorn/blob/master/src/useMovies.js"

    %% Styles
    classDef react fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef hooks fill:#90EE90,stroke:#333,stroke-width:1px
    classDef storage fill:#FFA500,stroke:#333,stroke-width:1px
    classDef ci fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:none,stroke:#666,stroke-width:1px,stroke-dasharray:5 5
```
