---
url: https://docs.corbitaltech.dev/products/whatsmark-saas/source-code-structure.md
description: >-
  Developer reference for WhatsMark SaaS source code organization. Built on
  Laravel 12 with the TALL stack (Tailwind, Alpine.js, Livewire, Laravel).
  Includes folder layout, multi-tenant architecture, modular addon system, and
  key directories.
---

# Source Code Structure

## Overview

WhatsMarkSaaS is built on the modern **TALL stack** (Tailwind CSS, Alpine.js, Livewire, Laravel) providing a robust SaaS platform for WhatsApp marketing automation. This structure ensures scalability, maintainability, and developer-friendly architecture.

## Technology Stack

* **[Laravel 12](https://laravel.com/)** - Backend PHP framework for robust API and business logic
* **[Livewire 3](https://livewire.laravel.com/)** - Full-stack reactive components without complex JavaScript
* **[Alpine.js](https://alpinejs.dev/)** - Minimal JavaScript framework for enhanced interactivity
* **[Tailwind CSS](https://tailwindcss.com/)** - Utility-first CSS framework for rapid UI development

::: warning Important Developer Notice
**This page contains technical developer documentation only.**

**Before making custom changes:**

* **TALL Stack Knowledge Required**: Custom modifications require solid understanding of Laravel, Livewire, Alpine.js, and Tailwind CSS
* **Risk Warning**: Improper changes may break your application functionality
* **Limited Support**: If you make custom modifications to the original script, our technical support will be limited
* **Backup First**: Always create a complete backup before making any custom changes
* **Testing Required**: Test all modifications in a development environment before applying to production
  :::

## Main Application Structure

```php
whatsmark-saas/
 app/                        # Application core
 bootstrap/                  # Application bootstrapping
 config/                     # Configuration files
 database/                   # Database migrations, seeds, factories
 public/                     # Web server document root
 resources/                  # Views, assets, language files
 routes/                     # Route definitions
 storage/                    # Generated files, logs, cache
 tests/                      # Automated tests
 vendor/                     # Composer dependencies
 Modules/                    # Custom modules (if using modular architecture)
 .env                        # Environment configuration
 artisan                     # Laravel command-line interface
 composer.json               # PHP dependencies
 package.json                # Node.js dependencies
 vite.config.js              # Vite build configuration
```

## Application Core (`/app`)

### Key Directories

```php
app/
 Http/
    Controllers/       # Traditional controllers
    Middleware/        # Request middleware
 Livewire/             # Livewire components (main UI layer)
 Models/               # Eloquent models
 Providers/            # Service providers
 Console/              # Artisan commands
 Policies/             # Authorization policies
```

### Livewire Components (`/app/Livewire`)

**What it does:** Houses all reactive UI components organized by feature and user type.
**Why it's useful:** Provides clean separation of concerns and makes the codebase maintainable and scalable.

```php
Livewire/
 Admin/                # Admin panel components
    Dashboard.php
    Tenant/          # Tenant management
       TenantList.php
       TenantCreator.php
       TenantDetails.php
    Plan/            # Subscription plans
       PlanList.php
       PlanCreator.php
    Subscription/    # Subscription management
       SubscriptionList.php
       InvoicesList.php
    Settings/        # Application settings
       PaymentGateway/
       Website/
       System/
    WhatsApp/        # WhatsApp integration
 Auth/                # Authentication components
 Frontend/            # Public-facing components
 Tenant/              # Tenant dashboard components
```

## Configuration (`/config`)

**What it does:** Contains all application configuration files for different services and features.
**Why it's useful:** Centralizes settings management and makes environment-specific configurations easy to manage.

Essential configuration files:

```php
config/
 app.php              # Core application settings
 database.php         # Database connections
 livewire.php         # Livewire configuration
 tenant.php           # Multi-tenancy settings
 subscription.php     # Billing configuration
 whatsapp.php         # WhatsApp API settings
 payment.php          # Payment gateway settings
 restrictions.php     # Domain/subdomain restrictions
```

## Routes (`/routes`)

**What it does:** Organizes all application routes by user type and functionality.
**Why it's useful:** Keeps routing logic clean and makes it easy to manage access control.

```php
routes/
 web.php              # Public web routes
 api.php              # API endpoints
 auth.php             # Authentication routes
 admin.php            # Admin panel routes
 tenant.php           # Tenant dashboard routes
```

### Route Examples

```php
// Admin routes use Livewire components directly
Route::get('tenants', TenantList::class)->name('tenants.list');
Route::get('subscriptions', SubscriptionList::class)->name('subscriptions.list');

// Tenant routes
Route::get('dashboard', TenantDashboard::class)->name('tenant.dashboard');
```

## Resources (`/resources`)

**What it does:** Contains frontend assets, views, and language files.
**Why it's useful:** Organizes all presentation layer components in a logical structure.

```php
resources/
 views/
    layouts/         # Base layouts (admin, tenant, frontend)
    livewire/        # Livewire component views
    components/      # Reusable Blade components
    admin/           # Admin-specific views
    tenant/          # Tenant-specific views
    frontend/        # Public website views
 css/
    app.css          # Tailwind CSS compilation
 js/
    app.js           # Alpine.js & application JS
 lang/                # Multi-language translation files
```

## Database (`/database`)

**What it does:** Contains database structure, sample data, and migration files.
**Why it's useful:** Maintains database version control and provides consistent data structure across environments.

```php
database/
 migrations/          # Database schema migrations
 seeders/            # Sample and default data
 factories/          # Model factories for testing
 settings/           # Application settings migrations
```

## Multi-tenancy Architecture

**What it does:** Provides complete data isolation between customer accounts.
**Why it's useful:** Ensures security, scalability, and customization for each SaaS customer.

### Tenant Middleware

* Path-based tenant detection
* Database query scoping
* Complete data isolation
* Route protection and access control

### Tenant-aware Components

* All Livewire components respect tenant context
* Automatic data filtering by tenant
* Isolated file storage per tenant

## Development Workflow

### Creating Components

```bash
# Create admin Livewire component
php artisan make:livewire Admin/FeatureName

# Create tenant Livewire component
php artisan make:livewire Tenant/FeatureName
```

### Database Operations

```bash
# Run migrations
php artisan migrate

# Seed sample data
php artisan db:seed

# Create new migration
php artisan make:migration create_feature_table
```

This architecture provides a scalable, maintainable foundation for the WhatsMarkSaaS platform using modern Laravel development practices.

***

::: danger When to Avoid Custom Changes:

* If you're not familiar with the TALL stack architecture
* If you don't have Laravel development experience
* If you need the feature urgently without proper testing time
* If you require full technical support coverage
  :::

::: tip Recommendation:

Use the built-in features and configuration options first. [Contact support](https://support.corbitaltech.dev) for feature requests before attempting custom development
:::
