# danceolsson/physioengine-react architecture

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

- Interactive diagram: https://gitdiagram.com/danceolsson/physioengine-react
- Repository: https://github.com/danceolsson/physioengine-react

## Overview

##### Main Components

A. Frontend Layer (React Application)
- Present this as the top-level layer with these key modules:
- Core Application (src/App.tsx, router.tsx)
- Feature Components (/components/features)
- Dynamic Questionnaire System (/components/dynamic-readers)
- UI Components (/components/ui)
- Marketing Components (/components/marketing)

B. State Management & Business Logic
- Custom hooks layer (/hooks)
- Calculator Services (/lib/calculators)
- Type System (/lib/types)

C. External Services
- Firebase Integration (/lib/firebase.ts)
- Real-time Updates System

D. Data Flow Layer
- Questionnaire Data Flow
- Response Processing Flow
- Real-time Updates Flow

**[Frontend Layer]**
- ↓↑
**[State Management Layer]**
- ↓↑
**[Business Logic Layer]**
- ↓↑
**[External Services Layer]**

##### Key Relationships to Highlight

A. Questionnaire Flow:
- QR Generation → Mobile Reader → Form Submission → Real-time Updates → Results Display

B. Data Processing Flow:
- User Input → Dynamic Reader → Calculator Services → Results Processing → Visual Output

##### Integration Points

- Firebase integration points for:
- Real-time updates
- Data persistence
- Authentication (if implemented)

##### Component Relationships

- QuestionnaireActionPanel ↔ QuestionnaireDynamicPanel
- Dynamic Readers ↔ Questionnaire Data
- Calculator Services ↔ Results Pages

##### Technical Stack Indicators

Technology badges for:
- React
- TypeScript
- Tailwind CSS
- Firebase
- Vite

Key Recommendations:
##### Expansion points for future modules

Remember to emphasize the real-time nature of the application and how the different questionnaire types (KOOS, HOOS, DASH) plug into the core system architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        App["Core Application"]
        DQS["Dynamic Questionnaire System"]
        FC["Feature Components"]
        UI["UI Components"]
        MC["Marketing Components"]
    end

    subgraph StateManagement
        Hooks["Custom Hooks"]
        TypeSystem["Type System"]
    end

    subgraph BusinessLogic
        Calculators["Calculator Services"]
        QData["Questionnaire Data"]
    end

    subgraph ExternalServices
        Firebase["Firebase Integration"]
    end

    %% Frontend Layer Relationships
    App --> DQS
    App --> FC
    App --> UI
    App --> MC

    %% State Management Relationships
    DQS --> Hooks
    FC --> Hooks
    Hooks --> Firebase

    %% Business Logic Relationships
    DQS --> Calculators
    DQS --> QData
    Hooks --> Calculators
    Calculators --> TypeSystem

    %% External Services Relationships
    Firebase --> Hooks

    %% Styling
    classDef frontend fill:#3b82f6,color:#fff
    classDef state fill:#9333ea,color:#fff
    classDef logic fill:#22c55e,color:#fff
    classDef external fill:#f97316,color:#fff

    class App,DQS,FC,UI,MC frontend
    class Hooks,TypeSystem state
    class Calculators,QData logic
    class Firebase external

    %% Click Events
    click App "https://github.com/DanceOlsson/physioengine-react/blob/main/src/App.tsx"
    click DQS "https://github.com/DanceOlsson/physioengine-react/blob/main/src/components/dynamic-readers/DynamicQuestionnaireForm.tsx"
    click FC "https://github.com/DanceOlsson/physioengine-react/blob/main/src/components/features/questionnaires/QuestionnaireActionPanel.tsx"
    click UI "https://github.com/DanceOlsson/physioengine-react/tree/main/src/components/ui/"
    click MC "https://github.com/DanceOlsson/physioengine-react/blob/main/src/components/marketing/Features.tsx"
    click Hooks "https://github.com/DanceOlsson/physioengine-react/blob/main/src/hooks/useQuestionnaireResponses.ts"
    click TypeSystem "https://github.com/DanceOlsson/physioengine-react/blob/main/src/lib/types/questionnaire.types.ts"
    click Calculators "https://github.com/DanceOlsson/physioengine-react/blob/main/src/lib/calculators/dash.ts"
    click QData "https://github.com/DanceOlsson/physioengine-react/blob/main/src/assets/questionnaires/dash_swedish.ts"
    click Firebase "https://github.com/DanceOlsson/physioengine-react/blob/main/src/lib/firebase.ts"
```
