# Project export: Rebase

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: AI-Powered Code Insights & Visualization for Seamless Codebase Understanding
- Devpost: https://devpost.com/software/rebase
- GitHub: https://github.com/evnkim/treehacks2025
- Team: 3 GitHub contributor(s) — Evan Kim (9 commits), Annie Wang (8 commits), adamzweiger (3 commits)

## Devpost submission (written by the team)

### Inspiration

Having worked with large codebases before, we know how overwhelming it can be to navigate and understand them—both for humans and AI. We wanted to create a low-token representation of a codebase that preserves its structure while making it easier to explore. Our goal was to fundamentally change how developers view and interact with code by introducing a hierarchical, AI-powered interface that abstracts away complexity and allows users to drill down only when necessary. We were also inspired by tools like Windsurf, which we love, and wanted to bring that intuitive experience to AI-powered code analysis.

### What it does

Rebase is an AI-powered code analytics tool that helps developers quickly understand large codebases. It features: A tree-based file explorer for intuitive navigation AI-generated summaries and complexity analysis for files Code analytics, including lines of code, commits, and files changed AI-powered visualizations and diagrams to represent code structure GitHub integration for real-time insights

### How we built it

We focused on designing an intuitive hierarchical interface that enables users to interact with code at different levels of abstraction. Our backend processes code efficiently, generating AI-powered summaries, complexity scores, and visualizations. We also worked on GitHub authentication and integrating real-time analytics into the dashboard.

### Challenges we ran into

One of the biggest challenges was handling GitHub authentication—we were stuck on it for a while. Managing dependencies across files efficiently and optimizing AI context window usage were also tricky. Balancing performance with usability was another key challenge, especially when working with large codebases.

### Accomplishments we're proud of

Successfully built a working prototype of our file tree explorer Implemented AI-generated summaries and complexity analysis Designed a scalable approach for integrating GitHub repositories Gained a deeper understanding of AI-driven software engineering

### What we learned

Throughout this project, we learned a lot about: AI-driven software engineering and code analysis Managing dependencies across files in a structured way Efficiently utilizing the context window for AI-powered insights Overcoming authentication and API integration hurdles

### What's next

This is just the beginning. Moving forward, Rebase can expand to integrate with popular AI software engineering services, provide deeper insights into code structure, and support more advanced AI-driven refactoring suggestions. Our goal is to make navigating and understanding large codebases effortless for developers everywhere.

## README (from the GitHub repository)

# treehacks2025

react + tailwind + flask + postgres

First, create a postgres database,

```bash
createdb rebasedb
```

```bash
cd client
yarn install
yarn run build
```

```bash
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 wsgi.py
```

navigate to `http://127.0.0.1:2000`


## Detected evidence (automated analysis)

