# vboudreau55/haze architecture

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

- Interactive diagram: https://gitdiagram.com/vboudreau55/haze
- Repository: https://github.com/vboudreau55/haze

## Overview

##### Main Components
a. Frontend:
- The React + Vite application, managed primarily within the “src” directory (e.g., src/App.tsx, src/pages, src/components, src/services).
- This layer includes all the UI pages (Landing, Home, About, Settings) and reusable components (charts, globe visualization, Navbar, country sensor table).
b. AWS Amplify Integration:
- The “amplify” directory holds configuration files and resources for authentication (amplify/auth/resource.ts) and data (amplify/data/resource.ts).
- Integration with AWS services (Cognito for Authentication, AppSync for API, DynamoDB for Database).
- The “amplify.yml” file indicates build and deployment configurations for connecting the frontend with these AWS services.
c. Backend / Lambda Functions:
- The “lambda” directory contains Python lambda functions (e.g., lambda/api_processing.py, lambda/lambda_funciton.py) which likely execute business logic or heavy processing.
d. External Elements:
- API endpoints exposed via Amplify and Lambda.
- Build and configuration tools (Vite, eslint, TypeScript configuration files) are also part of the development ecosystem but are not core to the architectural flow.

##### Relationships and Interactions
a. The Frontend communicates with AWS services via AWS Amplify, calling APIs (GraphQL via AppSync) and interacting with Cognito for user authentication.
b. The API requests may sometimes trigger AWS Lambda functions, as indicated by the presence of the lambda directory. This shows a separation where some business logic resides in Lambda functions rather than directly within Amplify.
c. The database layer (DynamoDB) is tied into the Amplify configuration and works behind the scenes to support real-time data requirements.

##### Architectural Patterns and Design Principles
a. Separation of Concerns: Clear partitioning between UI (React components/pages), business logic (services and lambda functions), and backend configuration (AWS Amplify).
b. Microservices Elements: Use of separate Lambda functions for API processing allows modular and scalable functions.
c. Client-Server Model: The frontend acts primarily as the client interface, while AWS Amplify and Lambda provide server-side processing and data management.

##### Relevant Technologies and Frameworks
- Frontend: React, Vite, TypeScript.
- AWS Services: Amplify, AWS Cognito, AWS AppSync, AWS DynamoDB.
- Backend: AWS Lambda (Python-based functions).
- Development Tools: ESLint, TypeScript, configuration files (tsconfig.json, vite.config.ts).

##### Elements
- Use clear, easily understandable labels for each component (e.g., “React Frontend”, “AWS Cognito”, “AWS AppSync”, “AWS DynamoDB”, “Lambda Functions”).
- User → React Frontend → AWS Amplify API → AWS AppSync and/or Lambda Functions.
- Lambda Functions → Data Storage (DynamoDB).
- Relationships where appropriate – noting that authentication flows will go through Cognito, API calls through AppSync, and so on.

- Frontend to the AWS Amplify service layer, indicating pathways for authentication (linking to AWS Cognito), API requests (linking to AWS AppSync), and data transactions (linking to DynamoDB).
- Supportive configuration elements (like “amplify.yml”, “package.json”) in an annotations area to indicate deployment and build management, if necessary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        User("User"):::external
        React("React Frontend"):::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        Amplify("AWS Amplify Integration"):::backend
    end

    %% Integration Layer
    subgraph "Integration Layer"
        Cognito("AWS Cognito"):::integrations
        AppSync("AWS AppSync"):::integrations
    end

    %% Backend Services
    subgraph "Backend Services"
        Lambda("Lambda Functions"):::lambda
    end

    %% Data Layer
    subgraph "Data Layer"
        Dynamo("AWS DynamoDB"):::database
    end

    %% Connections
    User -->|"initiates"| React
    React -->|"calls"| Amplify
    Amplify -->|"authenticates_via"| Cognito
    Amplify -->|"api_calls_to"| AppSync
    Amplify -->|"data_operations_on"| Dynamo
    AppSync -->|"triggers"| Lambda
    Lambda -->|"reads_writes"| Dynamo

    %% Click Events
    click React "https://github.com/vboudreau55/haze/tree/main/src"
    click Amplify "https://github.com/vboudreau55/haze/tree/main/amplify"
    click Lambda "https://github.com/vboudreau55/haze/tree/main/lambda"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef backend fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef integrations fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef lambda fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef database fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef external fill:#D5DBDB,stroke:#808B96,stroke-width:2px;
```
