# Project export: VisionZ+

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: TreeHacks 2025
- Tagline: VisionZ+ is your data scientist. It’s a big data analytics and visualization dashboard that transforms any dataset into sleek graphs, killer insights, and bold predictions. Drag, drop, and dominate.
- Devpost: https://devpost.com/software/visionz
- GitHub: https://github.com/AntoDono/visionzplus
- Video: https://www.youtube.com/embed/8bB2tO9vXhY?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 3 GitHub contributor(s) — AntoDono (34 commits), Taorui Huang (13 commits), Nick (2 commits)

## Devpost submission (written by the team)

### Overview

VisionZ+ is your data scientist. Our Team!!

### Inspiration

We are mainly interested in Palmer Luckey's disruptive innovations in defense systems and Marc Andreessen's forward-thinking vision of technology, this project embraces American dynamism to empower military personnel. The aim is to leverage cutting-edge wearable tech to boost productivity and efficiency on the field.

### What it does

VisionZ+ is a first-of-its-kind data visualization and analysis platform that lets users analyze any dataset through a simple drag-and-drop interface. With our dataset assistant, you can simply ask questions about your data and let the AI find patterns and insights for you. The platform is powered by a Multi-Agent AI Architecture that processes data through multiple specialized agents - from initial analysis and orchestration to planning, execution via mini-agent swarms, and validation. This makes sophisticated data analysis accessible to anyone, regardless of their technical background. Whether you're a medical researcher analyzing patient data, a military strategist evaluating operations, a financial advisor tracking markets, or a small business owner understanding operations, VisionZ+ eliminates the need for a dedicated data science team - just ask questions and get insights.

### How we built it

VisionZ+ is powered by a sophisticated Multi-Agent AI Architecture leveraging OpenAI's API and Terra's API, enhanced with our custom chain-of-thought processing and specialized agents. At its core, we developed a hierarchical orchestration system where each agent serves a distinct purpose: Our Analysis Agent processes natural language queries and translates them into structured task specifications The Orchestrator Agent coordinates the workflow The Planning Engine decomposes complex analytical tasks into optimized sub-tasks for parallel processing The real innovation lies in our Multi-Agent Architecture - specialized mini-agents that work in parallel, each focused on specific aspects like data processing, visualization, pattern recognition, and statistical analysis. These agents communicate through a custom-built coordination layer, ensuring efficient task distribution and resource optimization. Every output passes through our Validator Agent, which performs rigorous quality assurance and cross-validation before delivering results. The frontend provides an intuitive drag-and-drop interface, while our robust backend handles the complex orchestration of these AI agents. This architecture enables us to process complex analytical tasks with high accuracy and computational efficiency through systematic decomposition and parallel processing.

### Challenges we ran into

One of our biggest hurdles was working with the Terra API integration. The authentication flow required setting up our own SSH tunnel to generate and handle authorization links, which proved to be quite tricky. We spent considerable time troubleshooting the tunnel configuration and ensuring secure, reliable connections for our users' wearable data. The process taught us a lot about handling OAuth flows and secure data transmission in production environments. The implementation of our Multi-Agent Architecture presented its own set of complex challenges, particularly around processing time. We discovered that different types of data analysis required varying levels of computational resources and model capabilities. This led us to develop a dynamic approach where we utilize different models based on the specific analysis needs - from lightweight models for quick statistical analysis to more sophisticated reasoning model for complex pattern recognition. Integrating our dynamic frontend with the backend focused on formatting and passing payload history for wearable data into MongoDB. Managing state on wearable.js involved designing a payload structure that supports seamless, real-time data transfer. The main challenge was reliably passing the complete payload history while maintaining data consistency.

### What's next

We're pursuing an ambitious vision: creating the world's first truly autonomous data scientist. Beyond just analyzing data, we're developing VisionZ+ to proactively identify opportunities, generate hypotheses, and conduct independent research - much like a human data scientist would. Our goal is to enable VisionZ+ to not just answer questions, but to ask the right questions and uncover insights that users might not even know to look for. Looking ahead, we're enhancing our Multi-Agent Architecture with more sophisticated reasoning capabilities and expanding into industry-specific solutions. We envision VisionZ+ becoming an indispensable partner in data-driven decision making across all sectors - from healthcare and scientific research to business strategy and public policy. The future of data science is autonomous, and VisionZ+ is leading the way.

## README (from the GitHub repository)

