# Project export: SimuCHATlator

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: talk with anyone, anywhere, anytime.
- Devpost: https://devpost.com/software/simu-chat-lator
- GitHub: https://github.com/lamboenthusiast/sim
- Team: 1 GitHub contributor(s) — mayuridev (1 commits)

## Devpost submission (written by the team)

### Inspiration

we've all been there--staring at a text from the girl in your math class, wondering "will this come across the right way??". what if there was a way to practice and simulate the nuance of personal relationships? just like dr strange saw 14 million possible outcomes, what if you could freely practice any social situation over and over again until it becomes a reality?

### What it does

our one-click no-code button exports your entire iMessage chatlog into our fine-tuning pipeline, turning that LLM into someone that texts exactly like your best friend, boss, partner or romantic interest. rehearse infinite messages in a sandbox, add some context and what you hope to achieve with this individual, whether personal or professional. get your drafted messages scored in real-time, before you hit the 'send' button -- suggesting edits like “add an emoji here—they respond 73% better to the sobbing emoji in awkward situations” or “shorten this paragraph—they usually disengage after 2 sentences.” not sure how to respond to their latest text? get suggested messages powered by the same monte carlo algorithm that powered alphago.

### Challenges we ran into

parsing imsg data is messy. also generating replies took a long time, but sql/wasm caching works wonders.

## README (from the GitHub repository)

# Ninja - AI Chat Practice Tool

Ninja is a one-click fine-tuning tool that helps you practice messaging with AI-powered chat simulations. Train the model on your iMessage history to create personalized chat experiences and receive feedback on your messaging style.

## Features
- One-click iMessage chat export using MeGPT
- AI-powered chat playground with real-time feedback
- Contextual suggestions based on conversation history
- Performance ratings and messaging analysis

## Local Development Setup

### Prerequisites
- Python 3.8+ with pip
- Node.js 18+ with npm
- macOS (for iMessage integration)

### iMessage Export Setup (macOS only)

1. Clone and install MeGPT:
   ```bash
   git clone https://github.com/1rgs/MeGPT.git
   cd MeGPT
   pip install -r requirements.txt
   ```

2. Export your messages:
   ```bash
   python extract_messages.py
   ```

3. The exported messages will be saved as messages.csv and ready for fine-tuning

### Backend Setup
```bash
cd backend/ninja_backend
pip install -r requirements.txt
python -m uvicorn local_server:app --reload --port 3001
```

The backend will be available at http://localhost:3001

### Frontend Setup
```bash
cd frontend
npm install
npm run dev
```

The frontend will be available at http://localhost:3000

### Environment Variables

Backend (`.env` in backend/ninja_backend):
```
ANTHROPIC_API_KEY=your_api_key_here
MODEL_PATH=path/to/saved/model  # Optional, for loading pre-trained models
```

Frontend (`.env` in frontend):
```
NEXT_PUBLIC_API_URL=http://localhost:3001
```

## Development Notes

- The frontend is built with Next.js and uses Tailwind CSS for styling
- For hackathon demos, prepare the fine-tuned model in advance
- The chat playground provides real-time feedback and suggestions

## API Documentation

### Message Import
- `POST /api/v1/messages/import` - Import messages from MeGPT export
- `GET /api/v1/messages/{contact}` - Get imported messages for a contact

### Chat Interface
- `POST /api/v1/chat/message` - Send a message and get AI response
- `POST /api/v1/chat/analyze` - Get feedback on messaging style

### Model Management
- `POST /api/v1/model/train` - Fine-tune model on imported messages
- `GET /api/v1/model/status` - Check training status


## Detected evidence (automated analysis)

