AMS Docs
Docs / Architecture

Platform Architecture

A technical deep-dive into how AMS Platform is built โ€” from the multi-tenant database design to the queue system, caching strategy, and security model.

High-Level Architecture

๐ŸŒ Next.js 15 Frontend
React / Tailwind / App Router
๐Ÿ“ฑ Mobile (React Native)
iOS & Android / Expo
๐Ÿ”Œ External Clients
Webhooks / Zapier / API
โ†• HTTPS / REST + WebSocket (Laravel Echo)
๐Ÿ” Nginx Reverse Proxy + SSL Termination
โ†•
โš™๏ธ Laravel 11 API โ€” Sanctum Auth + RBAC + Tenant Resolution
โ†•
Members API
Events API
Finance API
Chat API
โ†•
๐Ÿฌ MySQL 8
Primary DB
โšก Redis 7
Cache + Queues
๐Ÿ“ S3 / Local
File Storage
๐Ÿ“ง SES / SMTP
Email Delivery

Technology Stack

LayerTechnologyVersionPurpose
Backend APILaravel11.xREST API, auth, business logic, queues
Frontend (Web)Next.js + React15.x / 19.xSPA + SSR, App Router, server components
Docs (Static)Plain HTML + Tailwind CDNโ€”Documentation portal (this site)
DatabaseMySQL8.0+Primary relational data store
Cache / QueueRedis7.xSession cache, pub/sub, job queues
Web ServerNginx1.18+Reverse proxy, SSL, static files
PHP RuntimePHP-FPM8.2+Laravel application server
AuthLaravel Sanctum3.xSPA cookies + API tokens
Real-timeLaravel Echo + Pusher/Soketiโ€”WebSocket for chat & notifications
StorageAWS S3 / MinIO / Localโ€”File uploads, avatars, documents
PaymentsStripev3 APIDues, invoices, ticket sales
EmailAWS SES / SendGrid / SMTPโ€”Transactional + bulk email
AIOpenAI GPT-4oโ€”AI Copilot, text generation
SMSTwilioโ€”SMS campaigns and OTPs

Multi-Tenant Database Design

AMS uses a shared database, shared schema multi-tenancy model. All tenants share the same MySQL database and tables. Every table that contains tenant-specific data has a tenant_id column.

Tenant isolation is enforced at the application level through a Global Query Scope that automatically appends WHERE tenant_id = ? to every Eloquent query. This scope is set at request boot time after the tenant is resolved from the incoming request.

sql โ€” Core table structure
-- Every tenant-scoped table follows this pattern:
CREATE TABLE members (
  id          BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  tenant_id   VARCHAR(36) NOT NULL,           -- Tenant isolation key
  ulid        VARCHAR(26) NOT NULL UNIQUE,    -- Public-facing ID
  email       VARCHAR(255) NOT NULL,
  status      ENUM('active','inactive','suspended') DEFAULT 'active',
  created_at  TIMESTAMP,
  updated_at  TIMESTAMP,
  INDEX idx_tenant_status (tenant_id, status),
  INDEX idx_tenant_email  (tenant_id, email)
);
โš ๏ธ Raw Query WarningIf you write raw SQL queries (e.g. via DB::statement()), the global scope does NOT apply. Always include WHERE tenant_id = ? manually in raw queries, or use the Eloquent ORM.

Frontend Architecture

The AMS web application is built with Next.js 15 using the App Router. It uses a hybrid rendering strategy:

API Design

The AMS REST API follows these conventions:

Caching Strategy

DataCache DriverTTLInvalidation
User permissionsRedis15 minOn role change or logout
Tenant configRedis60 minOn settings save
Member directoryRedis5 minOn member create/update/delete
Dashboard statsRedis10 minScheduled refresh every 10 min
API responsesHTTP Cache-ControlVariesETags + Last-Modified headers
Session dataRedis2 hoursOn logout or session expiry

File Storage

AMS supports two storage backends configured via FILESYSTEM_DISK environment variable:

All uploaded files are stored with a path pattern of {tenant_id}/{type}/{uuid}.{ext} to maintain tenant isolation at the storage level.

Queue System

Long-running tasks are processed asynchronously via Laravel Queues backed by Redis. This keeps API responses fast and ensures reliability.

QueuePriorityJobs Processed
highHighestWebhook delivery, payment confirmation, OTP SMS
defaultNormalEmail sending, member import processing, PDF generation
lowLowestReport generation, bulk exports, analytics aggregation

Queue workers are managed by Supervisor on the server, configured to restart automatically on failure. Failed jobs are stored in the failed_jobs table and can be retried via php artisan queue:retry all.

Security Overview

โ„น๏ธ More on SecuritySee the full Security Model page for RBAC, audit logging, GDPR compliance, and the vulnerability disclosure process.