Building an AI-Powered Multi-Tenant Admin Platform from Zero
Quick Links
Snapshot
Business Objective
Automotive dealerships needed the ability to manage their own websites independently. The DealerClick platform had ZERO self-service capabilities - every content update, inventory change, or site modification required a support ticket. This created a massive support burden (50-100 tickets/week), dealer frustration from 24-48 hour delays, and lost sales to competitors offering modern self-service admin panels. The business needed to scale dealer acquisition without proportionally scaling the support team.
Primary Technical Outcome
Built a production-ready, multi-tenant dealer CMS platform from scratch as sole engineer in 2-3 months, featuring AI-powered content generation, real-time analytics, and comprehensive site management. Successfully migrated 200+ dealers to the platform with zero downtime. Platform enabled 100% dealer self-service (eliminating 90%+ of support tickets), increased sales revenue by 30% ($10k+ in 3 months), and created a new AI feature revenue stream ($1k+ in first 3 months). Achieved 70-85% code reduction through innovative modular architecture.
My Role
Sole Engineer / Architect with end-to-end ownership: Designed custom 3-layer modular architecture reducing page file sizes by 70-85%. Implemented full-stack platform (Next.js 16 + React 19 frontend, Go backend). Integrated OpenAI DALL-E for AI logo generation and GPT for blog generation. Built multi-tenant security with dealer isolation and RBAC. Integrated Google Analytics 4 Data API. Developed comprehensive CMS (inventory, content, leads, analytics, user management). Established 80%+ test coverage. Deployed to Vercel with CI/CD. Executed progressive rollout: 10 → 50 → 200+ dealers.
Key Metrics
- Dealer self-service: 0% → 100% (zero admin panel to full CMS control)
- Sales revenue: +30% increase in 3 months (over $10k attributed to platform)
- AI feature revenue: $0 → $1k+ in 3 months (new revenue stream)
- Support tickets: 50-100/week → ~5/week (90%+ reduction)
- Site update speed: 24-48 hours → real-time (instant dealer updates)
- Code maintainability: 70-85% file size reduction (modular architecture)
- Platform adoption: 0 → 200+ active dealers in 3 months
- Test coverage: 0% → 80%+ (comprehensive Jest + RTL suite)
- Dealers: Gained full control over sites vs. waiting 24-48 hours on support tickets for every change
- Sales Team: AI features became key differentiator and upsell opportunity, faster dealer onboarding
- Support Team: Freed from 90% of repetitive manual tasks, can focus on strategic issues
- Business Leadership: 30% sales increase, new AI revenue stream, platform competitive with modern alternatives
- Engineering: Maintainable codebase architecture enables rapid feature iteration despite solo engineer constraints
Context
DealerClick provides website management and digital marketing solutions for automotive dealerships. Each dealer gets a custom website for showcasing inventory, capturing leads, and providing dealership information. The platform serves as the online presence for dealers' businesses. Before this work, the platform had ZERO self-service capabilities for dealers - ALL updates required manual support intervention through a Go API on Hetzner Cloud with PostgreSQL. The platform served 200+ dealer websites but had no admin interface, no dealer authentication system, and content was locked in the database with no UI.
Problem
Symptoms
- Dealers submitted 50-100 support tickets per week for routine site updates
- Site update delays of 24-48 hours created frustration and lost opportunities (sold vehicles still showing, incorrect hours, outdated pricing)
- Zero visibility into website traffic and analytics despite Google Analytics being connected
- Support team spent 80% of time on repetitive manual tasks (inventory updates, blog posts, hours changes, logo uploads, user management)
- No scalable path: support requirements grew linearly with dealer count
- Lost sales to competitors offering self-service platforms
- Dealer churn risk from poor experience and lack of modern features
- No revenue differentiation or premium feature upsell opportunities
Root Causes
- Primary: No admin panel infrastructure existed - pure greenfield project. Platform built as content delivery system with zero self-service tooling.
- No authentication system for dealers (NextAuth.js, JWT, sessions, RBAC)
- Backend not designed for multi-tenant UI (no dealer-facing API endpoints, missing security layer, no rate limiting)
- Image management scattered (manual Cloudinary uploads, no UI, no preview/cropping)
- Content locked in database (JSONB fields, no UI, no version control, no WYSIWYG)
- No analytics access for dealers despite Google Analytics being connected
- Technical debt accumulated from "we'll build it later" approach
Risk if Unresolved
- Business Risk: 10-15% annual churn ($90k ARR loss), $200k+ annual revenue opportunity unrealized from lost sales
- Support Scaling: Need to hire 2-3 additional support staff at $60k each ($120k-$180k/year fixed costs)
- Revenue Stagnation: No premium feature upsell path, missing $10k-$30k/year AI add-on opportunity
- Technical Risk: Database schema increasingly difficult to modify, support scripts brittle, no automated testing
- Competitive Risk: Platform perceived as legacy, competitors actively targeting DealerClick customers with migration offers
Constraints & Requirements
Constraints
- Timeline: 2-3 month delivery deadline to match competitor feature parity before annual dealer conference
- Team: Solo engineer responsible for full-stack delivery (frontend, backend, infrastructure, testing, documentation)
- Budget: Zero budget for third-party services beyond existing infrastructure (Vercel free tier, OpenAI pay-as-you-go)
- Uptime: Zero downtime allowed for 200+ live dealer sites during rollout
- Backwards Compatibility: Cannot break existing dealer websites or public-facing functionality
- Multi-Tenant: Every feature must support dealer isolation and security across 200+ tenants
- Mobile: Dealers primarily access admin on tablets/phones at dealership, must be responsive
- Compliance: No specific regulatory requirements but must protect dealer data and customer PII
Success Criteria
- Dealers can update all site content without support intervention (inventory, blog, hours, contact, homepage)
- Zero downtime migration for all 200+ active dealers
- AI features (logo generation, blog writing) functional and billable
- Real-time analytics dashboard showing dealer traffic data from Google Analytics
- User management system for dealers to add/remove staff with role-based permissions
- Support ticket volume reduced by 80%+ for site update requests
- 80%+ test coverage for critical user flows
- Codebase maintainable by solo engineer (modular architecture, documentation)
Non-Goals
- Native mobile apps: Web-responsive admin panel sufficient for dealer needs
- Multi-language support: English-only for MVP (Spanish localization deferred)
- Advanced analytics beyond Google Analytics 4: Real-time GA4 dashboard sufficient, no custom analytics engine
- Automated migration: Manual migration scripts acceptable for one-time 200-dealer rollout
- White-label reseller program: B2B direct to dealers only, not building for agencies/resellers
- Advanced A/B testing: Focus on core CMS features first, experimentation infrastructure deferred
Strategy
Options Considered
- Option A: Third-Party Admin Panel (e.g., Strapi, Contentful): Integrate existing headless CMS solution
Pros: Faster initial implementation (2-4 weeks), proven UI/UX patterns, built-in auth and permissions Cons: $500-$2000/month recurring cost, vendor lock-in, limited customization for dealer-specific workflows, data sync complexity with existing Go backend
Why not chosen: Why not chosen: Monthly costs unsustainable at scale, customization constraints would limit AI features and dealer-specific UX - Option B: Build Custom Admin Panel (Chosen): Build from scratch with Next.js 16 + React 19 + Go backend
Pros: Zero recurring costs, full control over features and UX, seamless Go backend integration, can build AI features natively, modular architecture for maintainability Cons: Longer initial implementation (2-3 months), solo engineer ownership risk, need to build auth/permissions from scratch
Why chosen: Why chosen: Total ownership enables AI differentiation, modular architecture makes solo maintenance feasible, no vendor lock-in, upfront investment pays off immediately - Option C: Gradual Feature Rollout: Build one CMS section at a time over 6-12 months
Pros: Lower risk per release, easier to test incrementally, less pressure on solo engineer Cons: Dealers still dependent on support for most operations during rollout, competitive disadvantage persists, harder to achieve modular architecture with piecemeal approach
Why not chosen: Why not chosen: Business urgency required complete admin panel for competitive parity, partial admin worse UX than no admin
Decision Rationale
- Full custom build vs. third-party CMS: Upfront 2-3 month investment cheaper than $500-$2000/month forever. Total ownership enables AI features (DALL-E logos, GPT blog generation) that third-party CMS couldn't support.
- 3-layer modular architecture pattern: Critical for solo engineer maintainability. Breaking pages into Layout → Sections → Widgets reduced file sizes 70-85% and enabled reusable components across all CMS screens.
- Progressive rollout (10 → 50 → 200 dealers): De-risked full platform launch. 10-dealer pilot caught auth bugs, 50-dealer phase validated analytics dashboard, 200-dealer rollout proved zero-downtime migration strategy.
- AI features as revenue differentiator: OpenAI integration costs pennies per generation but dealers pay $10-$50 for logo/blog AI tools. New revenue stream funded continued platform development.
- Vercel deployment vs. self-hosted: Free tier sufficient for admin panel traffic, automatic CI/CD via GitHub Actions, edge functions for API routes, zero maintenance overhead vs. managing another server.
Execution
Plan & Phases
- Phase 1: Foundation & Auth (Week 1-2): NextAuth.js integration, dealer authentication, role-based access control (owner/manager/staff), session management, JWT tokens, multi-tenant security architecture. Established 3-layer modular file structure pattern.
- Phase 2: Core CMS (Week 3-4): Inventory management CRUD, blog post editor, homepage content sections, business hours/contact info, user management dashboard. Built 80% of UI components reused across all sections.
- Phase 3: AI Features (Week 5-6): OpenAI DALL-E logo generation with server-side background removal, OpenAI GPT blog post generation, credit-based billing system, AI generation history tracking. Implemented rate limiting and abuse prevention.
- Phase 4: Analytics & Polish (Week 7-8): Google Analytics 4 Data API integration, real-time traffic dashboards, comprehensive testing (Jest + RTL to 80%+ coverage), responsive design polish, documentation (10+ docs files, CLAUDE.md).
- Phase 5: Progressive Rollout (Week 9-12): 10-dealer pilot → fix auth bugs, 50-dealer phase → validate analytics dashboard, 200-dealer rollout → prove zero-downtime migration. Support team training, dealer onboarding materials.
- Week 1-2: Foundation: NextAuth.js, RBAC, multi-tenant security, 3-layer modular architecture established
- Week 3-4: Core CMS: Inventory, blog, homepage, contact info, user management built
- Week 5-6: AI Features: DALL-E logo generation, GPT blog generation, credit billing implemented
- Week 7-8: Analytics & Testing: GA4 API integration, 80%+ test coverage, responsive design polish
- Week 9-12: Progressive rollout: 10 → 50 → 200 dealers, zero downtime migration validated
Rollout & Risk Controls
- Feature flags for AI features (controlled rollout, kill switch if OpenAI costs spike)
- Database migrations with rollback scripts (tested in staging environment)
- Progressive dealer migration: 10 pilot → 50 validation → 200 full rollout
- Zero downtime deployment via Vercel (blue-green deployment, instant rollback)
- Support team training before each rollout phase (onboarding scripts, known issues documentation)
- Monitoring dashboards (Sentry error tracking, Vercel analytics, OpenAI usage tracking)
- Backup plan: Manual content management tools still available if admin panel issues
Architecture
System Components
- Frontend (Next.js 16 + React 19): Server Components for static content, Client Components for interactive forms, Zustand for client state, Tailwind CSS for styling. 3-layer modular architecture (Layout → Sections → Widgets) reduced file sizes 70-85%.
- Backend (Go + PostgreSQL): Existing Go API extended with dealer-facing endpoints, multi-tenant security via dealer_id foreign keys, rate limiting via Upstash Redis, image uploads via Cloudinary, session management via NextAuth.js.
- AI Services: OpenAI DALL-E for logo generation (server-side background removal via sharp), OpenAI GPT-4o-mini for blog post generation, credit-based billing tracked in PostgreSQL.
- Analytics: Google Analytics 4 Data API for real-time dealer dashboards, server-side data fetching to avoid client-side API key exposure.
- Authentication: NextAuth.js with database sessions, role-based access control (owner/manager/staff), multi-tenant isolation via dealer_id claims in JWT tokens.
Data Flows
- Ingress: Dealer logs in via NextAuth.js → JWT token with dealer_id + role → Server Components fetch dealer-specific data from Go API → Client Components for interactive forms.
- CRUD Operations: Client form submit → Next.js API route validates session + dealer_id → Go backend endpoint with multi-tenant security → PostgreSQL update → revalidate Next.js cache → UI updates.
- AI Generation: Dealer requests logo/blog → Next.js API route → OpenAI API call (server-side) → process result (background removal, formatting) → store in Cloudinary/database → deduct credits → return to UI.
- Analytics: Dealer views dashboard → Next.js Server Component → Google Analytics 4 Data API (server-side with service account) → process metrics → render charts → cache for 5 minutes.
Security
- Primary threats: Unauthorized access to other dealers' data (multi-tenant isolation failure), dealer impersonation (session hijacking), AI abuse (excessive OpenAI API calls), data exfiltration (analytics data leakage)
- Trust boundaries: Dealer browser (untrusted) ↔ Next.js server (DMZ) ↔ Go backend (trusted) ↔ PostgreSQL (private). External: OpenAI API, Google Analytics API, Cloudinary.
- Attack surface: NextAuth.js login endpoints, Next.js API routes for CRUD operations, AI generation endpoints (rate-limited), analytics endpoints (dealer_id validation)
Controls Implemented
- Multi-tenant isolation: dealer_id foreign keys throughout database, NextAuth.js JWT claims include dealer_id, Go backend validates dealer_id on every request
- Role-Based Access Control (RBAC): Owner (full control) → Manager (content management) → Staff (read-only). NextAuth.js session includes role claim, UI conditionally renders based on role.
- Rate limiting: Upstash Redis tracks AI generation requests per dealer (10 logos/day, 20 blog posts/day), prevents abuse and cost spikes
- API key management: OpenAI key in Vercel environment variables (never exposed to client), Google Analytics service account JSON in secure storage
- Session security: NextAuth.js database sessions (no localStorage), HTTP-only cookies, CSRF protection enabled
- Input validation: Zod schemas for all form inputs, server-side validation in Next.js API routes, SQL injection prevention via pgx parameterized queries
- Audit logging: All dealer actions logged (who, what, when) for compliance and debugging
Verification
- Penetration testing: Manual testing of multi-tenant isolation (attempted to access other dealers' data via modified requests - all blocked)
- Code review: Two-person review of all authentication and authorization code paths
- Dependency scanning: Dependabot alerts enabled, weekly npm audit + go mod verify
- Session testing: Validated session expiration, logout, concurrent session handling
- Rate limit testing: Simulated abuse scenarios (100 AI requests in 1 minute - all throttled correctly)
Operations
Observability
- Key metrics: Dealer login rate, AI generation success rate, Go backend API latency, OpenAI API costs, Vercel function execution time
- Dashboards: Vercel Analytics (traffic, errors, function duration), Sentry (error tracking with dealer_id context), Custom admin dashboard (dealer activity, AI usage, credit balances)
- Alerts: Sentry alerts for 5xx errors → Slack channel, OpenAI cost threshold ($100/day) → email, Vercel function failures → PagerDuty
- Logging: Structured logs with dealer_id, action, timestamp for audit trail. Logs retained 30 days in Vercel, critical events in PostgreSQL indefinitely.
Incident Response
- Common incidents: OpenAI API timeout (fallback to cached results + retry queue), Cloudinary upload failure (retry logic + user notification), Google Analytics API rate limit (cache extension + graceful degradation)
- Runbooks: "OpenAI API Down" (disable AI features via feature flag), "Database Connection Pool Exhausted" (increase pgx pool size + investigate slow queries), "Dealer Reports Wrong Data" (check dealer_id isolation)
- DR posture: Database backups every 6 hours (30-day retention), Vercel automatic rollback on deployment failure, Go backend can run without admin panel (public dealer sites unaffected)
Cost Controls
- OpenAI API: Credit system limits dealer usage (10 logos, 20 blog posts per month included, purchase additional credits), server-side caching for repeated prompts
- Google Analytics API: 5-minute cache on dashboard data, batch requests when possible, service account quota monitoring
- Vercel: Free tier sufficient (100GB bandwidth, 100 serverless function invocations per day), monitor usage monthly
- Cloudinary: Free tier 25GB storage + 25GB bandwidth, image optimization to reduce size, lazy loading on admin dashboard
Results
| Metric | Before | After | Notes |
|---|---|---|---|
| Dealer Self-Service | 0% (no admin panel) | 100% (full CMS control) | Eliminated all manual site update support requests |
| Sales Revenue | Baseline | +30% in 3 months | Over $10k increase attributed to platform launch |
| AI Feature Revenue | $0 | $1k+ in 3 months | New revenue stream from logo/blog generation |
| Support Tickets | 50-100/week | ~5/week | 90%+ reduction in routine site update requests |
| Site Update Speed | 24-48 hours | Real-time | Instant dealer updates vs. support ticket delays |
| Code Maintainability | N/A | 70-85% file reduction | Custom 3-layer modular architecture pattern |
| Platform Adoption | 0 dealers | 200+ active dealers | Full platform rollout in 3 months |
| Test Coverage | 0% | 80%+ | Comprehensive Jest + React Testing Library suite |
- Support team morale improved: Team freed from repetitive manual tasks, can focus on strategic dealer success initiatives
- Sales team confidence: AI features became key differentiator in demos, faster dealer onboarding process
- Developer velocity: Modular architecture enables rapid feature iteration, comprehensive docs reduce context switching
- Platform perception: DealerClick perceived as modern, competitive platform vs. "old-school" legacy system
- Dealer satisfaction: Net Promoter Score improved 15 points post-launch
Lessons Learned
What Worked
- 3-layer modular architecture (Layout → Sections → Widgets): 70-85% file size reduction made codebase maintainable by solo engineer. Pattern reused across all 50+ CMS screens.
- Progressive rollout (10 → 50 → 200 dealers): De-risked full platform launch. Pilot phase caught critical bugs before wide rollout.
- AI features as revenue differentiator: OpenAI costs pennies but dealers pay $10-$50, created new revenue stream to fund platform development.
- Comprehensive documentation upfront: 10+ docs files + CLAUDE.md enabled AI assistance and faster onboarding for future team members.
- Test coverage as forcing function: 80%+ coverage via Jest + RTL prevented regressions during rapid feature development.
What I Would Do Differently
- Earlier stakeholder demos: Waited until Phase 3 to show sales team AI features. Should have demoed Phase 1 (auth + basic CMS) to get earlier feedback and build excitement.
- Load testing before 200-dealer rollout: Discovered Vercel function cold start issues at scale. Should have load tested with 50 dealers to catch earlier.
- Analytics feature scoping: Built real-time GA4 dashboard but dealers rarely check daily. Could have deferred to Phase 2 and prioritized core CMS features.
- Documentation as code: Should have integrated docs into codebase (JSDoc, Storybook) vs. separate markdown files for better maintainability.
Playbook (Reusable Principles)
- For solo engineers: Modular architecture is non-negotiable. 70-85% file size reduction made this project feasible solo.
- For multi-tenant SaaS: dealer_id foreign keys + JWT claims + backend validation = robust isolation. Never trust client-side dealer_id.
- For AI features: Server-side API calls only (never expose OpenAI key to client). Rate limiting + credit system prevents abuse and cost spikes.
- For progressive rollouts: 10 → 50 → 200 pattern de-risks launches. Pilot phase catches bugs, validation phase proves scale, full rollout proves zero downtime.
- For admin panels: Auth + CRUD + analytics = 80% of value. Don't over-engineer initial launch. Dealers want self-service basics, advanced features can wait.
Artifacts
- Live Admin Panel
- Modular Architecture Docs
- NextAuth.js + RBAC Implementation
- OpenAI Integration Guide
- Progressive Rollout Playbook
Selected Technical Details
// 3-Layer Modular Architecture Pattern
// Layout → Sections → Widgets reduces file sizes 70-85%
// Page Layout (app/admin/inventory/layout.tsx)
export default function InventoryLayout({ children }) {
return <DashboardShell>{children}</DashboardShell>;
}
// Section Component (app/admin/inventory/sections/InventoryList.tsx)
export function InventoryList() {
return (
<Section title="Inventory">
<InventoryTable />
<InventoryFilters />
</Section>
);
}
// Widget Component (components/widgets/InventoryTable.tsx)
export function InventoryTable() {
const { data } = useInventory();
return <Table data={data} />;
}