# tarun1801/rackathon_binarybeast_admin_dasboard architecture

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

- Interactive diagram: https://gitdiagram.com/tarun1801/rackathon_binarybeast_admin_dasboard
- Repository: https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard

## Overview

##### Project type and purpose
- This is a full-stack web application built for Rakathon’22.
- Purpose: ingest WhatsApp chat data via whatsapp-web.js, load it into a Neo4j graph database, run content/context-aware filtering and analytics, and surface actionable sales insights to both small vendors (frontend) and external consumers (B2B APIs for MNCs).

##### File structure
- Top-level directories:
- Shop_Frontend – React single-page application.
- Whatsaap_DB/rakathon22-neo4j-analytics-utkarsh – Node.js/Express backend with:
⁃ example.js – sample ingestion or test script.
⁃ routes.js – HTTP API endpoints.
⁃ model.js – Neo4j data-model and analytics logic.
⁃ package.json – dependencies including express, neo4j-driver, whatsapp-web.js.
- Whatsaap_DB/.wwebjs_auth – session storage for whatsapp-web.js.
- insight.ipynb – Jupyter notebook used for exploratory analysis.

##### README
- Confirms use of Neo4j, content/context filtering, target is to connect small businesses with tourism/food MNCs.

##### Main components
a. Frontend (React SPA)
- UI components under Shop_Frontend/src/components
- Static assets served from public/index.html
b. Backend (Node.js / Express)
- API layer (routes.js)
- Business logic & data-model (model.js)
- WhatsApp ingestion module (whatsapp-web.js using .wwebjs_auth for credentials)
c. Database
- Neo4j graph DB (hosted or local instance)
d. External services
- WhatsApp Web service (via whatsapp-web.js)
- Potential B2B consumers (Swiggy, Zomato, Makemytrip, etc.) – future API clients
e. Data-science/analysis
- Jupyter notebook (insight.ipynb) – offline analytics and model prototyping

##### Relationships & interactions
- User in browser → React SPA
- React SPA ↔ HTTP REST (or GraphQL) → Express API endpoints
- Express → (1) whatsapp-web.js client to fetch new chat messages → stores session under .wwebjs_auth
(2) neo4j-driver → persists and queries graph data
- Analytics results → exposed via API → consumed by React or third-party clients
- Notebook connects directly to Neo4j for advanced off-line analysis

##### Architectural patterns & design principles
- Separation of concerns:
- Presentation Layer (React)
- API Layer (Express routes)
- Data Layer (Neo4j + whatsapp ingestion)
- Modular services: whatsapp ingestion can be factored as its own microservice or background worker
- Graph-oriented data model for relationships (customers ↔ vendors ↔ products)
- Future extensibility: external MNC clients treated as API consumers, authentication/authorization plug-points

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Layer"
        React["React SPA"]:::frontend
        Components["UI Components"]:::frontend
        Static["Static Assets (index.html)"]:::frontend
    end

    subgraph "Backend Layer"
        subgraph "API Server"
            Routes["Express API Server"]:::backend
            Model["Business Logic & Neo4j Model"]:::backend
        end
        subgraph "Ingestion Service"
            Ingestion["WhatsApp-web.js Client"]:::backend
            Auth["Session Storage (.wwebjs_auth)"]:::backend
        end
        Config["Backend Config & Dependencies"]:::backend
    end

    DB["Neo4j Database"]:::database

    Notebook["Jupyter Notebook"]:::analysis

    ExternalWhats["WhatsApp Web Service"]:::external
    ExternalMNC["External MNC Clients"]:::external
    User["User Browser"]:::external

    User --> React
    React -->|HTTP REST/API| Routes
    Routes -->|invoke| Model
    Model -->|Cypher Queries| DB
    Routes -->|future B2B APIs| ExternalMNC
    Routes -->|trigger ingest| Ingestion
    Ingestion -->|uses| Auth
    Ingestion -->|connects| ExternalWhats
    Notebook -->|direct Neo4j access| DB

    click React "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/tree/main/Shop_Frontend/"
    click Components "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/tree/main/Shop_Frontend/src/components/"
    click Static "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/blob/main/Shop_Frontend/public/index.html"
    click Routes "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/blob/main/Whatsaap_DB/rakathon22-neo4j-analytics-utkarsh/routes.js"
    click Model "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/blob/main/Whatsaap_DB/rakathon22-neo4j-analytics-utkarsh/model.js"
    click Ingestion "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/blob/main/Whatsaap_DB/rakathon22-neo4j-analytics-utkarsh/example.js"
    click Auth "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/tree/main/Whatsaap_DB/rakathon22-neo4j-analytics-utkarsh/.wwebjs_auth/"
    click Config "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/blob/main/Whatsaap_DB/rakathon22-neo4j-analytics-utkarsh/package.json"
    click Notebook "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/blob/main/insight.ipynb"
    click README "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/blob/main/README.md"
    click README_Frontend "https://github.com/tarun1801/rackathon_binarybeast_admin_dasboard/blob/main/Shop_Frontend/README.md"

    classDef frontend fill:#D6EAF8,stroke:#1B4F72,color:#1B4F72
    classDef backend fill:#D5F5E3,stroke:#196F3D,color:#196F3D
    classDef database fill:#FCF3CF,stroke:#B7950B,color:#7D6608
    classDef external fill:#E5E7E9,stroke:#7F8C8D,color:#7F8C8D
    classDef analysis fill:#EBDEF0,stroke:#7D3C98,color:#7D3C98
```
