# prince-24cs072/dataxpert architecture

> Architecture diagram of the GitHub repository prince-24cs072/dataxpert, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prince-24cs072/dataxpert
- Repository: https://github.com/prince-24cs072/dataxpert

## Overview

##### Project Type & Purpose
- Full-stack web application for AI-powered business data analytics and management.
- Frontend: vanilla JavaScript + Chart.js UI pages.
- Backend: Python Flask REST API with modular AI, authentication, and database layers.
- Database: Supabase (PostgreSQL).
- External services: Google OAuth, Supabase.

##### Key Components
a. Frontend Layer
- HTML/CSS/JS pages (index.html, dashboard.html, analysis.html)
- Chart.js visualizations
- OAuth & JWT client logic (auth.js, config.js)
- HTTP calls to backend API
b. Backend Layer (Flask app.py)
- Auth Service (backend/auth/auth_service.py): login, JWT issuance
- AI Modules (backend/ai/*): NLP processor, anomaly detector, analysis engine
- Database Client (backend/database/supabase_client.py)
- REST Controllers (app.py routes)
c. Database Layer
- Supabase (tables: users, teams, team_members, business_data, chats, analysis_results)
d. External Services
- Google OAuth 2.0
- Supabase
- (Optional) Email service for future notifications

##### Relationships & Data Flows
- User interacts with UI → HTTP request to Flask API
- Auth flow: Frontend → /auth endpoints → JWT → secured API calls
- Data operations: Backend → Supabase client → PostgreSQL
- AI analysis: Backend receives chat message → NLP & anomaly modules → stores results in analysis_results → Frontend polls/fetches results
- Google OAuth: Frontend & Backend endpoints ↔ Google identity servers

##### Architectural Patterns & Principles
- Layered architecture: Presentation (frontend), Business Logic (Flask + AI modules), Data Access (Supabase client), Database
- Modular design: Separate packages for auth, ai, database
- Stateless REST API with JWT security
- Externalize configuration via .env

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side (Browser)"
        direction TB
        index["index.html"]:::frontend
        dashPage["dashboard.html"]:::frontend
        analysisPage["analysis.html"]:::frontend
        subgraph "Styles & Scripts"
            direction TB
            styleCSS["style.css"]:::frontend
            dashCSS["dashboard.css"]:::frontend
            analCSS["analysis.css"]:::frontend
            mainJs["main.js"]:::frontend
            dashJs["dashboard.js"]:::frontend
            analysisJs["analysis.js"]:::frontend
            authJs["auth.js"]:::frontend
            configJs["config.js"]:::frontend
        end
    end

    %% Server Side
    subgraph "Server Side (Flask)"
        direction TB
        app["Flask API (app.py)"]:::backend
        subgraph "Auth Module"
            direction TB
            authService["Auth Service"]:::backend
        end
        subgraph "AI Module"
            direction TB
            nlp["NLP Processor"]:::backend
            anomaly["Anomaly Detector"]:::backend
            engine["Analysis Engine"]:::backend
        end
        dbClient["Supabase Client"]:::backend
        envExample[".env.example"]:::backend
        reqs["requirements.txt"]:::backend
    end

    %% Data & External Services
    subgraph "Data & External Services"
        direction TB
        supaDb["Supabase / PostgreSQL"]:::db
        google["Google OAuth 2.0"]:::external
    end

    %% Connections
    index -->|"load UI"| mainJs
    dashPage -->|"load Dashboard"| dashJs
    analysisPage -->|"load Analysis"| analysisJs
    mainJs -->|"HTTP/JSON"| app
    dashJs -->|"HTTP/JSON"| app
    analysisJs -->|"poll results"| app
    authJs -->|"OAuth Login"| authService
    authService -->|"issues JWT"| app
    app -->|"calls NLP"| nlp
    app -->|"calls Anomaly"| anomaly
    app -->|"calls Analysis"| engine
    engine -->|"store results"| dbClient
    app -->|"DB Query/Mutation"| dbClient
    dbClient -->|"SQL over HTTPS"| supaDb
    authService <-->|"OAuth Flow"| google

    %% Click Events
    click index "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/index.html"
    click dashPage "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/dashboard.html"
    click analysisPage "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/analysis.html"
    click styleCSS "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/css/style.css"
    click dashCSS "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/css/dashboard.css"
    click analCSS "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/css/analysis.css"
    click mainJs "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/js/main.js"
    click dashJs "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/js/dashboard.js"
    click analysisJs "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/js/analysis.js"
    click authJs "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/js/auth.js"
    click configJs "https://github.com/prince-24cs072/dataxpert/blob/main/frontend/js/config.js"
    click app "https://github.com/prince-24cs072/dataxpert/blob/main/backend/app.py"
    click authService "https://github.com/prince-24cs072/dataxpert/blob/main/backend/auth/auth_service.py"
    click nlp "https://github.com/prince-24cs072/dataxpert/blob/main/backend/ai/nlp_processor.py"
    click anomaly "https://github.com/prince-24cs072/dataxpert/blob/main/backend/ai/anomaly_detector.py"
    click engine "https://github.com/prince-24cs072/dataxpert/blob/main/backend/ai/analysis_engine.py"
    click dbClient "https://github.com/prince-24cs072/dataxpert/blob/main/backend/database/supabase_client.py"
    click envExample "https://github.com/prince-24cs072/dataxpert/blob/main/backend/.env.example"
    click reqs "https://github.com/prince-24cs072/dataxpert/blob/main/backend/requirements.txt"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#1E88E5,stroke-width:1px
    classDef backend fill:#C8E6C9,stroke:#388E3C,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#F57C00,stroke-width:1px
    classDef db fill:#CFD8DC,stroke:#607D8B,stroke-width:1px
```
