Folder Structure

Complete project organization and file structure

Project Structure

DataXpert/
│
├── backend/                    # Backend application
│   ├── ai/                     # AI and analysis modules
│   │   ├── __init__.py
│   │   ├── analysis_engine.py  # Main analysis engine
│   │   ├── nlp_processor.py    # NLP processing
│   │   └── anomaly_detector.py # Anomaly detection
│   │
│   ├── auth/                   # Authentication module
│   │   ├── __init__.py
│   │   └── auth_service.py     # Auth logic & Google OAuth
│   │
│   ├── database/               # Database module
│   │   ├── __init__.py
│   │   └── supabase_client.py  # Supabase operations
│   │
│   ├── app.py                  # Main Flask application
│   ├── requirements.txt        # Python dependencies
│   └── .env.example            # Environment variables template
│
├── frontend/                   # Frontend application
│   ├── css/                    # Stylesheets
│   │   ├── style.css           # Main styles
│   │   ├── dashboard.css       # Dashboard styles
│   │   └── analysis.css        # Analysis page styles
│   │
│   ├── js/                     # JavaScript files
│   │   ├── config.js           # Configuration & API endpoints
│   │   ├── auth.js             # Authentication logic
│   │   ├── main.js             # Homepage logic
│   │   ├── dashboard.js        # Dashboard logic
│   │   └── analysis.js         # AI analysis logic
│   │
│   ├── index.html              # Homepage
│   ├── dashboard.html          # Dashboard page
│   └── analysis.html           # AI analysis page
│
└── documentation/              # Documentation website
    ├── css/                    # Documentation styles
    │   └── docs.css
    │
    ├── js/                     # Documentation scripts
    │   └── docs.js
    │
    ├── images/                 # Documentation images
    │   ├── er-diagram.png
    │   └── flow-diagram.png
    │
    ├── index.html              # Documentation home
    ├── workflow.html           # Workflow documentation
    ├── er-diagram.html         # Database schema
    ├── folder-structure.html   # This file
    ├── architecture.html       # System architecture
    └── setup.html              # Setup guide

Backend Structure Details

AI Module (backend/ai/)

  • analysis_engine.py - Core analysis logic, performs statistical analysis, generates insights
  • nlp_processor.py - Natural language processing, intent extraction, entity recognition
  • anomaly_detector.py - Anomaly detection using Z-scores and IQR methods

Auth Module (backend/auth/)

  • auth_service.py - Handles user authentication, password hashing, Google OAuth

Database Module (backend/database/)

  • supabase_client.py - All database operations, CRUD for all tables

Main Application (backend/app.py)

  • Flask application setup
  • API endpoints definition
  • Middleware configuration
  • CORS setup

Frontend Structure Details

HTML Pages

  • index.html - Landing page with login/signup modals
  • dashboard.html - Main dashboard with charts and stats
  • analysis.html - AI chat interface for data analysis

CSS Files

  • style.css - Global styles, components, utilities
  • dashboard.css - Dashboard-specific styles
  • analysis.css - AI analysis page styles

JavaScript Files

  • config.js - API configuration, endpoints, helpers
  • auth.js - Authentication logic, Google OAuth integration
  • main.js - Homepage interactivity, modal management
  • dashboard.js - Dashboard data loading, chart rendering
  • analysis.js - AI chat functionality, analysis display

Documentation Structure

The documentation website is completely separate from the main application and provides comprehensive guides:

  • Getting Started: Overview, setup guide, workflow
  • Architecture: System design, database schema, folder structure
  • Features: Detailed feature documentation
  • About: SGP Group info, contact details

Key Files Explained

backend/app.py

The main Flask application file. Contains all API endpoints:

  • Authentication endpoints (/api/auth/*)
  • User management (/api/user/*)
  • Team operations (/api/teams/*)
  • Business data (/api/business/*)
  • AI analysis (/api/ai/*)
  • Dashboard (/api/dashboard/*)

frontend/js/config.js

Central configuration file containing:

  • API base URL
  • Google Client ID
  • All API endpoints
  • Helper functions (auth headers, logout, etc.)

backend/ai/analysis_engine.py

Core AI analysis engine that:

  • Analyzes sales, profit, expenses
  • Detects trends and patterns
  • Generates insights and recommendations
  • Prepares data for visualizations

Configuration Files

backend/requirements.txt

Python dependencies:

  • Flask - Web framework
  • Flask-CORS - Cross-origin requests
  • PyJWT - JWT token handling
  • pandas, numpy - Data analysis
  • supabase - Database client
  • google-auth - Google OAuth

backend/.env

Environment variables (create from .env.example):

  • SECRET_KEY - Flask secret key
  • JWT_SECRET_KEY - JWT signing key
  • SUPABASE_URL - Supabase project URL
  • SUPABASE_KEY - Supabase API key
  • GOOGLE_CLIENT_ID - Google OAuth client ID