Skip to content

01 - Architecture

Overview

Wavic WebApp is a modern React application built with Next.js 15 using the App Router pattern. It serves as the frontend for the Wavic music collaboration platform, communicating with a NestJS 11 backend API.

High-Level Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                         WAVIC WEBAPP                                │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│   ┌─────────────┐    ┌─────────────┐    ┌─────────────┐            │
│   │   Pages     │    │  Layouts    │    │ Components  │            │
│   │ (App Router)│◄───│ (6 options) │◄───│ (RizzUI +   │            │
│   │             │    │             │    │  Custom)    │            │
│   └──────┬──────┘    └─────────────┘    └─────────────┘            │
│          │                                                          │
│   ┌──────▼──────┐    ┌─────────────┐    ┌─────────────┐            │
│   │   Server    │    │  Contexts   │    │    Hooks    │            │
│   │  Actions    │    │ (Wave, Auth,│    │ (30+ custom)│            │
│   │             │    │  Dropzone)  │    │             │            │
│   └──────┬──────┘    └─────────────┘    └─────────────┘            │
│          │                                                          │
└──────────┼──────────────────────────────────────────────────────────┘


    ┌─────────────┐
    │  WAVIC API  │
    │  (NestJS)   │
    │  Port 8080  │
    └─────────────┘

Technology Stack

Core Framework

TechnologyVersionPurpose
Next.js15.5.12React framework with App Router
React19.1.0UI library
TypeScript5.7+Type-safe JavaScript
Turbopack(built-in)Fast development builds

Styling & UI

TechnologyVersionPurpose
Tailwind CSS4.1.18Utility-first CSS (CSS-first config)
RizzUI2.1.0Pre-built component library
Framer Motion12.33.0Animations and transitions
react-icons5.3.0Icon library

State Management

TechnologyVersionPurpose
React Context(built-in)Component-tree state
Jotai2.17.0Atomic state management
next-auth4.24.13Authentication state

Data & Forms

TechnologyVersionPurpose
React Hook Form7.53.0Form state management
Zod3.23.8Schema validation
@tanstack/react-table8.20.5Data tables

Audio & Media

TechnologyVersionPurpose
WaveSurfer.js7.6.0Audio waveform visualization
react-player2.16.0Media playback
Swiper11.1.14Image carousels

Integrations

TechnologyVersionPurpose
Stripe8.0.0Payment processing
Three.js0.173.03D graphics (CD animation)
nodemailer8.0.0Email sending

Design Patterns

1. App Router Pattern (Next.js 15)

The application uses Next.js App Router with route groups:

src/app/
├── (hydrogen)/          # Main authenticated routes
│   ├── artist/          # Artist space pages
│   ├── project/         # Project pages
│   ├── wave/            # Track/waveform pages
│   └── layout.tsx       # Layout with sidebar
├── (other-pages)/       # Secondary pages
├── api/                 # API routes
└── layout.tsx           # Root layout

2. Server Actions Pattern

API calls are made through Server Actions (React Server Components):

typescript
// src/server-actions/artist/actions.tsx
'use server';

export const getArtists = async (session: any) => {
  const response = await fetch(
    `${process.env.NEXT_PUBLIC_API_BASE_URL}/artist`,
    {
      headers: { Authorization: `Bearer ${session?.token}` },
    }
  );
  return response.json();
};

3. Multi-Layout System

The app supports 6 different layout configurations:

LayoutDescription
BerylliumDefault - Clean header, minimal sidebar
HydrogenFull sidebar layout
HeliumCompact navigation
LithiumWide content area
BoronMinimal chrome
CarbonAlternative style

4. Context-Based State

Major features use dedicated React Contexts:

typescript
// Key contexts:
WaveContext       → Audio player, track, waveform state
NotificationContext → Real-time notifications
DropZoneContext   → File upload state
LoadingContext    → Global loading states
NavigatorContext  → Navigation state

5. Component Composition

Components follow atomic design principles:

components/
├── ui/              # Atoms (buttons, inputs)
├── cards/           # Molecules (track cards)
├── headers/         # Organisms (page headers)
├── modal/           # Modal dialogs
└── skeletons/       # Loading states

Data Flow

┌──────────┐    ┌─────────────┐    ┌──────────────┐    ┌──────────┐
│  User    │───►│  Component  │───►│   Server     │───►│   API    │
│  Action  │    │  (Client)   │    │   Action     │    │ (NestJS) │
└──────────┘    └─────────────┘    └──────────────┘    └──────────┘
                       │                  │                   │
                       ▼                  ▼                   ▼
                ┌─────────────┐    ┌──────────────┐    ┌──────────┐
                │   Context   │◄───│   Response   │◄───│  MongoDB │
                │   Update    │    │              │    │          │
                └─────────────┘    └──────────────┘    └──────────┘

Key Architectural Decisions

1. Why App Router over Pages Router?

  • Better performance with React Server Components
  • Simplified data fetching with Server Actions
  • Improved layout nesting capabilities

