🔮 HiddenForces
An AI-powered hidden test case generator for LeetCode and Codeforces problems. Built using FastAPI, LangChain, LangGraph, and Google Gemini, it generates robust and diverse test cases (including boundary conditions, edge cases, and stress tests) to thoroughly validate code submissions on the KodeKshetra Server platform.
- AI-Driven Generation: Leverages Google Gemini models to analyze problem constraints and produce high-quality test inputs.
- Stateful Validation: Uses a LangGraph workflow to orchestrate the generation and structure validation of test cases.
- Multiple Formats: Native support for LeetCode function signature format and Codeforces standard I/O format.
- Comprehensive Coverage: Targets minimal, maximal, edge, corner, and large scale stress inputs.
- High Performance: Asynchronous FastAPI endpoints capable of handling concurrent generation.
[ FastAPI Request ] ──▶ [ LangGraph Workflow ]
│
├─► [ Test Case Generator ] (Gemini LLM)
│
├─► [ Test Case Validator ] (Regex & Bounds)
│
└─► [ JSON Response ]
- Framework: FastAPI (Python 3.8+)
- AI Orchestration: LangChain & LangGraph
- LLM Provider: Google Generative AI (Gemini)
- Deployment: Uvicorn Server
HiddenForces/
├── app/
│ ├── main.py # FastAPI endpoints & CORS
│ ├── models.py # Pydantic schemas
│ ├── workflow.py # LangGraph state workflow
│ ├── codeforces_generator.py # CF generator prompt
│ ├── codeforces_validator.py # CF input constraint validator
│ ├── leetcode_generator.py # LC generator prompt
│ └── leetcode_validator.py # LC input constraint validator
├── requirements.txt # Python dependencies
└── run.py # Port-configured startup script
- Python 3.8 or higher
- Google Gemini API key (from Google AI Studio)
-
Create Virtual Environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Create a
.envfile in the root:GOOGLE_API_KEY=your_gemini_api_key_here PORT=8000
-
Start Server:
python run.py
The service will start on
http://localhost:8000(interactive API docs available at/docs).
| Method | Endpoint | Description | Key Body Parameters |
|---|---|---|---|
| GET | /health |
Check service health | None |
| POST | /generate-leetcode-tests |
Generate test cases for a LeetCode problem | problem (ID, constraints, examples, difficulty) |
| POST | /generate-codeforces-tests |
Generate test cases for a Codeforces problem | problem (ID, inputFormat, constraints, examples) |
- Google Generative AI for the Gemini API.
- Akshat Garg - GitHub Profile.