# kylemath/eegedu architecture

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

- Interactive diagram: https://gitdiagram.com/kylemath/eegedu
- Repository: https://github.com/kylemath/eegedu

## Overview

##### Project Type and Purpose
- EEGEdu is a front-end interactive web application built with React. Its purpose is to offer an educational playground where users can learn about and interact with different aspects of EEG (electroencephalogram) data.
- The app provides a curriculum broken into multiple “lessons” (e.g., tutorials on raw data viewing, frequency analysis, neurofeedback demos, etc.) delivered as separate interactive components.

##### File Structure
- The top-level directories and files indicate:
- Project configuration and deployment: Files like .env, firebase.json, app.yaml, and the GitHub workflows.
- A public folder (contains index.html and manifest.json) that serves as the container for the React application.
- A src directory where the bulk of the application code resides – notably, the /components folder contains React components.
- Under “src/components/PageSwitcher”, you see multiple subdirectories corresponding to different lessons (EEGEduIntro, EEGEduHeartRaw, EEGEduSpectra, etc.). Each of these contains a main component file and supporting translation and sketch files, suggesting that each module encapsulates a single feature or educational module.
- The PageSwitcher component itself acts like a router or a navigation hub between these lesson components.

##### README for Additional Insights
- The README explains the overall curriculum with step-by-step lessons each linked to a specific component.
- It details the deployment pipeline using Firebase and GitHub Actions and outlines local development and testing steps.
- The README highlights that the application runs in any modern web browser and explains the user flow from connecting via a Mock or real Muse headband to visualizing various EEG data experiments.

a. Main Components to Include:
- User/Client Browser: Represents the end-user accessing the application.
- Web Application (React Frontend): Encapsulate the core UI, broken down into:
- Entry Point (public/index.html and src/index.js)
- Main App Component (src/components/App) – includes general layout and translation support.
- PageSwitcher Component (src/components/PageSwitcher) – the central routing hub that manages lesson navigation.
- Lesson Modules: Each lesson (EEGEduIntro, EEGEduHeartRaw, EEGEduPredict, etc.) as individual components with their own internal structures (sketch files, translations, and any custom logic).
- Data Stream / EEG Data Processing Module: Although largely within the client code, the utils (e.g., mockMuseEEG.js) indicate that certain utilities are provided for handling the EEG data streams (both mock and real).

b. Relationships and Interactions:
- The User interacts via the browser with the React App, which in turn loads the App Component.
- The App dispatches navigation through the PageSwitcher, determining which lesson module to present.
- Each lesson/module receives data either from a simulated (mock) EEG data stream or directly from the Muse headband when connected.
- The communication is bidirectional; user events (e.g., slider changes or button clicks) trigger visual updates in the sketches (using libraries like p5.js) and data processing utilities.
- Deployment pipelines feed updated builds to Firebase Hosting, ensuring the latest version is available to users.

c. Architectural Patterns or Design Principles:
- Component-based architecture inherent to React.
- A clear separation of concerns: UI routing (via PageSwitcher), modularized educational lessons, and external utilities for EEG data handling.
- Localization support is evident (translations stored per component).
- Build and deployment automation emphasize a modern CI/CD approach.

d. Key Technologies, Frameworks, and Libraries:
- React (component-based UI design)
- Firebase (for hosting and deployment)
- Yarn/Node.js (for package management and building the app)
- p5.js or similar drawing libraries (as implied by the “sketch” files for interactive visualizations)
- Possibly Chart.js (referenced in README for charting needs)
- Muse headband connectivity libraries (as mentioned in the README references)

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interaction Layer
    subgraph "User Interaction"
        U["User Browser"]:::browser
    end

    %% React Application Layer
    subgraph "React Application"
        entry["React App Entry (index.js)"]:::app
        mainapp["Main App Component (App.js)"]:::app
        pageswitcher["Navigation (PageSwitcher)"]:::app
        %% Lesson Modules
        subgraph "Lesson Modules"
            eegeduintro["Lesson: EEGEduIntro"]:::lesson
            eegeduheartraw["Lesson: EEGEduHeartRaw"]:::lesson
            eegeduspectra["Lesson: EEGEduSpectra"]:::lesson
            eegeduraw["Lesson: EEGEduRaw"]:::lesson
            eegedupredict["Lesson: EEGEduPredict"]:::lesson
            others["Other Lesson Modules"]:::lesson
        end
    end

    %% EEG Data Processing Utilities
    subgraph "EEG Data Processing"
        eegutil["EEG Data Utility (mockMuseEEG.js)"]:::util
    end

    %% Deployment & CI/CD Layer
    subgraph "Deployment & CI/CD"
        fbhost["Firebase Hosting"]:::deploy
        ghactions["GitHub Actions"]:::deploy
        fbconfig["Firebase Config (firebase.json, app.yaml)"]:::deploy
        envconfig["Environment Variables (.env)"]:::deploy
        workflow["CI/CD Workflow (.github/workflows/workflow.yml)"]:::deploy
    end

    %% Connections in React Application
    U -->|"loads"| entry
    entry -->|"initializes"| mainapp
    mainapp -->|"routes via"| pageswitcher
    pageswitcher -->|"selects"| eegeduintro
    pageswitcher -->|"selects"| eegeduheartraw
    pageswitcher -->|"selects"| eegeduspectra
    pageswitcher -->|"selects"| eegeduraw
    pageswitcher -->|"selects"| eegedupredict
    pageswitcher -->|"selects"| others

    %% Lesson Modules use EEG Utilities
    eegeduintro -->|"processes EEG data"| eegutil
    eegeduheartraw -->|"processes EEG data"| eegutil
    eegeduspectra -->|"processes EEG data"| eegutil
    eegeduraw -->|"processes EEG data"| eegutil
    eegedupredict -->|"processes EEG data"| eegutil
    others -->|"can utilize"| eegutil

    %% Deployment connections
    ghactions -->|"deploys build"| fbhost
    fbconfig --> ghactions
    envconfig --> ghactions
    workflow --> ghactions

    %% Click Events
    click U "https://github.com/kylemath/eegedu/blob/master/public/index.html"
    click entry "https://github.com/kylemath/eegedu/blob/master/src/index.js"
    click mainapp "https://github.com/kylemath/eegedu/blob/master/src/components/App/App.js"
    click pageswitcher "https://github.com/kylemath/eegedu/blob/master/src/components/PageSwitcher/PageSwitcher.js"
    click eegeduintro "https://github.com/kylemath/eegedu/blob/master/src/components/PageSwitcher/components/EEGEduIntro/EEGEduIntro.js"
    click eegeduheartraw "https://github.com/kylemath/eegedu/blob/master/src/components/PageSwitcher/components/EEGEduHeartRaw/EEGEduHeartRaw.js"
    click eegeduspectra "https://github.com/kylemath/eegedu/blob/master/src/components/PageSwitcher/components/EEGEduSpectra/EEGEduSpectra.js"
    click eegeduraw "https://github.com/kylemath/eegedu/blob/master/src/components/PageSwitcher/components/EEGEduRaw/EEGEduRaw.js"
    click eegedupredict "https://github.com/kylemath/eegedu/blob/master/src/components/PageSwitcher/components/EEGEduPredict/EEGEduPredict.js"
    click eegutil "https://github.com/kylemath/eegedu/blob/master/src/components/PageSwitcher/utils/mockMuseEEG.js"
    click fbconfig "https://github.com/kylemath/eegedu/blob/master/firebase.json"
    click envconfig "https://github.com/kylemath/eegedu/blob/master/.env"
    click workflow "https://github.com/kylemath/eegedu/blob/master/.github/workflows/workflow.yml"

    %% Styles
    classDef browser fill:#f9c,stroke:#333,stroke-width:2px;
    classDef app fill:#BBDEFB,stroke:#333,stroke-width:2px;
    classDef lesson fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef util fill:#FFCC80,stroke:#333,stroke-width:2px;
    classDef deploy fill:#FFE082,stroke:#333,stroke-width:2px;
```
