Skip to content

DTSP-AI/fight-analyst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fight Analyst

Python Next.js FastAPI LangGraph React License

AI-powered fight analysis platform that processes combat sports footage through a multi-agent system. Upload fight video, get structured breakdown of technique, strategy, scoring, and improvement recommendations — powered by LangGraph agent orchestration.


Architecture

┌──────────────────────────────────────────────────────────┐
│  Next.js 15 Frontend (React 19 + Framer Motion)         │
│  ┌──────────┐  ┌──────────┐  ┌───────────────────────┐  │
│  │  Upload   │  │  Live    │  │  Analysis Dashboard   │  │
│  │  Panel    │  │  Feed    │  │  (Charts + Timeline)  │  │
│  └────┬─────┘  └────┬─────┘  └───────────┬───────────┘  │
│       └──────────────┴────────────────────┘              │
│                       │ REST API                         │
├───────────────────────┼──────────────────────────────────┤
│  FastAPI Backend      │                                  │
│                       ▼                                  │
│  ┌─────────────────────────────────────────────────┐     │
│  │           LangGraph StateGraph                  │     │
│  │                                                 │     │
│  │  ┌───────────┐    ┌────────────┐                │     │
│  │  │  Fight     │───▶│  Validator  │               │     │
│  │  │  Analyst   │    │  Agent     │               │     │
│  │  │  Agent     │    └─────┬──────┘               │     │
│  │  └───────────┘          │                       │     │
│  │       │            ┌────▼──────┐                │     │
│  │       │            │  Scoring   │               │     │
│  │       └───────────▶│  Engine   │               │     │
│  │                    └───────────┘                │     │
│  └─────────────────────────────────────────────────┘     │
│                       │                                  │
│              ┌────────┴────────┐                         │
│              │   PostgreSQL    │                          │
│              │   (Supabase)    │                          │
│              └─────────────────┘                         │
└──────────────────────────────────────────────────────────┘

How It Works

1. Video Ingestion — Upload fight footage via the frontend. The backend extracts metadata, timestamps, and prepares analysis context.

2. Multi-Agent Analysis — A LangGraph StateGraph orchestrates specialized agents:

  • Fight Analyst Agent — Contract-driven agent that breaks down technique exchanges, identifies patterns, and assesses fighter strategies
  • Validator Agent — Cross-references analysis claims against video evidence and known technique databases
  • Scoring Engine — Applies judging criteria to generate round-by-round or segment-based scoring

3. Structured Output — Results are assembled into a comprehensive fight report with timeline annotations, technique classifications, strategic assessments, and actionable coaching feedback.

Tech Stack

Layer Technology
Frontend Next.js 15 (App Router), React 19, TypeScript, Framer Motion, TailwindCSS
Backend FastAPI, Python 3.11+, Pydantic V2
Agent Framework LangGraph (StateGraph with conditional routing)
Agent Behavior JSON contract-based prompt architecture
Database PostgreSQL via Supabase (pgvector for embeddings)
Auth Supabase Auth with cookie-based sessions
Testing Pytest (backend), Jest (frontend)
Infrastructure Docker, Docker Compose

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Supabase account (free tier works)
  • OpenAI API key

Backend

cd fight-analyst-backend
python -m venv .venv
.venv/Scripts/activate          # Windows
source .venv/bin/activate       # Mac/Linux
pip install -r requirements.txt
cp .env.example .env            # Add your API keys
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8001

Frontend

cd fight-analyst-frontend
npm install
cp .env.example .env.local      # Set NEXT_PUBLIC_BACKEND_URL
npm run dev                     # http://localhost:3000

Docker

docker-compose up --build

Project Structure

fight-analyst-backend/
├── app/
│   ├── agents/           # LangGraph agent definitions
│   │   ├── contracts/    # JSON behavior contracts
│   │   ├── fight_analyst.py
│   │   ├── validator.py
│   │   └── base.py
│   ├── graph/            # LangGraph StateGraph wiring
│   ├── api/              # FastAPI route handlers
│   ├── services/         # Business logic layer
│   ├── models/           # Pydantic schemas
│   ├── memory/           # Session and persistent memory
│   ├── middleware/        # Auth, CORS, rate limiting
│   └── tests/            # Pytest test suite
├── migrations/           # Database migrations
├── Dockerfile
└── requirements.txt

fight-analyst-frontend/
├── app/                  # Next.js 15 App Router pages
├── middleware.ts          # Auth middleware
├── package.json
└── tsconfig.json

Design Decisions

Contract-Driven Agents — Agent behavior is defined in JSON specification files, not hardcoded in Python. This enables modifying agent personality, scope, and response patterns without touching application code.

LangGraph over raw chains — StateGraph provides deterministic routing, state persistence, and conditional branching that raw LangChain chains can't offer for multi-step analysis workflows.

Validator as separate agent — Rather than self-validation, a dedicated validator agent catches hallucinations and unsupported claims by cross-referencing against the original video context.

Background

This project combines 28+ years of experience coaching professional combat athletes with production AI agent engineering. The analysis models are grounded in real fight coaching methodology — not generic sports analytics.

License

MIT

Author

Pete Davidsmeier — AI Agent Architect, CTO at YBRYX Business Systems

LinkedIn

About

AI-powered combat sports analysis. LangGraph multi-agent system + Next.js 15 + FastAPI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors