Documentation is currently in beta. Report issues →
ArchitectureOverview

Architecture Overview

Y3NKO is built on a modern full-stack architecture using Next.js 14 with the App Router.

High-Level Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         CLIENT LAYER                            │
├─────────────────────────────────────────────────────────────────┤
│  Next.js 14 (App Router)                                        │
│  - Server Components (default)                                  │
│  - Client Components (interactive elements)                     │
│  - Tailwind CSS + shadcn/ui                                     │
└─────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│                         API LAYER                               │
├─────────────────────────────────────────────────────────────────┤
│  Next.js API Routes + Server Actions                            │
│  - Authentication (Supabase Auth)                               │
│  - Input validation (Zod)                                       │
│  - Rate limiting                                                │
└─────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│                       DATABASE LAYER                            │
├─────────────────────────────────────────────────────────────────┤
│  PostgreSQL (Supabase)                                          │
│  - Prisma ORM                                                   │
│  - Row Level Security                                           │
│  - Connection pooling                                           │
└─────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│                     EXTERNAL SERVICES                           │
├─────────────────────────────────────────────────────────────────┤
│  - Paystack (payments)                                          │
│  - Cloudinary (images)                                          │
│  - Resend (emails)                                              │
│  - Vercel (hosting)                                             │
└─────────────────────────────────────────────────────────────────┘

Tech Stack Decisions

Frontend Framework: Next.js 14 (App Router)

Why:

  • Server-side rendering for SEO and performance
  • Server Components reduce client-side JavaScript
  • Built-in API routes simplify architecture
  • Excellent deployment with Vercel
  • Strong TypeScript support

Database: PostgreSQL via Supabase

Why:

  • Managed PostgreSQL with generous free tier
  • Built-in authentication
  • Row-level security for data protection
  • Real-time capabilities for future features
  • Easy backups and scaling

ORM: Prisma

Why:

  • Type-safe database queries
  • Auto-generated TypeScript types
  • Easy migrations and schema management
  • Great developer experience

Authentication: Supabase Auth

Why:

  • Multiple providers (Google, Email)
  • Session management built-in
  • Server and client-side helpers
  • Integrates with Supabase database

Payments: Paystack

Why:

  • Best payment gateway for Ghana
  • Supports Mobile Money (MTN, Vodafone, AirtelTigo)
  • Supports international cards
  • Good API documentation
  • Reasonable fees (1.95% local, 3.9% international)

Image Storage: Cloudinary

Why:

  • Automatic image optimization
  • Responsive image transformations
  • CDN included
  • Generous free tier (25GB)

Styling: Tailwind CSS + shadcn/ui

Why:

  • Utility-first for rapid development
  • shadcn/ui provides accessible, customizable components
  • Small bundle size
  • Easy to maintain consistency

Email: Resend

Why:

  • Simple API
  • Good deliverability
  • Affordable pricing
  • React Email support

Hosting: Vercel

Why:

  • Zero-config Next.js deployment
  • Global edge network
  • Automatic HTTPS
  • Preview deployments
  • Free tier suitable for MVP

Performance Targets

MetricTargetStrategy
LCP< 2.5sImage optimization, SSR
FID< 100msCode splitting, minimal JS
CLS< 0.1Reserved image dimensions
TTI< 3.5sProgressive loading
Bundle Size< 200KBTree shaking, dynamic imports

Security Layers

  1. Authentication: Supabase Auth with session handling
  2. Authorization: Role-based access control (USER, HOST, ADMIN)
  3. Data Validation: Server-side validation with Zod
  4. SQL Injection: Prisma parameterized queries
  5. XSS Prevention: React’s built-in escaping
  6. HTTPS: Enforced via Vercel
  7. Rate Limiting: API route protection
  8. Secrets: Environment variables, never committed

Scaling Considerations

The architecture is designed to scale:

  1. Database: Supabase provides easy vertical scaling
  2. Caching: Add Redis for session/query caching (future)
  3. CDN: Cloudinary for images, Vercel Edge for static assets
  4. Search: Consider Algolia for advanced search (future)
  5. Background Jobs: Add job queue for emails/notifications (future)