# kamchettysadhika/realitysync- architecture

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

- Interactive diagram: https://gitdiagram.com/kamchettysadhika/realitysync-
- Repository: https://github.com/kamchettysadhika/realitysync-

## Overview

##### Project Type and Purpose
- RealitySync is a microservices-based, AI-powered field intelligence platform built on Node.js/TypeScript with Python forecasting components.
- It combines anomaly detection, predictive forecasting, AI-driven orchestration, and automated communication to streamline field operations.

##### File Structure and Key Modules
- Top-level entry: index.ts
- Core services (root folder and services/):
- anomalyEngine.ts (rules engine for anomaly detection)
- forecast/ (forecast_input.csv, forecast_output.json)
- simulateAnomaly.ts
- services/exportFeedback.ts, services/triggerActions.ts
- mulesoft.ts, salesforce.ts, sensors.ts, slack.ts
- src/ – higher-level modules organized by capability:
- src/forecast (Prophet model in Python, timeseries.ts)
- src/llm (agent tuning, prompt management)
- src/agents (autonomycommander, executeresponse)
- src/pipeline.ts (workflow coordination)
- src/services (coordination.ts, monitor.ts)
- src/slack (handlers, monitor integration)
- src/monitor (metrics, export to CSV)

##### README for Architectural Insights
- Four major subsystems:
1. Predictive Intelligence Engine (ML/anomaly + GPT-4)
2. Intelligent Workflow Orchestration (GPT planner + rules)
3. Automated Communication Hub (Slack API, Service Cloud, OAuth2)
4. Real-Time Dashboard Intelligence (Tableau + data pipelines)
- Microservices architecture on MERN stack, serverless-friendly, stateless OAuth2.

##### Out Main Components
a. Data Ingestion & Storage
- Event DB (db/logEvent.ts)
- Forecast input (CSV, timeseries.json)
b. Predictive Intelligence Service
- Anomaly Detection Engine (rules/anomalyEngine.ts)
- Forecast Service (forecast folder + src/forecast/prophet_forecast.py)
- LLM-based pattern learner (src/LLM-representation.ts, src/llm)
c. Workflow Orchestration Service
- pipeline.ts, src/pipeline.ts
- GPT-4 Planner (tunedprompt.ts, tuneAgent.ts)
d. Communication Hub
- Slack integration (slack.ts, src/slack/)
- Service Cloud integration (salesforce.ts)
- Mulesoft connector (mulesoft.ts)
- Feedback loop (services/exportFeedback.ts)
e. Monitoring & Dashboard
- Metrics collection (src/monitor/metrics.ts)
- CSV export (monitortoCSV.ts)
- Tableau pipeline (external)

##### Interactions and Data Flows
1. Raw events → Ingestion layer → Event DB
2. DB → Anomaly Detection → Forecast Service → LLM learner
3. LLM output + rules → Orchestration Engine → dispatch recommendation
4. Orchestration → triggers → Slack API, Service Cloud, Mulesoft
5. Field responses → exportFeedback → update DB → monitoring
6. Monitoring metrics → real-time dashboard (Tableau)

##### Architectural Patterns
- Microservices communicating via asynchronous triggers or REST calls
- Stateless OAuth2 for external API auth
- Hybrid model: Node.js for orchestration and integration, Python for forecasting
- Modular folder layout mirrors service boundaries

