Skip to main content
Connect World follows a layered architecture with clear separation between domain logic, application workflows, infrastructure, and presentation.

Root Directory Structure

connect-world-landing/
├── .git/                    # Git repository
├── .claude/                 # AI assistant configuration
├── public/                  # Static assets
│   ├── images/             # Image files
│   └── favicon.ico         # Site favicon
├── src/                     # Source code (see below)
├── .gitignore              # Git ignore patterns
├── README.md               # Project documentation
├── eslint.config.mjs       # ESLint configuration
├── next.config.ts          # Next.js configuration
├── package.json            # Dependencies and scripts
├── package-lock.json       # Locked dependency versions
├── postcss.config.mjs      # PostCSS configuration
└── tsconfig.json           # TypeScript configuration

Source Code Structure

The src/ directory is organized into layers following Domain-Driven Design principles:
src/
├── app/                           # Next.js App Router
│   ├── api/                       # API route handlers
│   │   ├── orders/               # Order management
│   │   │   └── route.ts          # POST /api/orders
│   │   ├── paypal/               # PayPal integration
│   │   │   ├── create-order/
│   │   │   │   └── route.ts      # Create PayPal order
│   │   │   └── capture-order/
│   │   │       └── route.ts      # Capture PayPal payment
│   │   ├── stripe/               # Stripe integration
│   │   │   └── route.ts          # Stripe payment intent
│   │   └── tmdb/                 # TMDB proxy
│   │       └── route.ts          # Fetch content data
│   ├── layout.tsx                # Root layout component
│   └── page.tsx                  # Homepage entry point

├── application/                   # Application layer (Use Cases)
│   ├── dtos/
│   │   └── OrderDto.ts           # Data transfer objects
│   └── use-cases/
│       └── CreateOrderUseCase.ts # Order creation workflow

├── domain/                        # Domain layer (Business Logic)
│   ├── entities/                 # Core business entities
│   │   ├── Customer.ts           # Customer entity & factory
│   │   ├── Order.ts              # Order entity & factory
│   │   └── Plan.ts               # Plan entity & pricing
│   ├── repositories/             # Repository interfaces
│   │   ├── ICustomerRepository.ts
│   │   └── IOrderRepository.ts
│   └── value-objects/            # Value objects with validation
│       ├── Email.ts              # Email validation & normalization
│       └── Phone.ts              # Phone validation & formatting

├── infrastructure/                # Infrastructure layer (Technical)
│   ├── database/                 # Database layer
│   │   ├── connection.ts         # MongoDB connection (cached)
│   │   └── models/               # Mongoose schemas
│   │       ├── CustomerModel.ts  # Customer schema (snake_case)
│   │       └── OrderModel.ts     # Order schema (snake_case)
│   ├── external/                 # External API integrations
│   │   └── tmdbService.ts        # TMDB API client
│   └── repositories/             # Repository implementations
│       ├── MongoCustomerRepository.ts  # Customer data access
│       └── MongoOrderRepository.ts     # Order data access

├── lib/                           # Shared utilities
│   ├── caseUtils.ts              # Case conversion utilities
│   ├── rateLimiter.ts            # Rate limiting (in-memory)
│   ├── sanitize.ts               # Input sanitization
│   └── utils.ts                  # General utilities (cn, etc.)

└── presentation/                  # Presentation layer (UI)
    └── components/
        ├── LandingClient.tsx     # Main client component
        ├── sections/             # Page sections
        │   ├── AboutSection.tsx  # About section
        │   ├── CatalogSection.tsx  # Content catalog
        │   ├── CheckoutModal.tsx   # Payment checkout
        │   ├── ContactSection.tsx  # Contact information
        │   ├── Footer.tsx          # Site footer
        │   ├── HeroSection.tsx     # Landing hero
        │   ├── Navbar.tsx          # Navigation bar
        │   ├── PlansSection.tsx    # Pricing plans
        │   └── StatsSection.tsx    # Statistics display
        └── ui/                     # Reusable UI components
            ├── BackgroundGradient.tsx
            ├── GlowCard.tsx
            ├── MovingCards.tsx
            ├── NumberCounter.tsx
            ├── SparklesCore.tsx
            ├── Spotlight.tsx
            └── TextReveal.tsx

Layer Breakdown

