# dlquake/weather-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/dlquake/weather-dashboard
- Repository: https://github.com/dlquake/weather-dashboard

## Overview

##### Main System Components

a) Frontend Layer (React.js)
- Main React components structure
- Features: Authentication, Dashboard, Weather Data Visualization, Forecast Reports
- Redux store (authSlice) for state management

b) Backend Layer (Dual Server Architecture)
- Express.js Server
- Authentication services
- Data management endpoints
- User management
- Flask Python Server
- Machine Learning components
- Weather analysis algorithms

c) Database Layer
- Relationships between tables (users, forecast, location, weatherdata, report)

##### Component Relationships and Data Flow

- Frontend → Express.js Backend: RESTful API calls
- Express.js Backend → PostgreSQL: Data persistence
- Frontend → Flask Backend: ML-related requests
- Express.js ↔ Flask: Inter-server communication

##### Specific Design Elements

Components with distinct visual representations:

- Authentication components (Login, Register)
- Dashboard components
- Weather visualization components
- Report generation components

- Express.js Controllers (Auth, Forecast, Location, Report, Users, WeatherData)
- Flask ML Services
- Middleware layer (Authentication)

##### Additional Elements

- External Services integration points
- Security layer (AuthUser middleware)
- Data processing pipeline for weather analysis
- ML model integration points

##### Important Notes

- Separation between public and authenticated areas
- ML research component (reference the Badania directory)
- PDF generation workflow
- Data flow for weather forecasting process

- User authentication flow
- Weather data analysis pipeline
- Forecast generation process
- Report creation and management

This system design should reflect the full-stack nature of the application while emphasizing its core purpose as a weather data analysis and forecasting tool.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef backend fill:#e8f5e9,stroke:#1b5e20
    classDef database fill:#fff3e0,stroke:#ff6f00
    classDef ml fill:#f3e5f5,stroke:#4a148c
    classDef api fill:#ffebee,stroke:#b71c1c

    %% Frontend Layer
    subgraph Frontend
        Auth[Authentication Components]
        Dashboard[Dashboard Interface]
        WeatherViz[Weather Visualization]
        ForecastUI[Forecast Reports UI]
        Redux[Redux Store]
        PDFGen[PDF Generator]
    end

    %% Backend Layer
    subgraph ExpressBackend
        AuthService[Auth Service]
        DataService[Weather Data Service]
        LocationService[Location Service]
        ReportService[Report Service]
        UserService[User Service]
        AuthMiddleware[Auth Middleware]
    end

    subgraph FlaskBackend
        MLServer[ML Server]
        MLModels[ML Models]
        WeatherAnalysis[Weather Analysis]
    end

    %% Database Layer
    subgraph Database
        Users[(Users)]
        WeatherData[(Weather Data)]
        Locations[(Locations)]
        Forecasts[(Forecasts)]
        Reports[(Reports)]
    end

    %% ML Research
    subgraph MLResearch
        MLAlgorithms[ML Algorithms Research]
    end

    %% Relationships
    Auth --> AuthService
    Dashboard --> DataService
    WeatherViz --> DataService
    ForecastUI --> ReportService
    Auth --> Redux
    Dashboard --> Redux

    AuthService --> Users
    DataService --> WeatherData
    LocationService --> Locations
    ReportService --> Reports
    UserService --> Users

    DataService --> MLServer
    MLServer --> MLModels
    MLModels --> WeatherAnalysis
    WeatherAnalysis --> Forecasts

    %% Component Mappings
    click Auth "https://github.com/DLQuake/Weather-Dashboard/blob/main/frontend/src/components/Login.jsx"
    click Dashboard "https://github.com/DLQuake/Weather-Dashboard/blob/main/frontend/src/pages/Dashboard.jsx"
    click WeatherViz "https://github.com/DLQuake/Weather-Dashboard/blob/main/frontend/src/components/WeatherdatasList.jsx"
    click ForecastUI "https://github.com/DLQuake/Weather-Dashboard/blob/main/frontend/src/components/ForecastReports.jsx"
    click Redux "https://github.com/DLQuake/Weather-Dashboard/blob/main/frontend/src/features/authSlice.js"
    click PDFGen "https://github.com/DLQuake/Weather-Dashboard/blob/main/frontend/src/components/PDFGenerator.jsx"
    click AuthService "https://github.com/DLQuake/Weather-Dashboard/blob/main/backend/controllers/Auth.js"
    click DataService "https://github.com/DLQuake/Weather-Dashboard/blob/main/backend/controllers/WeatherData.js"
    click LocationService "https://github.com/DLQuake/Weather-Dashboard/blob/main/backend/controllers/Location.js"
    click ReportService "https://github.com/DLQuake/Weather-Dashboard/blob/main/backend/controllers/Report.js"
    click UserService "https://github.com/DLQuake/Weather-Dashboard/blob/main/backend/controllers/Users.js"
    click AuthMiddleware "https://github.com/DLQuake/Weather-Dashboard/blob/main/backend/middleware/AuthUser.js"
    click MLServer "https://github.com/DLQuake/Weather-Dashboard/blob/main/backend/FlaskPythonServer/app.py"
    click MLAlgorithms "https://github.com/DLQuake/Weather-Dashboard/blob/main/Badania/BadanieAlgorytmowML_Warsaw.ipynb"

    %% Styling
    class Auth,Dashboard,WeatherViz,ForecastUI,Redux,PDFGen frontend
    class AuthService,DataService,LocationService,ReportService,UserService,AuthMiddleware backend
    class Users,WeatherData,Locations,Forecasts,Reports database
    class MLServer,MLModels,WeatherAnalysis ml
    class MLAlgorithms ml
```
