惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
GbyAI
GbyAI
博客园 - 司徒正美
美团技术团队
Vercel News
Vercel News
IT之家
IT之家
U
Unit 42
Y
Y Combinator Blog
罗磊的独立博客
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
Jina AI
Jina AI
V
Visual Studio Blog
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
MyScale Blog
MyScale Blog
博客园 - 叶小钗
A
About on SuperTechFans
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
B
Blog RSS Feed

Hacker News: Show HN

PurrrrrFocus: Pomodoro Timer App - App Store Workflow Engine — Multi-Step Orchestration for Bun RapidPhoto: Pro Photo Editor App - App Store GitHub - DheerG/swarms: Achieve extraordinary results with claude code across a variety of tasks SPICE simulation → oscilloscope → verification with Claude Code — Lucas Gerads Show HN: VCoding – A 5 MB native Windows IDE with no dynamic dependencies Show HN: LLMs don't hallucinate because they're bad at math, it's the format GitHub - Agent-FM/agentfm-core: AgentFM is a peer-to-peer network that turns everyday computers into a decentralized AI supercomputer. AgentFM lets you run massive AI workloads directly across a global mesh of idle CPUs and GPUs. Show HN: Tracking Top US Science Olympiad Alumni over Last 25 Years GitHub - Potarix/agent-hub: One place to talk to all your agents Show HN: Runtime security for AI agents(injection,tool abuse, data exfiltration) GitHub - dubeyKartikay/lazyspotify: Terminal Spotify client for macOS and Linux GitHub - the-banana-tool/king-louie: Easy to use GUI Personal AI Assistant. Win/Linux/Mac. Show HN I made my vacation rental bookable by AI agents–no Airbnb, 0% commission GitHub - basteez/jsf-autoreload: maven plugin to enable hot reload on jsf projects uvm32/hosts/host-gdbstub at main · ringtailsoftware/uvm32 GitHub - labsai/EDDI: Config-driven engine that turns JSON into production-grade AI agents. Multi-agent orchestration, 12+ LLM providers, MCP/A2A protocols, RAG, persistent memory, and enterprise compliance (EU AI Act, GDPR, HIPAA). Built on Quarkus. GitHub - glitchnsec/fortyone-oss: AI Executive Assistant Platform Quickstart | Alien GitHub - muxshed/shed: One stream in, or many. Every destination, simultaneously. No cloud middleman, no per-channel fees, no limits. GitHub - ocrbase-hq/ocrbase: 📄 PDF/IMG ->.MD/JSON Document OCR API for PaddleOCR and GLMOCR. Self-hostable. GitHub - impactjo/home-memory: MCP server that lets your AI assistant remember everything about your home. GitHub - Sets88/dbcls: DbCls is a powerful terminal database client that supports various databases GitHub - neptun2000/heor-agent-mcp GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh RollQuation: Math Puzzles - Apps on Google Play GitHub - dropbox/witchcraft Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis GitHub - opentalon/opentalon: OpenTalon is an open-source platform built from the ground up in Go as a robust alternative to OpenClaw LinkedIn™ 职位抓取工具 - Chrome 应用商店
GitHub - JoeCardoso13/brush-up-backend: FastAPI backend f...
jow13_12 · 2026-04-29 · via Hacker News: Show HN

Backend for Brush Up Python, Brush Up Ruby, and Brush Up JavaScript. A small AI-powered backend for tutors of Python, Ruby, and JavaScript built to showcase applied product and engineering work. You can read about its creation in my blog post.

The app answers programming questions by grounding model responses in a personal Zettelkasten-style knowledge base of interconnected markdown notes. This repository contains the backend API, retrieval pipeline, tutor prompt, and test suite.

What this does

  • Serves a FastAPI chat API for the public brush-up frontend
  • Builds one directed knowledge graph per language from markdown notes in notes/<language>/
  • Retrieves the most relevant topic with a lightweight TF-IDF index
  • Expands context with 1-hop graph neighbors before calling Anthropic
  • Tracks per-user token usage in memory to limit abuse on the public demo

Architecture

Flow

  1. A user asks a programming question from the frontend, scoped to a specific tutor (Python, Ruby, or JavaScript).
  2. The backend scores the question against the note corpus with TF-IDF retrieval.
  3. The top matching note becomes the primary topic.
  4. The graph expands that topic with connected neighbor notes.
  5. The backend builds a grounded system prompt from tutor_prompt.md plus the retrieved note context.
  6. Anthropic generates the tutoring response.
  7. The API returns the response, updated conversation history, and token usage metadata.

Main pieces

  • src/api.py
    FastAPI app with /api/chat and /api/health, app startup lifecycle, CORS config, and API error handling.

  • src/agent.py
    Retrieval-aware tutoring logic. Selects context, assembles the system prompt, calls Anthropic, and returns usage metadata.

  • src/graph.py
    Builds a networkx.DiGraph from Obsidian-style [[wikilinks]], exposes 1-hop context gathering, and implements the TF-IDF search index.

  • src/budget.py
    In-memory per-user input/output token budget tracking.

  • src/main.py
    Simple CLI entrypoint for chatting with the tutor locally.

  • notes/<language>/
    The teaching corpus: atomic markdown notes per language (Python, Ruby, JavaScript) with wikilinks between them.

  • tutor_prompt.md
    The tutor's behavioral/system prompt.

Tech stack

  • Python 3.11+
  • FastAPI
  • NetworkX
  • Anthropic Python SDK
  • pytest
  • uv for environment and dependency management
  • Fly.io for deployment

Local development

Prerequisites

  • Python 3.11 or newer
  • uv
  • ANTHROPIC_API_KEY

Install dependencies

uv pip install -e ".[dev,web]"

If you only want the core package plus tests:

uv pip install -e ".[dev]"

Run the API

ANTHROPIC_API_KEY=your_key uvicorn api:app --app-dir src --reload --port 8080

Run the CLI

ANTHROPIC_API_KEY=your_key python src/main.py

Run tests

uv run pytest

Environment variables

Variable Default Purpose
ANTHROPIC_API_KEY none Required for model calls
BRUSH_UP_MODEL claude-sonnet-4-20250514 Anthropic model used by the tutor
BRUSH_UP_INPUT_BUDGET 250000 Per-user input token cap
BRUSH_UP_OUTPUT_BUDGET 60000 Per-user output token cap
BRUSH_UP_ALLOWED_ORIGINS built-in allowlist Comma-separated CORS origins
BRUSH_UP_ALLOWED_ORIGIN_REGEX ^https://[-a-zA-Z0-9]+\.vercel\.app$ Regex-based CORS allowlist

API

POST /api/chat

Request body:

{
  "user_id": "browser-generated-id",
  "tutor": "python",
  "question": "What is a list comprehension?",
  "conversation_history": []
}

Response body:

{
  "response": "A list comprehension is ...",
  "history": [
    { "role": "user", "content": "What is a list comprehension?" },
    { "role": "assistant", "content": "A list comprehension is ..." }
  ],
  "usage": {
    "input_tokens": 123,
    "output_tokens": 456,
    "retrieval": {
      "topic": "Comprehension",
      "score": 0.73,
      "neighbors": 4
    }
  }
}

Behavior notes:

  • Returns 429 when a user exceeds the in-memory token budget
  • Returns 503 when Anthropic reports temporary overload
  • Returns 502 for other Anthropic API failures
  • Does not persist conversation history server-side; the client sends it back on each request

GET /api/health

Returns service status plus the number of topics loaded into each tutor's graph, e.g. {"status": "ok", "tutors": {"python": 127, "ruby": 42, "javascript": 30}}.

Deployment

This repo includes:

  • Dockerfile for containerized deployment
  • fly.toml for Fly.io

The production container:

  • installs the web dependencies
  • copies src/, notes/, and tutor_prompt.md
  • runs uvicorn on port 8080

Testing

The project includes unit, integration, and API-level tests covering the graph builder, retrieval, tutor flow, budget logic, and FastAPI endpoints.

License

MIT