Domain Layer (src/domain/)

Domain Layer

Pure business logic with zero dependencies on frameworks or infrastructure.
Location: src/domain/entities/
FilePurposeKey Features
Customer.tsCustomer entity and factoryEmail, phone, name validation
Order.tsOrder entity and factoryPayment tracking, subscription dates
Plan.tsPlan entity and pricing matrixDynamic pricing, feature lists
Example: src/domain/entities/Order.ts:19
export function createOrder(data: Omit<Order, "id" | "createdAt" | "activationDate" | "expirationDate">): Order {
  const activationDate = new Date();
  const expirationDate = new Date();
  expirationDate.setMonth(expirationDate.getMonth() + data.months);
  return { ...data, activationDate, expirationDate, createdAt: new Date() };
}
Location: src/domain/value-objects/
FilePurposeValidation
Email.tsEmail validationRegex, lowercase, trim
Phone.tsPhone validationDigit extraction, length check
Example: src/domain/value-objects/Email.ts:4
constructor(email: string) {
  if (!this.isValid(email)) {
    throw new Error(`Invalid email: ${email}`);
  }
  this.value = email.toLowerCase().trim();
}
Location: src/domain/repositories/
FileInterfaceMethods
ICustomerRepository.tsICustomerRepositorycreate, findByEmail, findById
IOrderRepository.tsIOrderRepositorycreate, findByCustomerId, findByReceiptId
Purpose: Define data access contracts without implementation details.

Application Layer (src/application/)

Application Layer

Orchestrates business workflows by coordinating domain entities and repositories.
Location: src/application/use-cases/
FileUse CaseWorkflow
CreateOrderUseCase.tsOrder creationValidate → Create customer → Create order → Persist → Return DTO
Key Code: src/application/use-cases/CreateOrderUseCase.ts:15
async execute(dto: CreateOrderDto): Promise<OrderResponseDto> {
  const email = new Email(dto.email);  // Domain validation
  const phone = new Phone(dto.phone);
  
  const customerData = createCustomer({ name: dto.name, email: email.toString(), phone: phone.toString() });
  const customer = await this.customerRepo.create(customerData);  // Infrastructure
  
  const orderData = createOrder({ ...dto, customerId: customer.id!, status: "completed" });
  const order = await this.orderRepo.create(orderData);  // Infrastructure
  
  return { orderId: order.id!, ... };  // DTO mapping
}
Location: src/application/dtos/
FileDTOsPurpose
OrderDto.tsCreateOrderDto, OrderResponseDtoAPI contract, serialization
Purpose: Decouple external API from internal domain entities.

Infrastructure Layer (src/infrastructure/)

Infrastructure Layer

Implements technical concerns: database, external APIs, and repository implementations.
Location: src/infrastructure/database/
FilePurposeKey Features
connection.tsMongoDB connectionCached connection for serverless
models/CustomerModel.tsCustomer Mongoose schemasnake_case fields, timestamps
models/OrderModel.tsOrder Mongoose schemaUnique payment receipt ID
Connection Caching: src/infrastructure/database/connection.ts:22
export async function connectDB(): Promise<typeof mongoose> {
  if (cached.conn) return cached.conn;  // Reuse existing connection
  if (!cached.promise) {
    cached.promise = mongoose.connect(MONGODB_URI, { bufferCommands: false });
  }
  cached.conn = await cached.promise;
  return cached.conn;
}
Location: src/infrastructure/repositories/
FileImplementationMaps
MongoCustomerRepository.tsICustomerRepositoryCustomer ↔ CustomerDbDoc
MongoOrderRepository.tsIOrderRepositoryOrder ↔ OrderDbDoc
Data Mapping: src/infrastructure/repositories/MongoOrderRepository.ts:7
// Domain entity (camelCase) → Database document (snake_case)
function orderToDb(order: Order): Record<string, unknown> {
  return {
    customer_id: order.customerId,
    payment_method: order.paymentMethod,
    activation_date: order.activationDate,
    // ...
  };
}
Location: src/infrastructure/external/
FileServiceFeatures
tmdbService.tsTMDB APITrending content, now playing, top rated, poster URLs
Example: src/infrastructure/external/tmdbService.ts:29
export async function getTrendingAll(timeWindow: "day" | "week" = "week"): Promise<TmdbMovie[]> {
  const { data } = await tmdbClient.get(`/trending/all/${timeWindow}`);
  return data.results.slice(0, 10);
}

