Inspiration
As Large Language Models (LLMs) scale, developers face a brutal trade-off between intelligence, speed, and API costs. Running every single user query through a massive, complex reasoning model is an architectural waste of capital and computational power. Many incoming prompts are simple commands, routine data structures, or conversational pleasantries that do not require heavy compute.
We built Aegis to solve this operational bottleneckâacting as an intelligent middleware buffer that dynamically grades incoming traffic structural complexity and maps requests to the most efficient computational layer.
What it does
Aegis acts as an intelligent, high-speed middleware buffer between your users and your AI models. Instead of blindly sending every single user prompt to an expensive, high-end LLM, Aegis intercepts incoming text payloads in real-time, instantly grades their structural and semantic complexity, and dynamically shoots them to the most cost-efficient processing layer.
By running an aggressive 4-tier routing matrix, Aegis optimizes system performance across the board:
- Slashes Inference Costs: Filters out basic inputs, commands, and formatting strings locally, ensuring you only pay for heavy AI compute when deep reasoning is actually required.
- Maximizes Response Speeds: Routes simple queries to ultra-low-latency deterministic pipelines, freeing up system bandwidth and delivering instant replies to users.
Prevents Service Downtime: Monitors connection health and automatically switches to fallback redundancy paths if a primary AI gateway encounters a network failure or rate limit.
How we built it
Aegis was architected from scratch as a highly performant, full-stack developer utility designed to sit cleanly in production pipelines:
The High-Performance Core Engine: Built natively with Node.js and TypeScript. We chose to orchestrate the infrastructure using
tsx(TypeScript Execute), allowing us to leverage blazing-fast, modern ECMAScript module structures without sacrificing type safety or compiling speed.The Intelligence Layer: Powered by the Gemini API. The system analyzes multi-line text strings and handles structured data transformations using advanced context matching rules when a prompt escalates past the basic tiers.
The Smart Routing Matrix: Engineered using high-speed structural regex maps and token keyword matchers. This local preprocessing middleware evaluates string complexity asynchronously, sorting traffic instantly before it ever touches a network socket.
The Real-Time Analytics Dashboard: Developed using React.js and styled with Tailwind CSS. The interface uses dynamic components to render active traffic flows, display active backend server logs, and visually graph simulated token cost savings in real time.
Challenges we ran into
Cross-Environment Path Failures: During local deployment testing across different developer machines, hidden configuration files caused instant application crashes. We ran into severe pathing bugs when the system attempted to locate the local operational
.envfile within nested directory structures. We solved this by normalizing configuration loaders and updating our documentation to strictly enforce standard path rules.Asynchronous Processing Latency: Building a middleware engine means your grading logic must be faster than the model itself. Initially, executing heavy string parsing and structural regex rules across large, multi-line prompt payloads caused slight performance bottlenecks in the Node.js event loop. We had to optimize our evaluation pipelines to run completely asynchronously, preventing blocking IO and keeping transit latency near zero.
State Syncing with
tsxModules: Because the routing engine utilizes native ECMAScript modules orchestrated viatsx, maintaining consistent state updates between our active routing logs and the rendering React frontend required careful lifecycle engineering. We had to implement clean event emitters to stream engine metrics seamlessly without causing memory leaks or infinite re-renders.Accomplishments that we're proud of
Zero-Overhead Local Grading Matrix: We successfully built an evaluation pipeline that can parse, score, and sort text payloads locally in microseconds. Achieving this level of speed means our routing engine adds virtually zero transit latency to incoming user requests.
Production-Ready System Security: Instead of taking shortcuts by hardcoding private credentials directly into our source code, we built a secure, enterprise-grade architecture that strictly relies on standard
.envconfiguration files. The system is structurally isolated and explicitly guarded against accidental data leaks on public repositories.A Fully Functional Full-Stack Utility: We are incredibly proud of bridging a high-performance TypeScript backend proxy seamlessly with a sleek, real-time React dashboard. It turns a complex architectural backend problem into a clean, highly visual, and easily interactive tool that anyone can understand instantly.
Solving a Massive Real-World Problem: We moved past building basic generative AI wrappers and successfully engineered a true piece of developer infrastructure that addresses the biggest bottleneck in the AI industry today: the skyrocketing cost of LLM tokens.
What we learned
The Power of Infrastructure-Level Code: Building Aegis forced us to step out of the comfort zone of simply consuming APIs and dive deep into middleware architecture. We learned how to write highly efficient, non-blocking asynchronous routines in Node.js that handle real-time string analysis without dragging down performance.
The Crucial Role of Token Economics: Developing this project opened our eyes to the massive operational costs scaling companies face when deploying Large Language Models. We gained a profound understanding of prompt token payloads, structural data footprints, and how intelligent cost-routing can make or break an AI application's financial sustainability.
The Subtleties of Modern Build Ecosystems: Working with native ECMAScript modules via
tsxtaught us a lot about the nuances of modern TypeScript execution environments. We learned how to manage configuration variables cleanly across different environments, package project dependencies reliably, and ensure an effortless setup process for external developers.What's next for Aegis Multi-Tier AI Routing Engine
Implementing Live Redis Caching: Our next immediate technical milestone is to integrate an ultra-fast Redis layer. This will allow Aegis to cache repetitive user queries and deterministic responses locally, completely bypassing the need to trigger duplicate external inference calls and dropping costs down to zero for recurring traffic.
Dynamic Predictive Token Estimation: We plan to transition our current static scoring rules into a lightweight, local machine learning classifier. By analyzing the structural patterns of historical data payloads, the engine will be able to predict exact token costs and API latencies before a request is even dispatched.
Production Cloud Orchestration: While Aegis runs flawlessly as a local development server, we want to package the backend architecture into native Docker containers. This will allow developers to instantly deploy Aegis as an auto-scaling gateway proxy on cloud platforms like AWS, Google Cloud, or Microsoft Azure.
Multi-Provider Gateway SDK: We aim to build out native connection adapters for other industry-standard LLM orchestrators (like Anthropic and OpenAI). This will allow Aegis to serve as a truly universal, model-agnostic traffic manager for multi-cloud enterprise AI systems.
Built With
- geminiapi
- json
- node.js
- react.js
- tailwindcss
- tsx
- typescript
- vite

Log in or sign up for Devpost to join the conversation.