Skip to content

Repository files navigation

Coding Trainer

An AI-powered coding review trainer that dynamically generates programming challenges using the Anthropic API (Claude). Each session produces fresh challenges across 5 structured learning blocks and 5 programming languages.

Phase 1 — FastAPI + Railway/Render deployment (this repo)
Phase 2 — AWS Lambda + API Gateway + S3 rebuild (coming after Phase 1 is live)


What It Does

Select a programming language, pick a learning block, and Claude generates a tailored challenge on demand. Every session is different — same learning objectives, fresh scenario each time — so the app has genuine replay value.

5 Learning Blocks

#BlockWhat You Practice
1Language FundamentalsCore syntax and idiomatic patterns
2Code ReviewSpot bugs, security flaws, and inefficiencies
3Algorithm PatternsHashmaps, stacks, sliding window, recursion
4Edge Cases & Error HandlingDefensive coding and robust error handling
5Full Module ReviewCorrectness, efficiency, security, readability

5 Languages: Python, JavaScript, C#, Java, Go


Architecture (2-Tier + External API)

┌────────────────────────────────────────────────────────────┐
│ Presentation Tier │
│ HTML / JS / CSS — single-page frontend │
│ Language selector → block nav → challenge → hint/answer │
└────────────────────────────┬───────────────────────────────┘
│ POST /generate
▼
┌────────────────────────────────────────────────────────────┐
│ Application Tier │
│ FastAPI (Python) — main.py │
│ • Validates request (language, block, difficulty) │
│ • Builds structured prompt for each block type │
│ • Calls Anthropic API via anthropic Python SDK │
│ • Returns structured JSON challenge │
└────────────────────────────┬───────────────────────────────┘
│ External API call
▼
┌──────────────────────┐
│ Anthropic API │
│ (external service) │
│ claude-haiku-4-5 │
└──────────────────────┘

No data tier — there is no database or file store. The Anthropic API is a third-party external service, not an owned data layer. A true data tier would be added in a future version (e.g., storing user session history).

API endpoint:POST /generate

Request:

{ "language": "python", "block_number": 1 }

Response:

{
"challenge": "...",
"context": "...",
"hint": "...",
"answer": "...",
"tags": ["list-comprehension", "iteration"],
"difficulty": "beginner"
}

Valid languages: python, javascript, csharp, java, go
Valid block numbers: 1 through 5


Local Setup

Prerequisites: Python 3.11+ and an Anthropic API key

# 1. Clone the repo
git clone https://github.com/your-username/coding-trainer.git
cd coding-trainer
# 2. Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh # macOS/Linux# or: winget install astral-sh.uv # Windows# 3. Install dependencies and create virtual environment
uv sync
# 4. Set up your API key
copy .env.example .env # Windows
cp .env.example .env # macOS / Linux# Then open .env and replace "your_key_here" with your actual key# 5. Run the server
uv run uvicorn main:app --reload --port 8000

Open http://localhost:8000 in your browser.

Note: Use uvicorn directly for local development — not the Procfile (which uses $PORT, a Unix env var).


Cloud Deployment

Railway

  1. Push this repo to GitHub
  2. Create a new project at railway.appDeploy from GitHub repo
  3. In the Railway project settings → Variables → add:
    ANTHROPIC_API_KEY = sk-ant-your-key-here
    
  4. Railway auto-detects the Procfile and deploys. Your app will be live at a *.up.railway.app URL.

Render

  1. Push this repo to GitHub
  2. Create a new Web Service at render.com
  3. Connect your GitHub repo
  4. Settings:
    • Build Command:pip install -r requirements.txt
    • Start Command:uvicorn main:app --host 0.0.0.0 --port $PORT
  5. In Environment → add:
    ANTHROPIC_API_KEY = sk-ant-your-key-here
    
  6. Deploy. Render provides a *.onrender.com URL.

Cold starts: Free-tier instances on both platforms sleep after inactivity. The first request after idle may take 10–15 seconds — the frontend shows a "Server warming up" message automatically.


Fork & Deploy Your Own Instance

This project is designed to be self-hosted. Every fork requires its own Anthropic API key — no shared keys, no shared costs.

  1. Fork this repo on GitHub
  2. Deploy to Railway or Render (steps above)
  3. Add your own ANTHROPIC_API_KEY in the platform's environment settings
  4. Done — your own private instance, your own costs

Extending the App

Add a new language:

  1. Add it to LANGUAGE_DISPLAY in main.py
  2. Update the validate_language allowed set
  3. Add a <button> to the language selector in static/index.html

Add a new block:

  1. Add a prompt to the prompts dict in build_prompt() in main.py
  2. Update the block selector in static/index.html
  3. Update BLOCK_NAMES in the JavaScript

Switch to a more capable model:
In main.py, change model="claude-haiku-4-5-20251001" to "claude-sonnet-4-6" for higher quality challenges at higher cost.


Screenshots

Coming soon — add screenshots of the challenge card, hint reveal, and answer reveal here.


Phase 2 — AWS Rebuild (Planned)

After Phase 1 is live, this project will be rebuilt on AWS infrastructure to demonstrate cloud architecture skills:

  • AWS Lambda — Python function handling challenge generation
  • API Gateway — HTTP endpoint in front of Lambda
  • S3 — Static frontend hosting
  • Secrets Manager / SSM — API key storage (no .env files)

Both versions will remain available as separate branches/repos. The two-phase story (fast deployment → cloud-native rebuild) demonstrates both product delivery and AWS cert knowledge.


License

MIT — see LICENSE

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages