Skip to content

🧱 RawDigs — Laravel Contexts Overview

Last updated: 2025-10-09 (Europe/Paris)

This document describes the bounded contexts and domain architecture of the RawDigs Laravel application.
Each context is modularized under app/Contexts/{Context}/ and encapsulates its own models, actions, repositories, DTOs, and service providers.
For table-level views, see the ER Diagram Index.

For scaffolding commands and path conventions, see CLI Tooling.


🧭 Philosophy

RawDigs follows a modular monolith pattern inspired by Domain-Driven Design (DDD):

  • Each domain area lives in its own context folder under app/Contexts/.
  • Contexts define contracts (interfaces) for repositories and services.
  • Contexts are autonomous but can communicate through domain events.
  • This structure allows future package extraction (composer submodules).

🗂 Context Directory Layout

app/Contexts/
  Accounts/
  Creators/
  Catalog/
  Commerce/
  Payouts/
  Media/
  Fulfillment/
  Community/
  Governance/
  Marketing/
  Analytics/
  Compliance/
  Integrations/
  Support/
  Search/

Each context contains:

Models/
Repositories/
Contracts/
Actions/
Policies/
Events/
DTOs/
Providers/


1️⃣ Accounts Context

Handles identity, access, and organizational structure.

Detailed guide: Accounts Context · Diagrams: Accounts Models, Accounts Entity Map

Model Description
User Base account identity.
Organization Label / collective / company.
Membership Connects users to organizations with a role.
Invitation Pending organization invites.

Features - User registration, authentication, 2FA. - Organization creation and membership management. - Roles & permissions via Spatie Laravel-Permission (team scoped). - Profile data, avatars, country, handle.


2️⃣ Auth Context

Governs role assignment, scoped permissions, and authentication guards across RawDigs.

Detailed guide: Auth Context · Diagrams: Roles & Permissions Schema Map, Auth Entity Map

Component Description
Guards Sanctum web sessions, personal access tokens, and Filament guard for staff tooling.
Roles & Permissions Spatie team-mode roles synchronized from Accounts memberships, with per-member overrides.
API Tokens Sanctum personal access tokens scoped for mobile, CLI, and partner integrations.
Flows Session login, token issuance, Filament dashboard authentication.

Features - Stateful SPA auth with Sanctum + Inertia (no separate API layer required). - Team-scoped roles using Spatie’s team_id for organization isolation. - Token lifecycle management with audit trails and scope enforcement. - Filament admin access with optional 2FA and session policies.


3️⃣ Creators Context

Manages artists and their collaborators.

Detailed guide: Creators Context · Diagrams: Creators Models, Creators Entity Map

Model Description
Artist Creator entity, may belong to an organization.
ArtistMember User ↔ Artist link with role (owner/admin/member).
ArtistAlias Alternate artist names or stage names.

Features - Multi-user artist management. - Artist roles & permissions via custom policy. - Organization-level fallback access. - Artist profile, bio, links, assets.


4️⃣ Catalog Context

Handles the musical works, releases, and merch.

Model Description
Release Album, EP, or single.
Track Individual track metadata.
Product Digital or physical sellable item.
Tag Genre/mood metadata.

Features - Draft → Published release workflow. - Track metadata (BPM, ISRC, key, etc.). - Bundles and multi-format management. - Tag-based discovery and search indexing.


5️⃣ Commerce Context

Manages sales, carts, orders, and payments.

Model Description
Cart Active shopping cart.
Order Completed checkout.
OrderItem Line item linked to a product.
Payment Transaction record.
DiscountCode Promotional coupon.

Features - Mixed checkout (digital + physical + merch). - Stripe integration (Apple/Google Pay support). - Discounts, preorders, bundles. - Email receipts and VAT invoices.


6️⃣ Payouts Context

Handles royalty splits, payouts, and financial flows.

Model Description
SplitPlan Defines payout percentages.
SplitParticipant Beneficiaries of revenue.
Payout Individual payout record.
WithdrawalMethod Bank or Stripe/PayPal details.

Features - Split per track or release. - Automatic accrual on payment capture. - Manual and automated payout workflows. - CSV/Stripe Connect exports.


7️⃣ Media Context

Handles storage, encoding, and asset delivery.

Model Description
Asset Uploaded file (audio, image, document).
TranscodeJob Background encoding task.
DownloadToken Secure token for downloads.

Features - S3/R2 storage with Cloudflare CDN. - Queued transcodes (FLAC, MP3, preview). - Signed URL access, expiring download tokens.


8️⃣ Fulfillment Context

Manages physical order logistics.

Model Description
Shipment Shipment linked to order.
Parcel Tracking info.
Address Shipping address.
ReturnRequest Returns/exchanges.

Features - Carrier integrations (Shippo/EasyPost).
- Tracking updates, partial shipments.
- Label printing, returns queue (phase 2).


9️⃣ Community Context

Handles social and interaction features.

Model Description
Follow User follows artist or label.
Collection User playlists/wishlists.
Comment Comments on releases.
Notification System/user notifications.

Features - Follow system and notifications. - Comments and moderation tools. - Public supporter profiles (phase 2).


🔟 Governance Context

Implements co‑op management and voting.

Model Description
Member Co‑op participant (user/org).
Proposal Governance proposal.
Ballot Active voting session.
Vote Individual vote record.
Policy Platform or co‑op policy.

Features - Proposal creation and approval. - Voting, quorum, majority enforcement. - Transparency dashboards.


🔟 Other Contexts

Marketing

  • Campaigns, banners, email templates, subscribers.

Analytics

  • Event logs, sales metrics, playback statistics.

Compliance

  • KYC, tax profiles, invoices.

Integrations

  • External service accounts, webhooks, API keys.

Support

  • Ticketing and internal support communication.
  • Meilisearch/Scout index management for releases, artists, products.

⚙️ Shared Kernel

app/Shared/ contains base utilities reused across contexts:

  • Database/BaseRepository.php
  • Traits/HasUuid.php
  • Enums/Status.php
  • Events/DomainEvent.php

🚀 Development Notes

  • Each context registers a Service Provider for bindings, routes, and policies.
  • All repository interfaces live in Contracts/, implemented in Repositories/.
  • Contexts communicate via domain events (e.g., OrderPaid, PayoutQueued).
  • Tests mirror this structure under tests/Contexts/.

📚 Summary Table

Context Responsibility Key Models
Accounts Identity, access, organizations User, Organization, Membership
Creators Artists and collaborations Artist, ArtistMember
Catalog Releases, tracks, products Release, Track, Product
Commerce Checkout, payments, orders Order, Payment
Payouts Splits and royalties SplitPlan, Payout
Media Uploads and delivery Asset, TranscodeJob
Fulfillment Physical shipping Shipment, Address
Community Follows and comments Follow, Comment
Governance Co‑op policies and votes Proposal, Vote
Analytics Metrics and reports EventLog, SaleMetric
Compliance Legal and tax KycProfile, TaxProfile
Integrations Third‑party links WebhookEndpoint
Support Helpdesk Ticket
Search Indexing and search

RawDigs’ modular architecture ensures isolation, scalability, and maintainability — paving the way for future multi‑service deployments or package extraction.