MockOAI is a full-featured mock test preparation platform designed specifically to simulate the actual format of corporate Online Assessments (OAs), such as the TCS NQT-Style exam. Unlike generic DSA grinding sites, MockOAI provides a unified, timed test interface that bundles English, Reasoning, Quant, CS Fundamentals, and live sandboxed Coding execution in one unified sitting. The platform integrates Gemini AI to generate custom, context-rich questions and provide deep post-assessment performance reviews, with dynamic fallback mechanisms to ensure complete offline viability.
Here is how the main components of MockOAI interact to deliver sandboxed code execution, AI grading, and database-driven rankings:
graph TD
Client[Next.js Client UI] -->|1. Auth Requests| BetterAuth[Better Auth + Google OAuth]
Client -->|2. Start Attempt / Save Answer| NextServer[Next.js App Router Server]
NextServer -->|3. Query/Persist Progress| NeonDB[(PostgreSQL / Neon DB)]
NextServer -->|4. Generate/Grade Questions| GeminiAPI[Google Gemini AI API]
NextServer -->|5. Run Coding Submissions| Piston[Docker Sandboxed Piston Engine]
subgraph Local Sandbox
Piston -->|Compile & Execute| GCC[gcc / c++]
Piston -->|Execute| Python[python]
Piston -->|Execute| Java[java/javascript]
end
MockOAI is fully built and includes the following features:
- Timed exam sections matching NQT specification (English, Reasoning, Quant, CS Fundamentals, and Coding).
- Section boundary controls with review flags and sequential locking.
- Section prefetching runs in the background to eliminate loading pauses between sections.
- Real-time sandbox code compiler using Piston execution.
- Multi-language support (C++, Python, Java, JavaScript) with custom test case matching.
- Standard error output, time limit monitoring, and detailed failure outputs.
- Supports three source modesβ
static(local JSON),ai(live Gemini), andhybrid(AI with automatic fallback). Environment variablesMCQ_SOURCE_MODE,CODING_SOURCE_MODE, andQUESTION_SOURCE_MODEcontrol the mode per section. - In hybrid mode the system first attempts Geminiβgenerated questions; if the request fails or the RPD quota is exhausted, a circuit breaker automatically switches to the static bank.
- This switchable architecture lets graders run the full app without consuming Gemini quota, making it a gameβchanging feature for demos and offline testing.
- Circular progress visualizers and bar charts displaying section performance.
- Complete review screens for coding submissions detailing input arguments, expected vs actual compiler output, and passed/failed markers.
- Deep AI-generated summaries presenting customized feedback on coding logic and topic-wise revision advice.
- Dynamic, timeframe-based ranking dashboard showing user performance across This Week, This Month, and All Time.
- Visual Top-3 Podium styling with dynamic highlighter colors and flat neo-brutalist accents (reordering the top three players as 2-1-3 for a real podium effect).
- Sticky "Your Rank" widget anchored at the bottom when you scroll past your own row, allowing users to see their global position at a glance.
- Debounced, case-insensitive user search widget that queries the database by username.
- Simple follow/unfollow toggle buttons that establish follower-following relationships between users.
- A dedicated Friends tab in the leaderboard that dynamically scopes results to only show the scores of the users you choose to follow.
- A dynamic mock OA attempt animation sequence showing MCQ progression, typed code submissions, sandbox test executions, and result compilations with micro-animations.
- Frontend & Server: Next.js 15 (App Router, React 19)
- Styling: Tailwind CSS v4, Vanilla CSS variables, and Lucide React icons
- Authentication: Better Auth with Google OAuth
- Database & ORM: PostgreSQL (Neon Database) and Prisma ORM
- Code Execution: Dockerized Piston Execution Engine
- Artificial Intelligence: Google Gen AI SDK (Gemini Pro)
- Node.js:
v18.xorv20.x(recommended) - Docker Desktop: Required to host the sandboxed code execution environment
- Database: A Neon PostgreSQL account or local PostgreSQL server
- Google Cloud OAuth Credentials: For setting up Google Sign-In
- Gemini API Key: A valid key from Google AI Studio
Follow these exact steps in order to stand up MockOAI locally:
# Clone the repository
git clone https://github.com/Yash-Bankar/MockOAI
cd MockOAI
# Install npm dependencies
npm installCopy .env.sample to .env and fill in the required credentials:
cp .env.sample .envEnsure you provide:
DATABASE_URL(PostgreSQL connection string)BETTER_AUTH_SECRET(generate withopenssl rand -hex 32)GOOGLE_CLIENT_ID&GOOGLE_CLIENT_SECRET(from Google Cloud Console)GEMINI_API_KEY(from Google AI Studio)
Because the app compiles and executes user code locally, you must spin up Piston via Docker:
# Navigate to the piston configuration directory
cd piston
# Start the Piston docker container in detached mode(start docker app before this command if you are windows user)
docker-compose up -dNext, configure the execution runtimes. Depending on your Operating System, run one of the following:
On Linux/macOS/Git Bash:
curl http://localhost:2000/api/v2/runtimesYou should see a JSON array (initially empty if no runtimes are installed yet).
Install the required language runtimes:
bash install-runtimes.shOn Windows (PowerShell):
# Run the PowerShell equivalent commands to register runtimes
Invoke-RestMethod -Uri "http://localhost:2000/api/v2/packages" -Method Post -ContentType "application/json" -Body '{"language":"gcc","version":"10.2.0"}'
Invoke-RestMethod -Uri "http://localhost:2000/api/v2/packages" -Method Post -ContentType "application/json" -Body '{"language":"python","version":"3.12.0"}'
Invoke-RestMethod -Uri "http://localhost:2000/api/v2/packages" -Method Post -ContentType "application/json" -Body '{"language":"java","version":"15.0.2"}'Verify Piston is running: Return to the root directory and test that the runtimes API returns the registered languages:
cd ..
curl http://localhost:2000/api/v2/runtimesInitialize Prisma schema migrations and run the local seeder to populate the exam configuration:
# Run Prisma migrations
npx prisma migrate dev --name init
# Seed database structure & static question bank
npm run seednpm run devOpen http://localhost:3000 in your browser.
To configure authentication:
- Visit the Google Cloud Console Credentials Page.
- Create a new project or select an existing one.
- Click Create Credentials -> OAuth client ID (select Web application).
- Under Authorized JavaScript origins, add:
http://localhost:3000
- Under Authorized redirect URIs, add the exact OAuth callback endpoint:
http://localhost:3000/api/auth/callback/google
- Copy the generated Client ID and Client Secret into your
.envfile asGOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET.
flowchart TD
Start[Load / Generate Section] --> CheckMode{Source Mode Check}
CheckMode -->|hybrid| TryGemini[Call Gemini API Pro]
TryGemini -->|Success| SaveExam[Display Generated Question]
TryGemini -->|Rate Limit / Fail| CircuitBreaker[Trigger Circuit Breaker]
CircuitBreaker --> Fallback[Load Randomly from Local JSON Bank]
CheckMode -->|static| Fallback
Fallback --> SaveExam
MockOAI supports toggling question generation/evaluation between hybrid and static modes using three environment variables in .env:
MCQ_SOURCE_MODE=hybridorstaticCODING_SOURCE_MODE=hybridorstatic
Google AI Studio's free-tier Gemini API has daily API call limits and rate limits (e.g., Requests Per Day cap). During continuous debugging, grading, or demo environments, this limit can be exhausted quickly.
By setting MCQ_SOURCE_MODE=static and CODING_SOURCE_MODE=static, the platform will fetch questions entirely from the pre-seeded JSON file templates without invoking the Gemini API. This allows a grader or reviewer to test the full system instantly with zero API calls and no active API key setup required.
To confirm your local deployment is working correctly:
- Go to
http://localhost:3000, click Start a Mock OA, and sign in via Google OAuth. - Hit Start New Mock OA to load Section 1 (English). Verify that questions render on-screen.
- Switch sections or fast-forward to the Coding section.
- Select a language (e.g., Python), write a solution, and click Run Code. Verify that test cases compile and return logs (this confirms the Next.js server is successfully communicating with the dockerized Piston engine).
- Click Submit Exam at the top right.
- Verify that the Results dashboard loads successfully, showing a performance breakdown chart, detailed test case diagnostics, and an AI analysis card.
The application is fully deployable to production for free!
- The Next.js frontend is hosted on Vercel.
- The Piston code execution engine is hosted on a Google Cloud Platform (GCP) Compute Engine VM (staying within the E2-Micro "Always Free" tier).
- The Gemini API free tier is used for generating questions and grading so go easy on it.
- Sandbox Execution Engine: The coding section requires the Piston sandbox server to be accessible. It must either run locally via Docker on port
2000, or be hosted on a cloud VM (e.g. GCP) with its IP configured in thePISTON_URLenvironment variable. If the server is offline or unreachable, coding executions will return connectivity errors. - Gemini rate limits: If free-tier Gemini keys are used, they have strict rate limits (RPD caps). While the hybrid circuit breaker shields the app from crash loops, heavy multi-user utilization can temporarily exhaust your keys.
- Static mode limits: If run entirely in static mode, questions will eventually repeat because the database utilizes a finite set of questions (60 MCQs per section, and 11 complex coding questions). Switch to AI/hybrid mode to get dynamically generated questions.
Key directories of MockOAI:
mockoai/
βββ app/ # Next.js App Router folders
β βββ api/ # Backend endpoints (Auth, Exam actions, Leaderboard, Run/Submit Code)
β βββ components/ # Main client components (e.g. HeroSimulator)
β βββ dashboard/ # User landing dashboard
β βββ exam/ # Main timed exam interface & sandbox IDE
β βββ leaderboard/ # Brutalist Leaderboard tabs & Followers widget
βββ components/ # Shareable UI components (Card, Button, Badge)
βββ data/ # Local JSON mock test repositories
β βββ question-banks/ # English, Reasoning, Quant, CS, and Coding static questions
βββ lib/ # Shared helper files
β βββ code/ # Piston execution API wrapper & diff checkers
β βββ question-source/ # Hybrid source router & JSON static parser
β βββ auth.ts # Better Auth initialization
β βββ prisma.ts # Prisma client connection handler
βββ piston/ # Docker compose files and runtimes configuration script
βββ prisma/ # Database schema definitions and seed data script