Complete Setup Guide

Step-by-step instructions to get DataXpert running on your system

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • Supabase account (free tier available)
  • Google OAuth credentials (optional)
  • Modern web browser (Chrome, Firefox, Edge, Safari)
  • Code editor (VS Code recommended)

Step 1: Clone Repository

git clone https://github.com/yourusername/DataXpert.git
cd DataXpert

Step 2: Backend Setup

Install Python Dependencies

cd backend
pip install -r requirements.txt

Create Environment File

cp .env.example .env

Configure Environment Variables

Edit the .env file with your credentials:

# Flask Configuration
SECRET_KEY=your-super-secret-key-change-this
JWT_SECRET_KEY=your-jwt-secret-key-change-this
FLASK_ENV=development
FLASK_DEBUG=True

# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-supabase-anon-key

# Google OAuth Configuration
GOOGLE_CLIENT_ID=your-google-oauth-client-id
GOOGLE_CLIENT_SECRET=your-google-oauth-client-secret

# Server Configuration
HOST=0.0.0.0
PORT=5000

Step 3: Supabase Setup

Create Supabase Project

  1. Go to supabase.com
  2. Sign up or login
  3. Click "New Project"
  4. Fill in project details
  5. Wait for project to be provisioned

Get API Credentials

  1. Go to Project Settings → API
  2. Copy Project URL (SUPABASE_URL)
  3. Copy anon/public key (SUPABASE_KEY)
  4. Add these to your .env file

Create Database Tables

Go to SQL Editor in Supabase and run these commands:

Users Table

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) UNIQUE NOT NULL,
    password VARCHAR(255),
    google_id VARCHAR(255) UNIQUE,
    role VARCHAR(50) DEFAULT 'user',
    created_at TIMESTAMP DEFAULT NOW()
);

Teams Table

CREATE TABLE teams (
    id SERIAL PRIMARY KEY,
    team_name VARCHAR(255) NOT NULL,
    owner_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
    created_at TIMESTAMP DEFAULT NOW()
);

Team Members Table

CREATE TABLE team_members (
    id SERIAL PRIMARY KEY,
    team_id INTEGER REFERENCES teams(id) ON DELETE CASCADE,
    user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
    role VARCHAR(50) DEFAULT 'member',
    joined_at TIMESTAMP DEFAULT NOW()
);

Business Data Table

CREATE TABLE business_data (
    id SERIAL PRIMARY KEY,
    user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
    record_date DATE NOT NULL,
    sales FLOAT NOT NULL,
    expenses FLOAT NOT NULL,
    profit FLOAT NOT NULL,
    category VARCHAR(100)
);

Chats Table

CREATE TABLE chats (
    id SERIAL PRIMARY KEY,
    user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
    message TEXT NOT NULL,
    response TEXT,
    timestamp TIMESTAMP DEFAULT NOW()
);

Analysis Results Table

CREATE TABLE analysis_results (
    id SERIAL PRIMARY KEY,
    chat_id INTEGER REFERENCES chats(id) ON DELETE CASCADE,
    summary TEXT NOT NULL,
    anomaly_score FLOAT DEFAULT 0.0,
    insight_level VARCHAR(50) NOT NULL,
    created_at TIMESTAMP DEFAULT NOW()
);

Step 4: Google OAuth Setup (Optional)

Create Google Cloud Project

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable "Google+ API"

Create OAuth Credentials

  1. Go to "APIs & Services" → "Credentials"
  2. Click "Create Credentials" → "OAuth client ID"
  3. Select "Web application"
  4. Add Authorized JavaScript origins:
    • http://localhost:5500
    • http://127.0.0.1:5500
  5. Add Authorized redirect URIs:
    • http://localhost:5500
    • http://127.0.0.1:5500
  6. Click "Create"
  7. Copy the Client ID and Client Secret

Configure OAuth in Application

  1. Add Client ID and Secret to backend/.env
  2. Edit frontend/js/config.js
  3. Update GOOGLE_CLIENT_ID constant

Step 5: Start Backend Server

cd backend
python app.py

You should see:

 * Running on http://0.0.0.0:5000
 * Debug mode: on

Step 6: Setup Frontend

Configure API Endpoint

Edit frontend/js/config.js:

// API Configuration
const API_BASE_URL = 'http://localhost:5000/api';

// Google OAuth Configuration
const GOOGLE_CLIENT_ID = 'your-google-client-id-here';

Start Frontend Server

Option 1: Python HTTP Server

cd frontend
python -m http.server 5500

Option 2: VS Code Live Server

  1. Install "Live Server" extension in VS Code
  2. Right-click index.html
  3. Select "Open with Live Server"

Option 3: Direct Browser Open

Simply double-click index.html (may have CORS issues)

Step 7: Verify Installation

Check Backend

Visit http://localhost:5000 in browser. You should see:

{
  "message": "Welcome to DataXpert API",
  "version": "1.0.0",
  "endpoints": {...}
}

Check Frontend

Visit http://localhost:5500 in browser. You should see the DataXpert homepage.

Test Authentication

  1. Click "Sign Up" on homepage
  2. Create a test account
  3. Verify you're redirected to dashboard
  4. Check browser console for errors

Troubleshooting

Backend Issues

Error: ModuleNotFoundError

Solution: Run pip install -r requirements.txt

Error: Supabase connection failed

Solution: Check SUPABASE_URL and SUPABASE_KEY in .env

Frontend Issues

Error: CORS policy blocked

Solution: Use Python HTTP Server or Live Server, not direct file opening

Error: Google Sign-In not loading

Solution: Verify GOOGLE_CLIENT_ID is correct in config.js

Next Steps

  • Read the Workflow Guide to understand how the app works
  • Check the ER Diagram to understand database structure
  • Explore the Folder Structure to navigate the codebase
  • Start adding business data and testing AI analysis