Indexed codebase: 33 recognized source files, 94 KB.
- CSS (language) — detected in the code
- FastAPI (technology) — detected in the code
- Hugging Face (technology) — detected in the code
- Next.js (technology) — detected in the code
- Ollama (technology) — detected in the code
- Python (language) — detected in the code
- PyTorch (technology) — detected in the code
- React (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- TypeScript (language) — detected in the code

## Codebase structure (from repository index)

### Files (52 of 52)

```
.DS_Store
backend/.DS_Store
backend/ninja_backend/.DS_Store
backend/ninja_backend/app/.DS_Store
backend/ninja_backend/app/api/v1/__init__.py
backend/ninja_backend/app/api/v1/messages.py
backend/ninja_backend/app/local_server.py
backend/ninja_backend/app/main.py
backend/ninja_backend/app/message_extractor/__init__.py
backend/ninja_backend/app/message_extractor/extract_messages.py
backend/ninja_backend/app/message_extractor/fine_tune.py
backend/ninja_backend/app/message_extractor/generate.py
backend/ninja_backend/app/message_extractor/utils.py
backend/ninja_backend/app/model/training.py
backend/ninja_backend/data/.DS_Store
backend/ninja_backend/Dockerfile
backend/ninja_backend/local_server.py
backend/ninja_backend/requirements.txt
backend/requirements.txt
Cargo.toml
docker-compose.yml
Dockerfile
frontend/.gitignore
frontend/eslint.config.mjs
frontend/next.config.ts
frontend/package.json
frontend/postcss.config.mjs
frontend/README.md
frontend/src/app/components/ChatInterface.tsx
frontend/src/app/components/ChatMessage.tsx
frontend/src/app/components/ContactSelector.tsx
frontend/src/app/components/ContextSettingsPanel.tsx
frontend/src/app/components/FeedbackPanel.tsx
frontend/src/app/components/Sidebar.tsx
frontend/src/app/globals.css
frontend/src/app/layout.tsx
frontend/src/app/page.tsx
frontend/src/app/types.ts
frontend/src/app/types/index.ts
frontend/src/app/types/speech-recognition.d.ts
frontend/src/lib/utils.ts
frontend/tailwind.config.ts
frontend/tsconfig.json
MeGPT/.DS_Store
MeGPT/.gitignore
MeGPT/extract_messages.py
MeGPT/fine_tune.py
MeGPT/generate.py
MeGPT/readme.md
MeGPT/requirements.txt
MeGPT/train_model.ipynb
README.md
```

### Dependencies

- backend/ninja_backend/requirements.txt: accelerate@==0.18.0, aiohttp@==3.8.4, bitsandbytes@==0.37.2, datasets@==2.11.0, fastapi@==0.104.1, httpx@==0.27.0, numpy@>=1.24.3, pandas@==2.0.0, peft@==0.2.0, python-dotenv@==1.0.0, python-multipart@==0.0.9, PyYAML@>=6.0, sqlalchemy@==2.0.23, torch@==2.0.0, transformers@==4.28.1, uvicorn@==0.24.0
- backend/requirements.txt: fastapi@>=0.68.0, ollama@>=0.1.0, python-multipart@>=0.0.5, uvicorn@>=0.15.0
- frontend/package.json: @eslint/eslintrc@^3, @headlessui/react@^2.2.0, @heroicons/react@^2.2.0, @types/node@^20, @types/react@^19, @types/react-dom@^19, clsx@^2.1.1, eslint@^9, eslint-config-next@15.1.7, framer-motion@^12.4.3, next@15.1.7, postcss@^8, react@^19.0.0, react-dom@^19.0.0, tailwind-merge@^3.0.1, tailwindcss@^3.4.1, typescript@^5
- MeGPT/requirements.txt: accelerate@==0.18.0, aiohttp@==3.8.4, aiosignal@==1.3.1, async-timeout@==4.0.2, attrs@==23.1.0, bitsandbytes@==0.37.2, certifi@==2022.12.7, charset-normalizer@==3.1.0, cmake@==3.26.3, datasets@==2.11.0, dill@==0.3.6, filelock@==3.12.0, frozenlist@==1.3.3, fsspec@==2023.4.0, huggingface-hub@==0.13.4, idna@==3.4, Jinja2@==3.1.2, lit@==16.0.1, MarkupSafe@==2.1.2, mpmath@==1.3.0, multidict@==6.0.4, multiprocess@==0.70.14, networkx@==3.1, numpy@==1.24.3, packaging@==23.1, pandas@==2.0.0, peft@==0.2.0, psutil@==5.9.5, pyarrow@==11.0.0, python-dateutil@==2.8.2, pytz@==2023.3, PyYAML@==6.0, regex@==2023.3.23, requests@==2.28.2, responses@==0.18.0, torch@==2.0.0, transformers@==4.28.1

### Recent commits (newest first)

- first commit
- update

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

### Cargo.toml

```
[workspace]
members = [
    "src-tauri",
    "src-wasm"
]

```

### Dockerfile

```
FROM rust:1.75-slim-bookworm as builder

WORKDIR /app
COPY . .

RUN cargo build --release

FROM node:20-slim

WORKDIR /app
COPY --from=builder /app/target/release/ninja /usr/local/bin/
COPY src-frontend /app

RUN npm install
EXPOSE 3000

CMD ["npm", "start"]

```

### docker-compose.yml

```yaml
version: "3.8"
services:
  ml-backend:
    build: 
      context: ./backend/ninja_backend
      dockerfile: Dockerfile
    ports:
      - "3001:3001"
    environment:
      - MODEL_NAME=facebook/opt-1.3b
      - BLOCK_SIZE=128
      - FRONTEND_URL=http://localhost:3000
    volumes:
      - ./models:/app/models
      # Do not mount Messages database in container
      # iMessage access must be done locally

```

### backend/requirements.txt

```
fastapi>=0.68.0
uvicorn>=0.15.0
python-multipart>=0.0.5
ollama>=0.1.0 
```

### MeGPT/requirements.txt

```
accelerate==0.18.0
aiohttp==3.8.4
aiosignal==1.3.1
async-timeout==4.0.2
attrs==23.1.0
bitsandbytes==0.37.2
certifi==2022.12.7
charset-normalizer==3.1.0
cmake==3.26.3
datasets==2.11.0
dill==0.3.6
filelock==3.12.0
frozenlist==1.3.3
fsspec==2023.4.0
huggingface-hub==0.13.4
idna==3.4
Jinja2==3.1.2
lit==16.0.1
MarkupSafe==2.1.2
mpmath==1.3.0
multidict==6.0.4
multiprocess==0.70.14
networkx==3.1
numpy==1.24.3
packaging==23.1
pandas==2.0.0
peft==0.2.0
psutil==5.9.5
pyarrow==11.0.0
python-dateutil==2.8.2
pytz==2023.3
PyYAML==6.0
regex==2023.3.23
requests==2.28.2
responses==0.18.0
torch==2.0.0
transformers==4.28.1

```

### frontend/package.json

```
{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@headlessui/react": "^2.2.0",
    "@heroicons/react": "^2.2.0",
    "clsx": "^2.1.1",
    "framer-motion": "^12.4.3",
    "next": "15.1.7",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    "tailwind-merge": "^3.0.1"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3",
    "@types/node": "^20",
    "@types/react": "^19",
    "@types/react-dom": "^19",
    "eslint": "^9",
    "eslint-config-next": "15.1.7",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5"
  }
}

```

### backend/ninja_backend/requirements.txt

```
transformers==4.28.1
peft==0.2.0
datasets==2.11.0
torch==2.0.0
pandas==2.0.0
fastapi==0.104.1
uvicorn==0.24.0
python-dotenv==1.0.0
sqlalchemy==2.0.23
httpx==0.27.0
python-multipart==0.0.9
accelerate==0.18.0
bitsandbytes==0.37.2
aiohttp==3.8.4
numpy>=1.24.3
PyYAML>=6.0

```

### backend/ninja_backend/Dockerfile

```
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && \
    apt-get install -y \
    build-essential \
    git \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && \
    pip install --no-cache-dir pytest==8.0.0 pytest-asyncio==0.23.5 -r requirements.txt

COPY . .

# Set environment variables
ENV PYTHONPATH=/app

CMD ["python", "-m", "uvicorn", "local_server:app", "--host", "0.0.0.0", "--port", "3001"]

```

### backend/ninja_backend/app/main.py

```python
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import os

from app.api.v1 import router as api_router

app = FastAPI(title="Ninja Social Coach")

# Configure CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=[os.getenv("FRONTEND_URL", "http://localhost:3000")],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Include API routes
app.include_router(api_router, prefix="/api/v1")

@app.get("/healthz")
async def healthz():
    return {"status": "ok"}

```

### frontend/src/app/layout.tsx

```typescript
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";

const geistSans = Geist({
  variable: "--font-geist-sans",
  subsets: ["latin"],
});

const geistMono = Geist_Mono({
  variable: "--font-geist-mono",
  subsets: ["latin"],
});

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body
        className={`${geistSans.variable} ${geistMono.variable} antialiased`}
      >
        {children}
      </body>
    </html>
  );
}

```

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