Presentation Layer (src/presentation/ + src/app/)

Presentation Layer

User interface components and API route handlers.
Location: src/app/api/
EndpointFilePurpose
POST /api/ordersapi/orders/route.tsCreate order (with use case)
POST /api/stripeapi/stripe/route.tsStripe payment intent
POST /api/paypal/create-orderapi/paypal/create-order/route.tsPayPal order creation
POST /api/paypal/capture-orderapi/paypal/capture-order/route.tsPayPal payment capture
GET /api/tmdbapi/tmdb/route.tsProxy TMDB requests
Security: All routes implement rate limiting, sanitization, and validation.
Location: src/presentation/components/sections/
ComponentPurposeKey Features
HeroSection.tsxLanding heroSpotlight effect, animated text
PlansSection.tsxPricing displayDynamic pricing, popular badge
CatalogSection.tsxContent showcaseTMDB integration, moving cards
CheckoutModal.tsxPayment formStripe & PayPal, validation
ContactSection.tsxContact infoSocial links, support details
AboutSection.tsxAbout sectionCompany information
StatsSection.tsxStatisticsAnimated counters
Navbar.tsxNavigationScroll-triggered transparency
Footer.tsxSite footerLinks, copyright
Location: src/presentation/components/ui/
ComponentEffectUsage
BackgroundGradient.tsxGradient backgroundCard highlights
GlowCard.tsxGlow effectFeatured items
MovingCards.tsxAnimated carouselContent display
Spotlight.tsxSpotlight effectHero section
SparklesCore.tsxParticle effectsVisual polish
TextReveal.tsxText animationsReveal effects
NumberCounter.tsxAnimated countersStatistics
Location: src/app/
FilePurposeRenders
page.tsxHomepageLandingClient component
layout.tsxRoot layoutMetadata, fonts, global styles

Shared Utilities (src/lib/)

Shared Utilities

Reusable helper functions used across layers.
FilePurposeKey Functions
sanitize.tsInput sanitizationsanitizeString, sanitizeEmail, sanitizePhone, sanitizeNumber, sanitizeEnum
rateLimiter.tsRate limitingcheckRateLimit, getClientIp
caseUtils.tsCase conversioncamelToSnake, snakeToCamel (for DB mapping)
utils.tsGeneral utilitiescn (className merger with tailwind-merge)
Example: src/lib/sanitize.ts
export function sanitizeString(value: unknown, maxLength = 255): string | null {
  if (typeof value !== "string") return null;
  return value.trim().slice(0, maxLength).replace(/[<>]/g, "");
}

export function sanitizeEmail(value: unknown): string | null {
  if (typeof value !== "string") return null;
  const email = value.trim().toLowerCase();
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email) ? email : null;
}

Configuration Files

next.config.ts

Next.js configuration:
  • Image domains (TMDB)
  • Environment variables
  • Build settings

tsconfig.json

