Inspiration
The tech ecosystem in Sub-Saharan Africa is exploding with world-class talent, yet developers often lack localized, accessible platforms to rigorously test and benchmark algorithmic efficiency against modern constraints. We noticed that while building complex systems, engineers frequently rely on intuition rather than concrete metrics to optimize their code.
We wanted to build Algorithm Arena a platform that doesn't just run code, but mathematically evaluates it. Our goal was to create a competitive and educational environment where developers can visualize how their algorithms scale, transforming abstract time complexity like $O(N)$ into tangible execution metrics, and putting African engineering talent on the global map.
What it does
Algorithm Arena is an AI-powered execution and benchmarking platform. Users can submit code snippets to solve specific computational problems. The platform:
- Executes the code in a secure environment.
- Benchmarks runtime and memory consumption across scaling input sizes ($N$).
- Analyzes the code using Google Gemini AI to infer the theoretical time complexity (e.g., distinguishing between an optimal $O(N \log N)$ approach and a naive $O(N^2)$ brute-force method) and suggests mathematical optimizations.
For example, if a user submits a sorting algorithm, the arena calculates the empirical runtime $T(N)$ and plots it to verify if the limit behavior aligns with theoretical expectations: $$ \lim_{N \to \infty} \frac{T(N)}{N \log N} = C $$
How we built it
We architected the system for speed, safety, and scalability:
- Frontend: We built a highly responsive, modern interface using Next.js 15 (App Router) with TypeScript. For styling, we utilized Tailwind v4 and Shadcn UI to create a sleek, dark-mode terminal aesthetic that feels native to developers.
- Backend: The core engine is driven by Python FastAPI. Python allowed us to build robust concurrent endpoints capable of handling rapid execution requests and easily interfacing with data science libraries for benchmarking.
- Database & Auth: We leveraged Supabase (PostgreSQL). It handles secure user authentication, stores historical benchmark records, and manages leaderboard states seamlessly.
- AI Integration: We integrated the Google Gemini API on the backend. By passing the user's Abstract Syntax Tree (AST) and code execution metrics to Gemini, we generate deep, heuristic feedback on how to improve algorithmic bounds.
- Payments: We integrated Stripe to offer premium tiers for organizations wanting to run massive datasets or private hackathons.
Challenges we ran into
- Secure Code Execution: Running untrusted, user-submitted code safely is notoriously difficult. We had to implement strict sandboxing to prevent infinite loops (like a rogue $O(2^N)$ recursive function) from crashing our backend or causing memory leaks.
- Real-time Feedback: Ensuring the frontend received real-time updates while the FastAPI backend spun up isolated execution environments required careful handling of asynchronous state and streaming responses.
- AI Hallucinations on Complexity: Initially, the AI struggled to accurately determine the difference between complex nested loops. We overcame this by feeding Gemini not just the code, but the actual empirical runtime arrays, allowing the model to perform polynomial regression analysis to confirm its theoretical Big-O guesses.
Accomplishments that we're proud of
- Successfully integrating the Google Gemini API to provide genuinely useful, mathematical code reviews rather than just generic linting suggestions.
- Building a full-stack application from scratch in a matter of days, connecting a modern Next.js 15 frontend seamlessly to a high-performance Python FastAPI backend.
- Creating a beautiful, developer-centric UI/UX that makes the complex data of algorithm execution times easily digestible through visual graphs and clear metrics.
- establishing a robust PostgreSQL schema via Supabase that can reliably track and rank hundreds of code execution attempts in real-time.
What we learned
Building Algorithm Arena pushed our limits in distributed systems architecture. We learned how to securely sandbox environments, optimize FastAPI for high concurrency, and seamlessly tie together a Next.js frontend with a Python backend using Supabase as the glue. Most importantly, we learned how to effectively prompt engineering models (Gemini) to act as a reliable, automated code reviewer for highly technical mathematical logic.
What's next for Algorithm Arena
We plan to introduce support for multiple programming languages (we are currently focused on Python/JavaScript), implement WebSockets for live multiplayer coding battles, and partner with tech hubs across Sub-Saharan Africa to host regional algorithmic tournaments!
Built With
- artificial-intelligence
- css3
- html5
- javascript
- machine-learning
- node.js
- postgresql
- react
- rest-api
- shadcn-ui
- stripe
- tailwind-css
- typescript
Log in or sign up for Devpost to join the conversation.