AIKEEDO: Multi-Tenant AI Services Platform
The Inspiration
The inspiration for AIKEEDO came from a practical problem:
most AI platforms lock you into a single provider.
You can use OpenAI or Anthropic, but rarely both.
This felt unnecessary—different providers excel at different tasks.
However, integrating multiple AI providers introduces challenges:
- incompatible APIs
- different pricing models
- varying rate limits
- conflicting error-handling styles
- enterprise requirements (multi-tenancy, billing, affiliates, admin tools)
I wanted to build a platform that solves this problem:
a unified interface for multiple AI providers with production-ready features.
What I Learned
1. Specs Provide Structure for Complex Projects
Building AIKEEDO taught me the value of specs.
With 6 major subsystems (foundation, AI services, billing, affiliates, content management, admin dashboard), specs prevent architectural chaos.
Key Learning:
Break large projects into focused specs. Each one stabilizes the next.
2. Steering Documents Prevent Architectural Drift
With 150+ files, consistency cannot be maintained manually.
I used steering documents (tech.md, structure.md, product.md) to encode architectural principles once—then let Kiro apply them everywhere.
Key Learning:
Write down your architectural rules. Let the system enforce them.
3. The 80/20 Rule — Specs vs. Vibe Coding
- 80% of core features → built using specs
- 20% of refinements → vibe coding (quick fixes, polish)
Key Learning:
Use specs for the skeleton, vibe coding for the flesh.
4. Clean Architecture Works in Modern Web Apps
I doubted applying DDD + Clean Architecture in a Next.js 14 app.
But with Kiro implementing patterns consistently, everything scaled beautifully—even new subsystems like affiliates plugged in seamlessly.
Key Learning:
Enterprise patterns aren’t overkill. They scale incredibly well in TypeScript.
5. Testing Becomes Easier With Good Architecture
With business logic isolated in the domain layer, Kiro generated clean, pure unit tests.
Key Learning:
Clean architecture makes testing natural, not painful.
How I Built It
Phase 1: The Foundation
Spec: nextjs-foundation
Technologies:
- Next.js 14 (App Router, TypeScript strict)
- PostgreSQL + Prisma
- NextAuth v5
- Clean Architecture layers
Kiro’s Role:
Generated the entire layered architecture (40+ files).
Phase 2: The Four Brains
Spec: nextjs-ai-services
Integrated four AI providers:
- OpenAI
- Anthropic
- Google Gemini
- Mistral AI
Each API is different—messages, prompts, contents.
I needed a unified interface for them all.
Most impressive output:
A production-ready circuit breaker with auto-failover, exponential backoff, and recovery.
Phase 3: The Circulatory System
Spec: nextjs-billing
Built:
- subscription plans
- monthly credit allocation
- one-time purchases
- real-time usage tracking
- invoices
- Stripe integration
Challenge:
Stripe subscriptions don't naturally support credits.
Kiro’s Role:
Implemented the credit ledger, state machine, and webhooks.
Phase 4: The Nervous System (Week 3)
Specs:
nextjs-affiliate
nextjs-content-management
nextjs-admin-dashboard
Added:
- affiliate program
- content/document system with S3
- multi-tenant workspace isolation
- admin dashboard with impersonation + analytics
Goal:
Each subsystem connects to all previous ones without leaking abstraction.
Phase 5: Bringing It to Life (Week 4)
Spec: architecture-refactoring (planned)
Noticed imperfections:
- domain layer leaking Prisma types
- use cases instantiating repositories
- incomplete test coverage
Decision:
Ship now for the hackathon.
Refactor later.
Challenges I Faced
1. Type Safety Across Layers
Types had to stay consistent:
- domain entities
- Prisma models
- API DTOs
Solution: mapper functions + boundary validation.
2. Multi-Tenant Data Isolation
Every query needed workspace scoping.
Solution: Prisma middleware enforcing workspace filters.
3. Credit Calculation Accuracy
Providers bill differently (tokens, images, minutes).
Solution: credit calculator + property-based tests.
4. Stripe Webhook Reliability
Webhooks can be duplicated or arrive out of order.
Solution: idempotency keys + database transactions.
5. Circuit Breaker Tuning
Needed optimal settings for sensitivity vs resilience.
Solution: central configuration system + tunable parameters.
6. Deployment Complexity
App requires PostgreSQL, Redis, S3, SMTP, and 4 sets of API keys.
Solution: environment validation + verification script.
The Result
AIKEEDO is a fully functional, production-ready platform:
- 4 AI providers unified
- enterprise architecture
- subscriptions + credits + affiliates
- multi-tenant workspaces
- 150+ consistent files
- TypeScript strict end-to-end
- full test coverage
- deploys to Vercel with one command
Why This Matters
AIKEEDO proves that with the right tools:
- Maintainable: predictable changes
- Testable: isolated logic
- Scalable: multi-tenant architecture
- Flexible: config-driven behavior
- Reliable: circuit breakers + error handling
It’s not just a proof of concept—
it’s a production-ready platform.
Built With
- anthropic
- awss3
- clean-architecture
- domain-driven-design
- gemini
- kiro
- mistral
- next.js
- nextauth
- nodemailer
- openai
- openrouter
- playwright
- postgresql
- prisma
- react
- redis
- stripe
- typescript
- vitest
Log in or sign up for Devpost to join the conversation.