# abduldayyan1/my-works architecture

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

- Interactive diagram: https://gitdiagram.com/abduldayyan1/my-works
- Repository: https://github.com/abduldayyan1/my-works

## Overview

##### Project type and purpose
- From the README, this repo bundles two full-stack assignments:
a) A **Rule Engine** service (Flask + PostgreSQL + React) that parses and evaluates user-defined logical rules via an AST.
b) A **Weather Monitoring System** (Flask + OpenWeatherMap API + React) that fetches, processes, stores, and visualizes real-time weather data.

##### File structure
- The two core apps live conceptually under:
- `backend/` (Flask apps)
- `frontend/` (React UIs)
- `weather-app/` (Node baseline or reference implementation)
- Key configuration and dependency files: `pyproject.toml`, `package.json`, database schema SQL, `requirements.txt`, and `package-lock.json`.

##### README for architectural details
- Rule Engine:
- REST API endpoints (/api/rules, /api/evaluate) on Flask
- PostgreSQL for rule storage and audit
- React frontend calling those endpoints
- Weather Monitoring:
- Flask service with `weather.py` modules fetching from OpenWeatherMap
- (Optional) PostgreSQL for historical storage
- React components for charts and UI

##### Main components and interactions
- User’s Web Browser (UI)
- React Frontend (two apps or a combined UI)
- Flask Backend(s) (Rule Engine service; Weather service)
- PostgreSQL Database (for Rule Engine; optionally for Weather)
- External OpenWeatherMap API
b. Relationships and data flows:
- Browser → HTTP(S) → React Frontend
- Frontend → HTTP(S) → Flask Backend(s)
- Flask → SQL → PostgreSQL
- Weather service → HTTPS → OpenWeatherMap
- Flask → Response → Frontend → Browser
c. Architectural patterns
- **Separation of Concerns**: clear front/back split, each service in its own module
- **Micro-service flavor**: two independent services (Rule Engine vs Weather)
- **RESTful API** communication
- **AST Pattern** internally for rule parsing (annotate as an internal library component)
d. Relevant technologies
- Python + Flask + psycopg2
- React + Node (npm)
- PostgreSQL
- External HTTP API

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Rule Engine Domain
    subgraph "Rule Engine Domain"
        direction TB
        Browser1("User's Web Browser"):::external
        RuleFrontend("Rule Engine Frontend (React)"):::frontend
        RuleAPI("Rule Engine API (Flask)"):::backend
        ASTParser("AST Parser Module"):::backend
        RuleDB[(PostgreSQL Database)]:::db
    end

    %% Weather Monitoring Domain
    subgraph "Weather Monitoring Domain"
        direction TB
        Browser2("User's Web Browser"):::external
        WeatherFrontend("Weather Monitoring Frontend (React)"):::frontend
        WeatherAPI("Weather Service (Flask)"):::backend
        OpenWeather("OpenWeatherMap API"):::external
        WeatherDB[(PostgreSQL Database)]:::db
    end

    %% Interactions Rule Engine
    Browser1 -->|"HTTP Request"| RuleFrontend
    RuleFrontend -->|"REST API Calls"| RuleAPI
    RuleAPI -->|"Uses"| ASTParser
    RuleAPI -->|"SQL Queries"| RuleDB
    RuleDB -->|"Data Response"| RuleAPI
    RuleAPI -->|"HTTP Response"| RuleFrontend
    RuleFrontend -->|"Render UI"| Browser1

    %% Interactions Weather Monitoring
    Browser2 -->|"HTTP Request"| WeatherFrontend
    WeatherFrontend -->|"REST API Calls"| WeatherAPI
    WeatherAPI -->|"HTTPS Request"| OpenWeather
    OpenWeather -->|"Weather Data"| WeatherAPI
    WeatherAPI -->|"Optional SQL"| WeatherDB
    WeatherDB -->|"Data Response"| WeatherAPI
    WeatherAPI -->|"HTTP Response"| WeatherFrontend
    WeatherFrontend -->|"Render UI"| Browser2

    %% Shared Project Metadata
    subgraph "Project Metadata & Tooling"
        direction TB
        RootNPM("NPM Project Root (package.json)"):::metadata
        RootPy("Python Project Root (pyproject.toml)"):::metadata
        Linter("Linter/IDE Extensions (.replit/extensions.json)"):::metadata
    end

    %% Click Events
    click RuleFrontend "https://github.com/abduldayyan1/my-works/blob/main/frontend/index.html"
    click RuleAPI "https://github.com/abduldayyan1/my-works/blob/main/backend/main.py"
    click RootPy "https://github.com/abduldayyan1/my-works/blob/main/pyproject.toml"
    click RootNPM "https://github.com/abduldayyan1/my-works/blob/main/package.json"
    click WeatherAPI "https://github.com/abduldayyan1/my-works/blob/main/weather-app/app.js"
    click MetadataNPM "https://github.com/abduldayyan1/my-works/blob/main/package.json"
    click WeatherPkg "https://github.com/abduldayyan1/my-works/blob/main/weather-app/package.json"
    click WeatherLock "https://github.com/abduldayyan1/my-works/blob/main/weather-app/package-lock.json"
    click WeatherNodeMod "https://github.com/abduldayyan1/my-works/tree/main/weather-app/node_modules"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef backend fill:#d4edda,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    classDef db fill:#fff3cd,stroke:#333,stroke-width:1px;
    classDef external fill:#f8d7da,stroke:#333,stroke-width:1px;
    classDef metadata fill:#e2e3e5,stroke:#333,stroke-width:1px;
```
