# davidn22/osanalytics architecture

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

- Interactive diagram: https://gitdiagram.com/davidn22/osanalytics
- Repository: https://github.com/davidn22/osanalytics

## Overview

##### Main System Components

a) Client Layer:
- React Frontend (TypeScript-based)
- Key frontend modules:
- Dashboard Components
- Authentication UI
- Charts/Visualization Components
- Click Tracking Hook Integration
- Playground Visualizations

b) Server Layer:
- Node.js/Express Backend
- Controllers for different functionalities
- Authentication Middleware
- Data Processing Services

c) External Services:
- AWS Services (Bedrock, Cognito)
- Database (PostgreSQL)
- OAuth Providers (Google)

##### Component Relationships

a) Client-Side Flow:
**User Interface → Click Tracker Hook → Data Collection → API Calls**

b) Server-Side Flow:
**API Routes → Middleware → Controllers → Database**

c) Authentication Flow:
**Login/Signup → AWS Cognito/OAuth → JWT → Protected Routes**

##### Specific Implementation Details

- Click Tracking System
- Real-time Data Visualization
- AI Report Generation (AWS Bedrock)
- Heatmap Generation
- Data Export Functionality

##### Data Flow Indicators

Critical data flows:
- Click data collection → Backend storage
- Data retrieval → Dashboard visualization
- User authentication flow
- AI processing pipeline

##### Technical Stack Representation

Technology badges for:
- React/TypeScript
- Node.js/Express
- PostgreSQL
- AWS Services
- Chart.js/React Flow
- Authentication services

##### Architectural Patterns

Patterns:
- MVC pattern in backend structure
- Component-based frontend architecture
- Middleware pipeline
- Service-oriented integration with AWS

**[User Interface Layer]**
- ↓
**[Frontend Services Layer]**
- ↓
**[API Gateway Layer]**
- ↓
**[Backend Services Layer]**
- ↓
**[Database Layer]**
- ↔
**[External Services Layer]**

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        UI[User Interface]
        DC["Dashboard Components"]
        Auth["Authentication UI"]
        Charts["Charts/Visualization"]
        CTH["Click Tracking Hook"]
        PG["Playground Visualizations"]
        StateM["State Management"]
        DataP["Data Processing"]
    end

    subgraph Server
        API["API Gateway"]
        AuthM["Auth Middleware"]
        BC["Backend Controllers"]
        DPS["Data Processing Services"]
    end

    subgraph External
        AWS["AWS Services"]
        DB[(PostgreSQL)]
        OAuth["OAuth Providers"]
    end

    %% Client Layer Connections
    UI --> DC
    UI --> Auth
    UI --> Charts
    UI --> CTH
    UI --> PG

    %% Server Layer Connections
    API --> AuthM
    AuthM --> BC
    BC --> DPS
    DPS --> DB

    %% Cross-Layer Connections
    CTH --> API
    Auth --> OAuth
    BC --> AWS
    StateM --> DataP
    DataP --> API

    %% External Service Connections
    OAuth --> AuthM
    AWS --> BC

    %% Click Events
    click DC "https://github.com/DavidN22/OSanalytics/blob/main/client/src/components/User/Dashboard.tsx"
    click Auth "https://github.com/DavidN22/OSanalytics/tree/main/client/src/components/Login"
    click Charts "https://github.com/DavidN22/OSanalytics/tree/main/client/src/components/ChartPages/Charts"
    click CTH "https://github.com/DavidN22/OSanalytics/blob/main/client/src/components/User/ClickLog.tsx"
    click PG "https://github.com/DavidN22/OSanalytics/tree/main/client/src/components/Playground"
    click BC "https://github.com/DavidN22/OSanalytics/tree/main/server/controllers"
    click AuthM "https://github.com/DavidN22/OSanalytics/tree/main/server/middleware"
    click DB "https://github.com/DavidN22/OSanalytics/blob/main/server/models/db.ts"
    click AWS "https://github.com/DavidN22/OSanalytics/blob/main/server/middleware/awsEncryption.ts"
    click API "https://github.com/DavidN22/OSanalytics/tree/main/server/routes"
    click StateM "https://github.com/DavidN22/OSanalytics/blob/main/client/src/state/Atoms.tsx"
    click DataP "https://github.com/DavidN22/OSanalytics/tree/main/client/src/services"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef auth fill:#f1c40f,stroke:#f39c12,color:black

    class UI,DC,Auth,Charts,CTH,PG,StateM,DataP frontend
    class API,AuthM,BC,DPS backend
    class AWS,OAuth external
    class DB database
```