Indexed codebase: 25 recognized source files, 81 KB.
- CSS (language) — detected in the code
- Flask (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- OpenAI (technology) — detected in the code
- Python (language) — detected in the code
- React (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- PostgreSQL (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (30 of 30)

```
.gitignore
client/.gitignore
client/index.html
client/package.json
client/src/components/CommitsTab.jsx
client/src/components/FileTreeExplorer.jsx
client/src/components/GitHubLoginButton.jsx
client/src/components/OverviewTab.jsx
client/src/index.css
client/src/layouts/RootLayout.jsx
client/src/main.jsx
client/src/pages/Dashboard.jsx
client/src/pages/Home.jsx
client/src/router.jsx
client/tailwind.config.js
client/vite.config.js
LICENSE
README.md
requirements.txt
server/__init__.py
server/config.py
server/controllers/ai_insights.py
server/controllers/api.py
server/controllers/auth.py
server/db.py
server/models/Puzzle.py
server/models/Submission.py
server/models/User.py
server/utils.py
wsgi.py
```

### Dependencies

- client/package.json: @mantine/core@^7.16.3, @mantine/hooks@^7.16.3, @tabler/icons-react@^3.30.0, @tailwindcss/vite@^4.0.6, @types/react@^18.0.26, @types/react-dom@^18.0.9, @vitejs/plugin-react@^3.0.0, chart.js@^4.4.7, chartjs@^0.3.24, chartjs-adapter-date-fns@^3.0.0, chartjs-plugin-zoom@^2.2.0, date-fns@^4.1.0, icons-react@^3.7.1, react@^18.2.0, react-chartjs-2@^5.3.0, react-dom@^18.2.0, react-icons@^5.4.0, react-router-dom@^7.1.5, tailwindcss@^4.0.6, vite@^6.1.0
- requirements.txt: APIFlask@==2.1.1, Authlib@==1.3.1, Faker@==26.0.0, Flask@==3.0.3, Flask-Cors@==4.0.1, Flask-SQLAlchemy@==3.1.1, openai, psycopg2-binary@==2.9.9, python-dotenv@==1.0.1, requests@==2.32.3, SQLAlchemy@==2.0.29

### Recent commits (newest first)

- instructions:
- cleanup
- fix icon
- learn more button
- homepage
- overview and commits
- overview
- Merge branch 'temp_branch' of https://github.com/evnkim/treehacks2025 into temp_branch
- menu by user
- Merge branch 'temp_branch' of https://github.com/evnkim/treehacks2025 into temp_branch
- github app
- commits
- center button
- works now i think
- merge
- this whole thing is wrong
- fixed ui
- adam
- fixed api
- Initial commit

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

### requirements.txt

```
# Automatically generated by https://github.com/damnever/pigar.

APIFlask==2.1.1
Authlib==1.3.1
Faker==26.0.0
Flask==3.0.3
Flask-Cors==4.0.1
Flask-SQLAlchemy==3.1.1
psycopg2-binary==2.9.9
python-dotenv==1.0.1
requests==2.32.3
SQLAlchemy==2.0.29
openai
```

### client/package.json

```
{
  "name": "client",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@mantine/core": "^7.16.3",
    "@mantine/hooks": "^7.16.3",
    "@tabler/icons-react": "^3.30.0",
    "@tailwindcss/vite": "^4.0.6",
    "chart.js": "^4.4.7",
    "chartjs": "^0.3.24",
    "chartjs-adapter-date-fns": "^3.0.0",
    "chartjs-plugin-zoom": "^2.2.0",
    "date-fns": "^4.1.0",
    "icons-react": "^3.7.1",
    "react": "^18.2.0",
    "react-chartjs-2": "^5.3.0",
    "react-dom": "^18.2.0",
    "react-icons": "^5.4.0",
    "react-router-dom": "^7.1.5"
  },
  "devDependencies": {
    "@types/react": "^18.0.26",
    "@types/react-dom": "^18.0.9",
    "@vitejs/plugin-react": "^3.0.0",
    "tailwindcss": "^4.0.6",
    "vite": "^6.1.0"
  }
}

```

### client/src/main.jsx

```javascript
import React from "react";
import ReactDOM from "react-dom/client";
import { RouterProvider } from "react-router-dom";
import { router } from "./router";
import "./index.css";
import "@mantine/core/styles.css";
import { createTheme, MantineProvider, rem } from "@mantine/core";


const theme = createTheme({
  fontFamily: "Lexend, sans-serif",
  fontFamilyMonospace: "Roboto Mono, monospace",
  headings: { fontFamily: "Lexend, sans-serif" },
  colors: {
    // due to the way that default colors work in mantine, this color gradient is
    // inverted, i.e., darkest to lightest. if the theme ever changes, the new color
    // scheme should follow this inverted pattern, otherwise the app may look/feel
    // different than before.
    "blue": [
      "#4593CC",
      "#499BD7",
      "#4CA4E3",
      "#50ACEE",
      "#54B4F9",
      "#58BCFF",
      "#5CC4FF",
      "#60CCFF",
      "#63D5FF",
      "#67DDFF",
    ],
  },
  primaryColor: "blue",
  spacing: {
    xs: rem(4),
    sm: rem(8),
    md: rem(12),
    lg: rem(16),
    xl: rem(20),
    xxl: rem(32),
    xxxl: rem(36),
  },
  fontSizes: {
    xs: rem(12),
    sm: rem(14),
    md: rem(16),
    lg: rem(18),
    xl: rem(20),
    xxl: rem(24),
    xxxl: rem(30),
    xxxxl: rem(36),
  },
});

ReactDOM.createRoot(document.getElementById("root")).render(
  <React.StrictMode>
    <MantineProvider theme={theme}>
      <RouterProvider router={router} />
    </MantineProvider>
  </React.StrictMode>
);

```

### wsgi.py

```python
"""Entry-point to our application.

This file launches the backend server, which also serves the frontend client in
production.
"""

from typing import cast

from server import create_app

app = create_app()
if __name__ == "__main__":
    port = cast(int, app.config["FLASK_RUN_PORT"])
    debug = cast(bool, app.config["DEBUG"])
    app.run(host="0.0.0.0", port=port, debug=debug)

```

### client/tailwind.config.js

```javascript
/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

```

### client/index.html

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/icon.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Code Analytics Dashboard</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.jsx"></script>
  </body>
</html>

```

### client/vite.config.js

```javascript
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [tailwindcss(), react()],
  server: {
    proxy: {
      "/api": {
        target: "http://127.0.0.1:2000",
        changeOrigin: true,
      },
      "/auth": {
        target: "http://127.0.0.1:2000",
        changeOrigin: true,
      },
    },
  },
});

```

### server/utils.py

```python
"""Utilities for the server."""

import hashlib
import math
from typing import Dict, List

import requests
from sqlalchemy import select

from server.config import (
    SECRET_KEY,
)
from server.db import db


def generate_user_id(github_username: str) -> str:
    """Generate a user ID from a GitHub username."""
    hashed = hashlib.sha256(
        f"{github_username}_{SECRET_KEY}".encode("utf-8")
    ).hexdigest()
    return f"{github_username}_{hashed[:8]}"


def get_username_from_user_id(user_id: str) -> str:
    """Get username from a user ID."""
    return user_id.split("_")[0]

```

### server/db.py

```python
"""SQLAlchemy database + helpers.

Provides a SQLAlchemy instance and helper functions for initializing the database.
"""

from typing import Type, cast

from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import DeclarativeBase, MappedAsDataclass


class Base(DeclarativeBase, MappedAsDataclass):
    """Base SQLAlchemy class. Don't use this class; use db.Model instead.

    Since we use Flask SQLAlchemy, this class shouldn't be used directly.
    Instead, use db.Model.
    """

    pass


class ProperlyTypedSQLAlchemy(SQLAlchemy):
    """Temporary type hinting workaround for Flask SQLAlchemy.

    This is a temporary workaround for the following issue:
    https://github.com/pallets-eco/flask-sqlalchemy/issues/1312
    This workaround may not be correct.
    """

    Model: Type[Base]


db = SQLAlchemy(model_class=Base)
db = cast(ProperlyTypedSQLAlchemy, db)


def init_db(db: ProperlyTypedSQLAlchemy):
    """Initializes the db.

    Calls db.create_all() and initializes global data like admin user.
    """
    db.create_all()

```

### server/config.py

```python
"""Configuration for the backend server.

Default values are necessary to pass ci-checks.
"""

import os
from pathlib import Path
from typing import cast

from dotenv import load_dotenv

load_dotenv(os.path.dirname(__file__) / Path("../.env"))

ENV = os.environ.get("ENVIRONMENT", "development")
SECRET_KEY = os.environ.get("SECRET_KEY", "secret")


def _get_config_option(
    name: str, default_value: str | None = None, required: bool = False
) -> str | None:
    if ENV == "production":
        value = os.environ.get(name, None)
        if value is None:
            raise Exception(
                f"Environment variable {name} not set. In production, "
                "every environment variable must be set."
            )
    else:
        value = os.environ.get(name, default_value)

    if required and value is None:
        raise Exception(f"Environment variable {name} is required but not set.")

    return value


ENV="production"

# from flaskenv
FLASK_RUN_PORT = 2000
DEBUG = True

# CORS configuration
FRONTEND_URL = cast(str, _get_config_option("FRONTEND_URL", "http://localhost:5173"))
BACKEND_URL = cast(str, _get_config_option("BACKEND_URL", "http://localhost:2000"))
ALLOWED_DOMAINS = [FRONTEND_URL]

# Database
SQLALCHEMY_DATABASE_URI = _get_config_option(
    "DATABASE_URL", "postgresql://postgres@localhost/rebasedb"
)

GITHUB_CLIENT_ID = _get_config_option("GITHUB_CLIENT_ID")
GITHUB_CLIENT_SECRET = _get_config_option("GITHUB_CLIENT_SECRET")

```

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