The Problem

Users need a single place to capture, organise and interrogate learning material from many formats (PDFs, audio, YouTube, etc.). Without a dedicated pipeline each source must be processed manually, leading to fragmented notes and missed insights.

What This Does

app/ implements a FastAPI‑style backend that ingests files, calls LLM services, stores results in PostgreSQL and exposes REST endpoints. The web UI lives in web/ (Next.js + React) and consumes those endpoints. A small Node crawler in web_crawler/ provides a public API for fetching remote pages.

Key files:

  • main.py – starts the Python service (imports app and mounts the routers).
  • app/api/content/index.py – core content‑creation routes (create_content, batch_create, process_transcript_task).
  • app/database/session.py – provides get_async_session used by 119 call sites (the database hub).
  • web/src/apis/index.ts – the only module that imports 97 other TS files, acting as the front‑end request façade.

How It Is Wired

Execution begins in main.py which creates a FastAPI app and includes routers from app/api/*. A typical request flow for uploading a file is:

  1. app/api/content/index.py:create_content receives the HTTP payload.
  2. It calls app/database/session.get_async_session (hub module – 21 callers, 1 import) to obtain a DB session.
  3. Business logic in app/services/content_processor.py:process_file runs, which: Writes the uploaded file to the filesystem (open in app/common.py – flagged for missing context manager). Calls an LLM via app/libs/llm/ainee_web.py:invoke_llm_with_structured_output (network call). * Persists the result through app/database/repositories/content_repository.py:create (DB write).
  4. Success or error is wrapped by the helpers in app/common.py (success, failed, failed_with_code). These helpers are the “hub module” with 27 downstream dependencies, giving them a large blast radius.

The internal call graph shows get_async_session as the most‑referenced function (119 distinct callers) and success/failed as the next‑most‑used (47/39 callers). Circular imports involve app/__init__.py, app/common.py and app/database/session.py (24 high‑severity cycles), which increase coupling and make refactoring risky.

External side‑effects traced from entry points:

  • Database – 118 functions issue SQL via the async session.
  • Network – 31 functions perform outbound HTTP (e.g., LLM calls, YouTube transcript fetch).
  • Filesystem – 13 functions read/write files (uploads, temporary audio extraction).
  • Crypto – 8 functions generate hashes or tokens (e.g., hashlib.md5 in create_upload_and_pends).

How To Use It

# Clone the repo
git clone https://github.com/moses-y/Ainee
cd Ainee

# Install Python deps (Python 3.11 required)
pip install -r requirements.txt

# Install Node deps (pnpm required)
pnpm install --filter web...

# Spin up supporting services (Postgres, Redis) via Docker
docker compose up -d   # uses docker-compose.yml at repo root

# Run the backend
python main.py          # starts FastAPI on default port 8000

# Run the frontend (development)
cd web
pnpm dev               # starts Next.js dev server on http://localhost:3000

Environment variables are loaded from .env.example; copy it to .env and fill in database URLs, LLM API keys, etc. The Dockerfiles already pin the Python base image (python:3.11-slim‑bullseye) and the Next.js build environment.

Real‑World Use

A product manager wants to turn a recorded interview into actionable notes. They upload the audio file via the web UI → create_content stores the file, triggers process_file → the service extracts speech, calls the LLM to generate a summary and flashcards, and writes the results back to the same knowledge base. The manager can then chat with the generated notes through the /api/rag_chat endpoint.

Code Health & Issues

  • HIGH – No test suite – 356 source files, no tests (tests/ missing).
  • HIGH – No CI pipeline – no .github/workflows/ or other build gate.
  • HIGH – No Docker build gate – Dockerfile present but never validated automatically.
  • HIGH – Wildcard CORS – web_crawler/src/app.ts uses cors() with origin: "*" while credentials are enabled.
  • MEDIUM – Dependabot missing – three manifest files (requirements.txt, web/package.json, web_crawler/package.json) lack automated version updates.
  • MEDIUM – Unpinned base image – Dockerfile uses mutable tag python:3.11-slim-bullseye.
  • MEDIUM – Large binaries in repo – web/public/images/ai-apps-coming-soon.svg (4.9 MiB) and data/uszips-new.csv (4.8 MiB) inflate clone size.
  • LOW – Missing conventions – No .editorconfig, .gitattributes, or formatter config.

The Bottom Line

Ainee provides a full‑stack pipeline for AI‑augmented note‑taking, with clear separation between backend ingestion, LLM processing and a Next.js UI. The codebase is functional but suffers from high coupling (import cycles, hub modules) and a lack of automated testing/CI, which raises maintenance risk. It is suitable for teams that can invest in adding tests and refactoring the import graph; otherwise, the platform may be fragile in production.