Engineering case study · Math contest tooling

ContestKit

A problem-set generation toolkit built around 2,295 AMC and AIME problems from 2010–2024. Normalizes problems, classifies topics, and balances generated sets using community difficulty ratings.

Python / FastAPI / PostgreSQL / BeautifulSoup / KaTeX

The problem

Generating a useful mathematics problem set requires consistent problem data, difficulty information, and a deliberate topic distribution. ContestKit collects and normalizes AMC and AIME problems, then adds topic classification and a balancing stage for generated sets. The service also needs controlled API access and safe document exports.

Engineering decisions

  • Scraped, parsed, and normalized 2,295 AMC 8, AMC 10, AMC 12, and AIME problems from 2010–2024, using community difficulty ratings as labels for problem-set generation.
  • Built a postgresql-backed FastAPI service with seven endpoints, CORS middleware, localhost-only default binding, and optional bearer or custom-header authentication.
  • Developed keyword-based topic classification and automatic balancing to maintain subject distribution across generated sets.
  • Hardened LaTeX export by escaping plain text and removing unsafe tex commands. Added regression tests for API authorization and export sanitization.

The result

The normalized collection contains 2,295 problems from 2010–2024. A seven-endpoint FastAPI service provides access to the postgresql-backed data, while regression tests cover API authorization and LaTeX export sanitization.

Explore the ideas

Interactive explanations of concepts behind this work: