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
- Go to supabase.com
- Sign up or login
- Click "New Project"
- Fill in project details
- Wait for project to be provisioned
Get API Credentials
- Go to Project Settings → API
- Copy Project URL (SUPABASE_URL)
- Copy anon/public key (SUPABASE_KEY)
- Add these to your
.envfile
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
- Go to Google Cloud Console
- Create a new project or select existing
- Enable "Google+ API"
Create OAuth Credentials
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- Select "Web application"
- Add Authorized JavaScript origins:
http://localhost:5500http://127.0.0.1:5500
- Add Authorized redirect URIs:
http://localhost:5500http://127.0.0.1:5500
- Click "Create"
- Copy the Client ID and Client Secret
Configure OAuth in Application
- Add Client ID and Secret to
backend/.env - Edit
frontend/js/config.js - Update
GOOGLE_CLIENT_IDconstant
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
- Install "Live Server" extension in VS Code
- Right-click
index.html - 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
- Click "Sign Up" on homepage
- Create a test account
- Verify you're redirected to dashboard
- 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