##### Technologies & Frameworks to Annotate
- Node.js + TypeScript, Python + Prophet
- GPT-4 API
- Slack SDK, Salesforce Service Cloud API, Mulesoft
- Tableau for real-time dashboards
- Durable storage (file-based CSV/JSON and a DB for events)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layer 1: Data Ingestion & Storage
    subgraph "Data Ingestion & Storage"
        direction TB
        DB["Event DB"]:::data
        CSVIN["Forecast Input CSV"]:::data
        CSVOUT["Forecast Output JSON"]:::data
        SENSOR["Sensors Stream & Simulator"]:::service
    end

    %% Layer 2: Predictive Intelligence Service
    subgraph "Predictive Intelligence Service"
        direction TB
        ANOM["Anomaly Detection Engine"]:::service
        FORECAST["Forecast Service"]:::service
        PYTHON["Prophet Forecast (Python)"]:::service
        TIMESERIES["Time Series Processor"]:::service
        LLMREP["LLM‐based Pattern Learner"]:::service
    end

    %% Layer 3: Workflow Orchestration Service
    subgraph "Workflow Orchestration Service"
        direction TB
        ENTRY["Orchestration Entry (index.ts)"]:::service
        PIPELINE["Pipeline Coordinator"]:::service
        ROUTE["Routing Map"]:::service
        AGENTS["GPT‐4 Planner & Agent Executors"]:::service
    end

    %% Layer 4: Communication Hub
    subgraph "Communication Hub"
        direction TB
        SLACK_ROOT["Slack Integration"]:::external
        SLACK_HAND["Slack Handlers"]:::service
        SLACK_MON["Slack Monitor"]:::service
        SF["Service Cloud (Salesforce)"]:::external
        MULE["Mulesoft Connector"]:::external
        TRIGGERS["Trigger Actions"]:::service
        FEEDBACK["Export Feedback"]:::service
    end

    %% Layer 5: Monitoring & Dashboard
    subgraph "Monitoring & Dashboard"
        direction TB
        METRICS["Metrics Collection"]:::service
        CSVEXP["CSV Export Utility"]:::service
        TABLEAU["Real-Time Dashboard (Tableau)"]:::external
    end

    %% Data Flows
    DB -->|"fetch events"| ANOM
    CSVIN -->|input data| FORECAST
    FORECAST -->|forecast results| CSVOUT
    TIMESERIES -->|prepare ts| PYTHON
    ANOM -->|anomaly data| LLMREP
    PYTHON -->|model output| LLMREP
    LLMREP -->|patterns| ENTRY
    ENTRY -->|orchestrate| PIPELINE
    PIPELINE -->|route tasks| ROUTE
    ROUTE -->|invoke agents| AGENTS
    AGENTS -->|dispatch| SLACK_ROOT
    AGENTS -->|dispatch| SF
    AGENTS -->|dispatch| MULE
    SLACK_ROOT -->|handle| SLACK_HAND
    SLACK_HAND -->|monitor events| SLACK_MON
    SLACK_MON -->|feedback| FEEDBACK
    SF -->|feedback| FEEDBACK
    MULE -->|feedback| FEEDBACK
    FEEDBACK -->|update| DB
    FEEDBACK -->|notify monitor| METRICS
    METRICS -->|export metrics| CSVEXP
    CSVEXP -->|data| TABLEAU

    %% Click Events
    click DB "https://github.com/kamchettysadhika/realitysync-/blob/main/db/logEvent.ts"
    click CSVIN "https://github.com/kamchettysadhika/realitysync-/blob/main/forecast/forecast_input.csv"
    click CSVOUT "https://github.com/kamchettysadhika/realitysync-/blob/main/forecast/forecast_output.json"
    click SENSOR "https://github.com/kamchettysadhika/realitysync-/blob/main/simulateAnomaly.ts"
    click SENSOR "https://github.com/kamchettysadhika/realitysync-/blob/main/sensors.ts"
    click ANOM "https://github.com/kamchettysadhika/realitysync-/blob/main/rules/anomalyEngine.ts"
    click FORECAST "https://github.com/kamchettysadhika/realitysync-/blob/main/forecast/forecast_input.csv"
    click FORECAST "https://github.com/kamchettysadhika/realitysync-/blob/main/forecast/forecast_output.json"
    click PYTHON "https://github.com/kamchettysadhika/realitysync-/blob/main/src/forecast/prophet_forecast.py"
    click TIMESERIES "https://github.com/kamchettysadhika/realitysync-/blob/main/src/forecast/timeseries.ts"
    click TIMESERIES "https://github.com/kamchettysadhika/realitysync-/blob/main/src/forecast/timeseries.json"
    click TIMESERIES "https://github.com/kamchettysadhika/realitysync-/blob/main/src/run_forecast.py"
    click LLMREP "https://github.com/kamchettysadhika/realitysync-/blob/main/src/LLM-representation.ts"
    click LLMREP "https://github.com/kamchettysadhika/realitysync-/blob/main/src/llm/tuneAgent.ts"
    click LLMREP "https://github.com/kamchettysadhika/realitysync-/blob/main/src/llm/tunedprompt.ts"
    click ENTRY "https://github.com/kamchettysadhika/realitysync-/blob/main/index.ts"
    click PIPELINE "https://github.com/kamchettysadhika/realitysync-/blob/main/src/pipeline.ts"
    click ROUTE "https://github.com/kamchettysadhika/realitysync-/blob/main/src/routingmap.ts"
    click AGENTS "https://github.com/kamchettysadhika/realitysync-/blob/main/src/agents/autonomycommander.ts"
    click AGENTS "https://github.com/kamchettysadhika/realitysync-/blob/main/src/executeresponse.ts"
    click SLACK_ROOT "https://github.com/kamchettysadhika/realitysync-/blob/main/slack.ts"
    click SLACK_HAND "https://github.com/kamchettysadhika/realitysync-/blob/main/src/slack/checkinhandler.ts"
    click SLACK_MON "https://github.com/kamchettysadhika/realitysync-/blob/main/src/slack/monitor.ts"
    click SF "https://github.com/kamchettysadhika/realitysync-/blob/main/salesforce.ts"
    click MULE "https://github.com/kamchettysadhika/realitysync-/blob/main/mulesoft.ts"
    click TRIGGERS "https://github.com/kamchettysadhika/realitysync-/blob/main/services/triggerActions.ts"
    click FEEDBACK "https://github.com/kamchettysadhika/realitysync-/blob/main/services/exportFeedback.ts"
    click METRICS "https://github.com/kamchettysadhika/realitysync-/blob/main/src/monitor/metrics.ts"
    click CSVEXP "https://github.com/kamchettysadhika/realitysync-/blob/main/src/monitor/export/monitortoCSV.ts"

    %% Styles
    classDef service fill:#cce5ff,stroke:#004085,color:#004085
    classDef data fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
```