TypeScript configuration:
  • Path aliases (@/*)
  • Strict mode enabled
  • JSX support for React

package.json

Dependencies and scripts:
  • dev: Start dev server
  • build: Production build
  • start: Serve production
  • lint: Run ESLint

eslint.config.mjs

ESLint configuration:
  • Next.js rules
  • TypeScript rules
  • Code quality checks

File Naming Conventions

Connect World follows consistent naming conventions across the codebase.
ContextConventionExample
React ComponentsPascalCase + .tsxCheckoutModal.tsx
TypeScript FilesPascalCase + .tsCreateOrderUseCase.ts
Utility FilescamelCase + .tssanitize.ts, rateLimiter.ts
API Routeslowercase + /route.tsapi/orders/route.ts
Domain EntitiesPascalCaseCustomer.ts, Order.ts
Value ObjectsPascalCaseEmail.ts, Phone.ts
Repository InterfacesI prefix + PascalCaseIOrderRepository.ts
Repository ImplementationsMongo prefix + PascalCaseMongoOrderRepository.ts
Database ModelsPascalCase + ModelOrderModel.ts
DTOsPascalCase + DtoOrderDto.ts

Code Conventions

Domain Layer

  • Entities: camelCase properties
  • Factory functions: create prefix
  • No framework imports

Database Layer

  • Schema fields: snake_case
  • MongoDB collections: lowercase plural
  • Mapping functions: toDb, fromDb

API Routes

  • HTTP methods: Uppercase (GET, POST)
  • Error handling: Try-catch with status codes
  • Response: JSON with NextResponse

Components

  • Props: TypeScript interfaces
  • Exports: Named or default
  • Styling: Tailwind CSS classes

Import Path Aliases

Connect World uses TypeScript path aliases for clean imports:
// Instead of:
import { Order } from "../../../../domain/entities/Order";

// Use:
import { Order } from "@/domain/entities/Order";
Configuration: tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Key Files Reference

FilePurposeLines
src/domain/entities/Order.tsOrder entity and factory31
src/domain/entities/Plan.tsPricing logic79
src/application/use-cases/CreateOrderUseCase.tsOrder workflow55
src/app/api/orders/route.tsOrder API endpoint98
FilePurposeLines
src/infrastructure/repositories/MongoOrderRepository.tsOrder data access64
src/infrastructure/database/connection.tsMongoDB connection34
src/infrastructure/external/tmdbService.tsTMDB API client48
FilePurposeFeatures
src/lib/sanitize.tsInput sanitizationXSS prevention, validation
src/lib/rateLimiter.tsRate limitingIP-based, configurable windows
src/domain/value-objects/Email.tsEmail validationRegex, normalization

Directory Purpose Summary

src/domain/

Pure business logicNo dependencies on frameworks, databases, or external services. Contains entities, value objects, and repository interfaces.

src/application/

Workflow orchestrationCoordinates domain entities and repositories to implement business use cases. Defines DTOs for data transfer.

src/infrastructure/

Technical implementationImplements repository interfaces, database models, external API clients, and connection management.

src/presentation/

User interfaceReact components for UI sections and reusable UI elements with animations and effects.

src/app/

Next.js App RouterAPI route handlers and page components following Next.js conventions.

src/lib/

Shared utilitiesReusable helper functions for sanitization, rate limiting, case conversion, and more.

Dependencies Overview

{
  "next": "16.1.6",              // React framework
  "react": "19.2.3",             // UI library
  "mongoose": "^9.2.4",          // MongoDB ODM
  "typescript": "^5",            // Type safety
  "tailwindcss": "^4"            // Styling
}
{
  "stripe": "^20.4.1",                      // Stripe SDK
  "@stripe/react-stripe-js": "^5.6.1",     // Stripe React components
  "@paypal/react-paypal-js": "^9.0.1",     // PayPal SDK
  "axios": "^1.13.6"                        // HTTP client (TMDB)
}
{
  "framer-motion": "^12.35.1",       // Animations
  "lucide-react": "^0.577.0",        // Icons
  "@tabler/icons-react": "^3.40.0",  // Additional icons
  "tailwind-merge": "^3.5.0",        // Class merging
  "clsx": "^2.1.1"                   // Conditional classes
}

Development Workflow

Add Feature

  1. Define entity in domain/
  2. Create use case in application/
  3. Implement repository in infrastructure/
  4. Add API route in app/api/
  5. Create UI in presentation/

Modify Business Logic

  1. Update entity in domain/entities/
  2. Adjust use case in application/use-cases/
  3. Update DTOs if needed
  4. Test changes

Change Database

  1. Update model in infrastructure/database/models/
  2. Adjust repository mapping
  3. Update interfaces if schema changes
  4. Migrate data if needed

Testing Strategy

The layered architecture makes testing straightforward - each layer can be tested independently.
Domain Layer:
  • Test entity factory functions
  • Test value object validation
  • No mocking needed (pure functions)
Application Layer:
  • Test use cases with mock repositories
  • Verify workflow logic
  • Test DTO mappings
Infrastructure Layer:
  • Test repository implementations with test database
  • Test external service clients with mock servers
  • Test database connection
Presentation Layer:
  • Test API routes with mock use cases
  • Test component rendering
  • Test user interactions

Next Steps

Architecture Overview

High-level system architecture and design

Domain-Driven Design

Deep dive into DDD layers and patterns

API Reference

Detailed API endpoint documentation

Development Guide

Setup and development workflow

Build docs developers (and LLMs) love