# VisionZ➕

VisionZ+, Your data scientist.

![VisionZ+ Logo](./images/visionz+.png "VisionZ+ Logo")

First of its kind data visualization and analysis platform powered by our groundbreaking Multi-Agent AI Architecture. Analyze **any** dataset with just a drag and drop.

Stanford TreeHacks 2025.

### Team:
<a href="https://youweizhen.com" target="_blank">Youwei Zhen</a> (Brown University), 
<a href="http://linkedin.com/in/taorui-huang/" target="_blank">Taorui Huang</a> (Stanford),
<a href="https://www.linkedin.com/in/a-zimina/" target="_blank">Anni Zimina</a> (Stanford),
<a href="http://linkedin.com/in/nickadesina" target="_blank">Nick Adesina</a> (UC Berkeley)

<p float="left">
   <img src="./images/team1.jpg" width=300 alt="Team photo!">
   <img src="./images/team2.jpg" width=300 alt="Team photo!">
</p>

## What is VisionZ+
VisionZ+ is a first-of-its-kind data visualization and analysis platform that lets users analyze any dataset through a simple drag-and-drop interface. With our dataset assistant, you can simply ask questions about your data and let the AI find patterns and insights for you. The platform is powered by a Multi-Agent AI Architecture that processes data through multiple specialized agents - from initial analysis and orchestration to planning, execution via mini-agent swarms, and validation. This makes sophisticated data analysis accessible to anyone, regardless of their technical background. Whether you're a medical researcher analyzing patient data, a military strategist evaluating operations, a financial advisor tracking markets, or a small business owner understanding operations, VisionZ+ eliminates the need for a dedicated data science team - just ask questions and get insights.

## Revolutionary Multi-Agent AI Architecture

VisionZ+ employs a sophisticated Multi-Agent AI system that processes your requests through a highly orchestrated pipeline:

![VisionZ+ Multi-Agent Architecture](./images/architecture.png "Architecture Diagram")

1. **Analysis Agent** 🔍
   - First point of contact for all user requests
   - Performs initial request analysis and requirement extraction
   - Translates natural language into structured task specifications

2. **Orchestrator Agent** 🎮
   - Central command center of the system
   - Coordinates complex workflows between agents
   - Manages resource allocation and task prioritization

3. **Planning Engine** 📋
   - Breaks down complex tasks into smaller, manageable sub-tasks
   - Develops execution strategies for optimal results
   - Creates dynamic task graphs for parallel processing

4. **Mini-Agents Swarm** 🐝
   - Specialized micro-agents working in parallel
   - Each agent focuses on a specific sub-task:
     - Data Processing Agents
     - Visualization Agents
     - Pattern Recognition Agents
     - Statistical Analysis Agents
   - Dynamic scaling based on task complexity

5. **Validator Agent** ✅
   - Quality assurance and result verification
   - Ensures consistency and accuracy of outputs
   - Performs cross-validation of results
   - Optimizes final output for user consumption

This advanced pipeline delivers:
- Highly accurate and validated results
- Parallel processing for faster insights
- Scalable architecture for complex tasks
- Robust error handling and quality control
- Real-time adaptive processing

## Inspiration

We believe everyone deserves their own personal data scientist. In today's data-driven world, the ability to extract meaningful insights from data shouldn't be limited to those with technical expertise or resources to hire analysts. Whether you're a medical researcher analyzing patient outcomes, a military strategist evaluating field operations, or a financial advisor tracking market trends, understanding your data is crucial for making informed decisions.

This vision drove us to create VisionZ+. In healthcare, it can help doctors identify patterns in patient vitals and treatment responses. Military personnel can use it to analyze sensor data from equipment and personnel, enhancing operational efficiency and safety. Financial institutions can leverage it to detect market patterns and assess risk factors. Even small business owners can gain valuable insights about their operations without needing a dedicated data science team.

By combining cutting-edge AI with an intuitive interface, we're making sophisticated data analysis accessible to everyone, regardless of their technical background or industry.

## Setup Instructions

### Backend Setup

1. Navigate to the backend directory:
   ```bash
   cd backend
   ```

2. Install dependencies:
   ```bash
   npm install
   ```

3. Set up environment variables:
   - Edit `.env` and add your OpenAI API key:
     ```
      PORT = Server port (default: 5000)
      MONGODB_URI = MongoDB connection string
      OPENAI_API_KEY = Your OpenAI API key (required)
      NODE_ENV = Node environment (development/production)     
   ```
   - Update other environment variables as needed
