Overview
SushiGo is built as a monorepo containing a Laravel 12 API backend and a React 19 webapp frontend. The system follows domain-driven design principles with a focus on inventory management, multi-location operations, and complete traceability.Monorepo Structure
Backend Architecture (Laravel API)
Single Action Controller Pattern
SushiGo uses Single Action Controllers (SAC) - each controller handles exactly one HTTP action via__invoke():
- Clear responsibility boundaries
- Easier to test and maintain
- No method bloat
- Self-documenting route definitions
Layered Architecture
| Layer | Responsibility | Location |
|---|---|---|
| Controllers | Receive requests, validate, delegate | app/Http/Controllers/Api/V1/ |
| FormRequests | Input validation, sanitization | app/Http/Requests/ |
| Services | Business logic orchestration | app/Services/ |
| Actions | Reusable domain operations | app/Actions/ |
| Models | Data access, relationships | app/Models/ |
| Responses | Output formatting | app/Http/Responses/ |
Domain Model
Core Entities
Branch
Physical or administrative branch of the organization. Each branch groups permanent and temporary inventories.code, name, region, timezone, is_active
OperatingUnit
Operational context within a branch - either a permanent inventory or a temporary event.BRANCH_MAIN- Primary branch inventoryBRANCH_BUFFER- Auxiliary warehouseBRANCH_RETURN- Return staging areaEVENT_TEMP- Temporary event inventory
InventoryLocation
Physical or logical zones within each operating unit (Main, Kitchen, Bar, Waste, etc.).name, type, is_primary, priority
Item & ItemVariant
Master catalog of products. AnItem represents a product (e.g., “Salmon Nigiri”), while ItemVariant represents specific versions (e.g., “6-piece tray”).
- INSUMO - Supplies and ingredients (allows multiple UOM conversions)
- PRODUCTO - Finished products (1:1 UOM)
- ACTIVO - Assets and equipment (1:1 UOM)
Stock & StockMovement
Stock records trackon_hand and reserved quantities per location/variant. Every stock change generates a StockMovement for complete traceability.
TRANSFER- Between locationsRETURN- Stock returnsSALE- Sales consumptionADJUSTMENT- Manual correctionsCONSUMPTION- Waste/usageOPENING_BALANCE- Initial stock
Employee & User
User is the authenticated identity (holds credentials and permissions). Employee is the work profile (name, code, position) linked to a User.Service Layer Organization
Services encapsulate complex business logic and orchestrate operations across multiple models.- Multi-step transactions
- Cross-domain operations
- Complex business rules
- External API integrations
- Simple CRUD operations (use controllers directly)
- Single model updates
- Basic queries
API Versioning Strategy
All API routes are versioned under/api/v1/:
https://api.sushigo.com/api/v1/{resource}
Version strategy:
- Current:
v1(Laravel 12 + Passport) - Future versions add new prefixes:
v2,v3 - Old versions maintained for backward compatibility
- Breaking changes require new version
Frontend Architecture (React Webapp)
File-Based Routing
Uses TanStack Router with file-based routing - each page exports its own route configuration:State Management
- Auth state: Zustand store (
stores/auth.store.ts) - Server state: TanStack Query
- Local UI state: React hooks
API Client
Axios instance with automatic token injection:Design Principles
| Principle | Implementation |
|---|---|
| Single Tenant Scope | All data belongs to SushiGo tenant |
| Operating Unit Abstraction | Every operation occurs within an operating unit |
| Inventory by Location | Stock segregated by physical/logical locations |
| Complete Traceability | Every movement generates audit records |
| Service-Oriented Layering | Thin controllers → Services → Models |
| Strong Typing | PHP 8.2 types + TypeScript |
| Secure IDs | Internal IDs, external exposure via Hashids |
Technology Stack
Backend:- Laravel 12 (PHP 8.2)
- PostgreSQL 16
- Laravel Passport (OAuth2)
- Spatie Permissions
- L5 Swagger (OpenAPI docs)
- React 19
- TypeScript
- TanStack Router + Query
- Zustand
- Tailwind CSS
- Vite
- Docker Compose (development)
- Nginx (reverse proxy)
- Mailhog (email testing)
- PgAdmin (database management)
Related Documentation
Operating Units
Multi-location inventory isolation
Authentication
OAuth2 password grant flow
Permissions
Role-based access control
API Reference
Complete endpoint documentation