2. Why Server Actions over API Routes?

  • Reduced client-side bundle
  • Automatic request deduplication
  • Type-safe end-to-end

3. Why RizzUI?

  • Pre-built accessible components
  • Tailwind-native styling
  • Consistent design language

4. Why Multi-Layout System?

  • A/B testing different UI approaches
  • User preference customization
  • Incremental UI updates

Environment Configuration

The app uses @t3-oss/env-nextjs for type-safe environment variables:

javascript
// src/env.mjs
export const env = createEnv({
  server: {
    NODE_ENV: z.enum(['development', 'test', 'production']),
    NEXTAUTH_SECRET: z.string(),
    NEXTAUTH_URL: z.string().url(),
    GOOGLE_CLIENT_ID: z.string().optional(),
    GOOGLE_CLIENT_SECRET: z.string().optional(),
  },
  client: {
    NEXT_PUBLIC_APP_NAME: z.string().optional(),
  },
});

Performance Optimizations

  1. Turbopack: Development server uses Turbo for fast HMR
  2. Image Optimization: Next.js Image component with remote patterns
  3. Skeleton Loading: All data-dependent views show loading skeletons
  4. Lazy Loading: Components loaded on-demand where appropriate

Tech Stack Assessment

✅ Strong Choices

TechnologyWhy It Works
Next.js 15 + App RouterIndustry standard, great SEO, server components, excellent DX
TypeScript 5.6Type safety critical for a collaborative app
Tailwind CSSFast UI development, consistent design system
JotaiLightweight, atomic state - perfect for audio player state
WaveSurfer.jsBest-in-class waveform library, actively maintained
NextAuth.jsHandles OAuth/credentials well, good security defaults
StripeGold standard for payments

⚠️ Considerations

AreaCurrentConsideration
RizzUIv2.1.0Stable v2 with Tailwind v4 support. Breaking API changes from v1 resolved
TurbopackDev modeStable in Next.js 15 for development builds
No TestingNone foundCritical gap - add Vitest + Playwright before scaling
No MonorepoSeparate reposConsider Turborepo if API/webapp need shared types
Audio ProcessingClient-side onlyFor enterprise, may need server-side transcoding (FFmpeg)

Enterprise Readiness Gaps

NeedRecommended Solution
ObservabilitySentry (errors), Application Insights or PostHog
Feature FlagsLaunchDarkly or Azure App Configuration
CDN for AudioAzure CDN or CloudFront
Real-time CollabAzure SignalR or Socket.io for live cursors/presence
Background JobsAzure Functions or Inngest for async processing

Cloud Infrastructure

Platform: Microsoft Azure

ComponentAzure ServicePurpose
API (NestJS)Container AppsServerless containers with auto-scale
DatabaseCosmos DB (MongoDB API)Document database, seamless MongoDB migration
File StorageBlob StorageAudio files, attachments, images
CDNAzure CDNGlobal audio streaming delivery
AuthEntra ID B2C (future)Enterprise SSO when needed
MonitoringApplication InsightsAPM, logs, metrics, tracing
CI/CDGitHub ActionsSource control and deployments
SecretsKey VaultAPI keys, connection strings

Cost Estimates

ScaleMonthly EstimateNotes
Dev/Test~$50-80Free tiers where available
Production (100 users)~$150-250Container Apps + Cosmos DB + Blob
Scale (1000+ users)~$500-800Auto-scaling, reserved capacity

Deployment Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        AZURE                                    │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│   ┌──────────────┐     ┌──────────────┐     ┌──────────────┐   │
│   │   Azure CDN  │     │  Container   │     │  Cosmos DB   │   │
│   │  (Audio/     │     │    Apps      │     │  (MongoDB)   │   │
│   │   Static)    │     │  (NestJS)    │     │              │   │
│   └──────┬───────┘     └──────┬───────┘     └──────┬───────┘   │
│          │                    │                    │           │
│          │             ┌──────▼───────┐            │           │
│          │             │    Blob      │            │           │
│          └────────────►│   Storage    │◄───────────┘           │
│                        │  (Audio/     │                        │
│                        │   Files)     │                        │
│                        └──────────────┘                        │
│                                                                 │
│   ┌──────────────┐     ┌──────────────┐     ┌──────────────┐   │
│   │  App Insights│     │  Key Vault   │     │ Azure DevOps │   │
│   │  (Monitoring)│     │  (Secrets)   │     │  (CI/CD)     │   │
│   └──────────────┘     └──────────────┘     └──────────────┘   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Migration Path

  1. Phase 1: Deploy API to Azure Container Apps
  2. Phase 2: Set up Cosmos DB (MongoDB API), migrate data
  3. Phase 3: Configure Azure Blob Storage for audio files
  4. Phase 4: Add Azure CDN for global audio delivery
  5. Phase 5: Implement Application Insights for observability

Ctrl-Audio Platform Documentation