4. Start the backend server:
   ```bash
   npm start
   ```

### Frontend Setup

1. Navigate to the frontend directory:
   ```bash
   cd frontend
   ```

2. Install dependencies:
   ```bash
   npm install
   ```

3. Start the development server:
   ```bash
   npm run dev
   ```

## Environment Variables

### Backend (.env)

- `PORT`: Server port (default: 5000)
- `MONGODB_URI`: MongoDB connection string
- `OPENAI_API_KEY`: Your OpenAI API key (required)
- `NODE_ENV`: Node environment (development/production)

## API Endpoints

### AI Generation

- `POST /api/ai/generate`
  - Generates AI-powered visualizations and analysis
  - Requires valid OpenAI API key
  - Request body:
    ```json
    {
      "prompt": "Your analysis prompt here"
    }
    ```

## Error Handling

The API includes comprehensive error handling for:
- Missing or invalid OpenAI API key
- API quota exceeded
- Invalid requests
- Server errors


## Detected evidence (automated analysis)

Indexed codebase: 30 recognized source files, 570 KB.
- CSS (language) — detected in the code
- Express (technology) — detected in the code
- JavaScript (language) — detected in the code
- MongoDB (technology) — detected in the code
- Next.js (technology) — detected in the code
- OpenAI (technology) — detected in the code
- React (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- HTML (language) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (44 of 44)

```
.gitignore
backend/.env.example
backend/.gitignore
backend/package.json
backend/src/models/AIInteraction.js
backend/src/models/TerraData.js
backend/src/models/UserWearable.js
backend/src/routes/ai.js
backend/src/routes/wearable.js
backend/src/scripts/exportMongoData.js
backend/src/server.js
exports/heart_rate_data.json
exports/hypnogram_samples.json
exports/mongodb_export.json
exports/students.json
frontend/.gitignore
frontend/app/globals.css
frontend/app/layout.js
frontend/app/page.js
frontend/components/feature-item.js
frontend/components/header.js
frontend/components/Navbar.js
frontend/components/ui/button.js
frontend/components/ui/grid-illustration.js
frontend/components/ui/mobile-menu.js
frontend/components/ui/navigation-menu.js
frontend/components/ui/pulse-animation.js
frontend/eslint.config.mjs
frontend/jsconfig.json
frontend/next.config.js
frontend/package.json
frontend/pages/_app.js
frontend/pages/analyze.js
frontend/pages/api/analyze.js
frontend/pages/result.js
frontend/pages/wearable.js
frontend/postcss.config.js
frontend/postcss.config.mjs
frontend/public/chart.js
frontend/public/d3.js
frontend/README.md
frontend/tailwind.config.js
frontend/tailwind.config.mjs
README.md
```

### Dependencies

- backend/package.json: cors@^2.8.5, dotenv@^16.4.7, express@^4.18.2, express-session@^1.18.1, mongoose@^8.0.0, nodemon@^3.0.1, openai@^4.85.1, terra-api@^1.4.8
- frontend/package.json: @eslint/eslintrc@^3, @tailwindcss/typography@^0.5.16, autoprefixer@^10.4.20, eslint@^9, eslint-config-next@15.1.7, framer-motion@^12.4.3, next@15.1.7, openai@^4.85.1, postcss@^8, react@^19.0.0, react-dom@^19.0.0, react-dropzone@^14.3.5, react-markdown@^9.0.3, tailwindcss@^3.4.1

### Recent commits (newest first)

- root cleaned
- team photo!
- updated description
- team photo!
- adjusting size
- team photo!
- readme updated
- readme
- readme
- readme
- Merge pull request #7 from AntoDono/taoruih
- working historical data fetch
- Merge branch 'main' into taoruih
- change to relative path + download wearable data
- Merge pull request #6 from AntoDono/final
- done
- Merge pull request #5 from AntoDono/final
- perfect working version
- code not running
- currently fixed

## Key source files (fetched from GitHub, selected and truncated for size)

### backend/package.json

```
{
  "name": "visionzplus-backend",
  "version": "1.0.0",
  "description": "Backend server for VisionZPlus",
  "main": "src/server.js",
  "type": "module",
  "scripts": {
    "start": "node src/server.js",
    "dev": "nodemon src/server.js"
  },
  "dependencies": {
    "cors": "^2.8.5",
    "dotenv": "^16.4.7",
    "express": "^4.18.2",
    "express-session": "^1.18.1",
    "mongoose": "^8.0.0",
    "openai": "^4.85.1",
    "terra-api": "^1.4.8"
  },
  "devDependencies": {
    "nodemon": "^3.0.1"
  }
}

```

### frontend/package.json

```
{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev --turbopack",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "autoprefixer": "^10.4.20",
    "framer-motion": "^12.4.3",
    "next": "15.1.7",
    "openai": "^4.85.1",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    "react-dropzone": "^14.3.5",
    "react-markdown": "^9.0.3"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3",
    "@tailwindcss/typography": "^0.5.16",
    "eslint": "^9",
    "eslint-config-next": "15.1.7",
    "postcss": "^8",
    "tailwindcss": "^3.4.1"
  }
}

```

### frontend/app/layout.js

```javascript
import './globals.css';
import { Inter } from 'next/font/google';
import Header from '../components/header';

const inter = Inter({ subsets: ['latin'] });

export const metadata = {
  title: 'VisionZ+',
  description: 'Transform your health data into actionable insights',
};

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body className={`${inter.className} relative min-h-screen`}>
        <Header />
        <div className="flex items-center justify-center">
          <main className="pt-24 w-[85vw]">{children}</main>
        </div>
        <footer className="absolute bottom-0 w-full py-6 text-center text-sm text-gray-500">
          {new Date().getFullYear()} VisionZ+. All rights reserved.
        </footer>
      </body>
    </html>
  );
}

```

### backend/src/server.js

```javascript
import express from 'express';
import mongoose from 'mongoose';
import cors from 'cors';
import dotenv from 'dotenv';
import session from 'express-session';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import aiRoutes from './routes/ai.js';
import wearableRoutes from './routes/wearable.js';

dotenv.config();

const app = express();
const PORT = process.env.PORT || 5000;

// Middleware
app.use(cors());
app.use(express.json());

// Serve static files from public directory
app.use(express.static('public'));
app.use(session({
  secret: process.env.SESSION_SECRET || 'your-secret-key',
  resave: false,
  saveUninitialized: false,
  cookie: { secure: process.env.NODE_ENV === 'production' }
}));

// MongoDB Connection
const connectDB = async () => {
  try {
    await mongoose.connect(process.env.MONGODB_URI);
    console.log('MongoDB connected successfully');
  } catch (error) {
    console.error('MongoDB connection error:', error);
    process.exit(1);
  }
};

// Routes
app.get('/api/health', (req, res) => {
  res.json({ status: 'ok', message: 'Server is running' });
});

// AI Routes
app.use('/api/ai', aiRoutes);

// Wearable Routes
app.use('/api/wearable', wearableRoutes);

// Start server
console.log("Connecting to MongoDB")
connectDB().then(() => {
  app.listen(PORT, () => {
    console.log(`Server is running on port ${PORT}`);
  });
});

```

### frontend/app/page.js

```javascript
'use client';

import Link from 'next/link';
import { motion } from 'framer-motion';
import GridIllustration from '../components/ui/grid-illustration';
import FeatureItem from '../components/feature-item';
import PulseAnimation from '../components/ui/pulse-animation';

export default function Home() {
  return (
    <div className="overflow-x-hidden">
      <div className="fixed inset-0 -z-10">
        <GridIllustration />
      </div>
      
      <div className="relative">
        <div className="mx-auto max-w-7xl px-6 lg:px-8">
          <div className="relative py-8 lg:py-12">
            <div className="lg:grid lg:grid-cols-12 lg:gap-x-6">
              {/* Left side: Text content */}
              <div className="lg:col-span-6">
                <motion.div
                  initial={{ opacity: 0, scale: 0.97, y: 20 }}
                  animate={{ opacity: 1, scale: 1, y: 0 }}
                  transition={{ 
                    duration: 0.8,
                    ease: [0.16, 1, 0.3, 1]
                  }}
                  className="relative"
                >
                  <div className="absolute -left-4 top-8 h-12 w-12">
                    <PulseAnimation delay={0} />
                  </div>
                  <h1 className="text-4xl font-bold tracking-tight text-gray-900 sm:text-5xl xl:text-6xl">
                    Transform Your Health
                    <br />
                    Data Into
                    <br />
                    <span className="text-purple-400">Actionable Insights</span>
                  </h1>
                  <p className="mt-4 text-lg leading-7 text-gray-600">
                    Connect your wearable devices and unlock powerful analytics to understand 
                    your health patterns and make informed decisions about your well-being.
                  </p>
                  <div className="mt-6 flex gap-3">
                    <Link
                      href="/wearable"
                      className="inline-flex items-center rounded-lg bg-purple-400 px-4 py-2 text-sm font-medium text-white hover:bg-purple-500 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:ring-offset-2"
                    >
                      Connect Device
                    </Link>
                    <Link
                      href="/analyze"
                      className="inline-flex items-center rounded-lg border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
                    >
                      View Analytics
                    </Link>
                  </div>
                </motion.div>
              </div>

              {/* Right side: Feature items */}
              <div className="mt-12 lg:col-span-6 lg:mt-0">
                <div className="flex flex-col gap-3">
                  <FeatureItem
                    icon={
                      <svg className="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M13 10V3L4 14h7v7l9-11h-7z" />
                      </svg>
                    }
                    title="Real-Time Sync"
                    description="Seamlessly connect and sync data from your wearable devices for instant access to your health metrics."
                    delay={0.2}
                  />
                  <FeatureItem
                    icon={
                      <svg className="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
                      </svg>
                    }
                    title="AI Analytics"
                    description="Leverage AI-powered analytics to uncover patterns and trends in your health data."
                    delay={0.4}
                  />
                  <FeatureItem
                    icon={
                      <svg className="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
                      </svg>
                    }
                    title="Secure & Private"
                    description="Your health data is encrypted and protected with enterprise-grade security measures."
                    delay={0.6}
                  />
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}
```

### frontend/postcss.config.js

```javascript
module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}

```

### frontend/tailwind.config.js

```javascript
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    './pages/**/*.{js,ts,jsx,tsx,mdx}',
    './components/**/*.{js,ts,jsx,tsx,mdx}',
    './app/**/*.{js,ts,jsx,tsx,mdx}',
  ],
  theme: {
    extend: {
      colors: {
        'visionz': {
          purple: '#4A1D96',
          'purple-light': '#5925B0',
          'purple-dark': '#3B1678',
        },
      },
    },
  },
  plugins: [],
}

```

### frontend/next.config.js

```javascript
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  publicRuntimeConfig: {
    // Will be available on both server and client
    OPENAI_API_KEY: process.env.OPENAI_API_KEY,
  },
  serverRuntimeConfig: {
    // Will only be available on the server side
    OPENAI_API_KEY: process.env.OPENAI_API_KEY,
  },
  async rewrites() {
    return [
      {
        source: '/api/:path*',
        destination: 'http://localhost:5001/api/:path*'
      }
    ];
  },
}

module.exports = nextConfig

```

### frontend/pages/_app.js

```javascript
import '../app/globals.css';
import { Inter } from 'next/font/google';
import Header from '../components/header';

const inter = Inter({ subsets: ['latin'] });

export const metadata = {
  title: 'VisionZ+',
  description: 'Transform your health data into actionable insights',
};

export default function App({ Component, pageProps }) {
  return (
    <div className="h-full w-screen">
      <Header />
      <div className="h-fit w-full pt-12">
        <Component {...pageProps} />
      </div>
      <footer className="w-full py-6 text-center text-sm text-gray-500">
        {new Date().getFullYear()} VisionZ+. All rights reserved.
      </footer>
    </div>
  );
}

```

### frontend/components/Navbar.js

```javascript
'use client';

import Image from 'next/image';
import Link from 'next/link';
import { motion } from 'framer-motion';

export default function Navbar() {
  return (
    <nav className="container p-4 bg-transparent fixed top-0 left-0">
      <div className="flex items-center gap-4">
        <Link href="/">
          <div className="w-fit cursor-pointer hover:opacity-80 transition-opacity">
            <Image
              src="/logo.png"
              alt="VisionZ+ Logo"
              width={100}
              height={35}
              className="object-contain"
              priority
            />
          </div>
        </Link>
        <motion.div
          initial={{ opacity: 0, x: -20 }}
          animate={{ opacity: 1, x: 0 }}
          transition={{ duration: 0.5 }}
          className="text-3xl font-bold text-white"
        >
          VisionZ<span className="text-purple-400">+</span>
        </motion.div>
      </div>
    </nav>
  );
}

```

[18 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]