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

推荐订阅源

H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
L
LangChain Blog
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog
G
Google Developers Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I Built a Free Python Practice Platform With Zero Ser...
Ameer Abdullah · 2026-06-19 · via DEV Community

I wanted to build a Python coding challenge platform that generates a completely unique problem every single time. No question bank. No repetition. Genuinely infinite practice.

The challenge was cost. AI API calls cost money. If thousands of students use a tool daily, the API bill scales with them. Most free tools either cap usage or die when they hit their billing limit.

Here is how I built PyCodeIt with a Bring Your Own Key (BYOK) architecture that keeps server costs at zero while giving users a completely frictionless experience.


The Architecture

┌─────────────────────────────────┐
│         User's Browser          │
│                                 │
│  Next.js App (Vercel)          │
│  ├── Challenge UI               │
│  ├── Auth (Supabase JS)         │
│  └── API Key (localStorage)     │
└──────────┬───────────────┬──────┘
           │               │
           ▼               ▼
      Supabase       OpenRouter API
     (Auth, DB,     (Direct from browser
  Edge Functions)    using user's key)

The key insight: if the AI call goes from the user's browser to OpenRouter using the user's own API key, there is no server cost to me. By relying on OpenRouter, users gain access to a pool of 8 different models, and the system can handle instant fallback logic automatically if a specific provider encounters any latency or rate limits.


The Frictionless UX: No Forced Signup

The BYOK model usually creates friction because it forces visitors through a lengthy checklist before they can even see the product.

To combat this, PyCodeIt allows users to start practicing immediately with or without signing up. A user can simply land on the site, paste their OpenRouter API key directly into the application, and generate a problem instantly.

For users who want to track their progress, authentication and score tracking are available via Supabase, which is free up to 50,000 monthly active users:

  • Authentication with email and Google OAuth
  • PostgreSQL database for scores and streaks
  • Row Level Security so users only access their own data

The schema for the scoring system looks like this:

CREATE TABLE user_stats (
  user_id UUID REFERENCES auth.users(id) PRIMARY KEY,
  xp INTEGER DEFAULT 0,
  streak INTEGER DEFAULT 0,
  best_streak INTEGER DEFAULT 0,
  total_solved INTEGER DEFAULT 0,
  easy_solved INTEGER DEFAULT 0,
  medium_solved INTEGER DEFAULT 0,
  hard_solved INTEGER DEFAULT 0,
  last_active DATE DEFAULT CURRENT_DATE
);

ALTER TABLE user_stats ENABLE ROW LEVEL SECURITY;

CREATE POLICY "Users manage own stats"
ON user_stats
USING (auth.uid() = user_id);


The Problem Generation Prompt

The prompt structure that consistently returns clean, structured JSON across the configured fallback models:

const prompt = `Generate a unique Python ${difficulty} dry-run problem about ${concept}.
The user must predict the exact terminal output.
Make it genuinely tricky but fair for ${difficulty} level.

Return ONLY valid JSON with exactly these keys:
{
  "title": "string",
  "concept": "string",
  "code_snippet": "string (valid Python with print statements)",
  "correct_output": "string (exact terminal output)",
  "hint_1": "string",
  "hint_2": "string",
  "explanation": "string (step by step trace)"
}
Do not include any text outside the JSON object.`;

Enforcing response_format: { type: "json_object" } in the API call eliminates parsing errors and ensures structural consistency.


The Security Honest Assessment

The main trade-off with a pure browser-based BYOK setup is that API keys are visible in network requests. A technically sophisticated user can open browser developer tools, inspect the network tab, and see their API key being sent out.

This is a risk to the user, not to the platform. The key is theirs. However, I handle this by being completely transparent in the UI:

  • Transparency: A note near the API key input explains exactly where the key is stored (localStorage) and how it is used (sent directly to the AI router from the browser, never to my servers).
  • Minimal permission guidance: The UI links to instructions on creating restricted OpenRouter keys or setting strict budget limits.
  • Easy rotation: A visible "Clear API key" button makes it trivial to wipe the key from localStorage instantly.

What I would do differently if building again: I would pass all requests through a Supabase Edge Function proxy. The user's key would still be used for the actual AI request, but it would flow through the serverless function rather than directly from the client network tab. This completely hides the key from frontend inspection while still utilizing the user's personal quota.


Conclusion

By keeping the platform decoupled from an expensive central API budget and removing mandatory account creation, the product remains highly accessible and cost-free to run. The only thing that would push me to paid tiers is outgrowing Supabase's 50k monthly active users limit, which is a good problem to have.

The platform is live at pycodeit.com if you want to see this architecture running in production. Try it out at pycodeit.com and feel free to drop a comment if you want to discuss any aspect of the implementation.


Written by the developer behind PyCodeIt, a free AI-powered Python dry-run practice platform for technical interview preparation.