# TANRAIL ONE — Architecture Decision Record (ADR)

This document tracks all significant architectural decisions made during the lifecycle of TANRAIL ONE.

---

## ADR-001
**Title:** Shared Core with Business Unit Extensions
**Status:** Approved
**Date:** 2026-09-03
**Decision:** The platform will use a single codebase (Modular Monolith) handling multiple business units rather than building separate microservices or isolated applications per business.
**Context:** TANRAIL runs multiple distinct businesses (Restaurant, Catering, Water). Building separate apps creates data silos and complicates consolidated executive reporting.
**Reason:** A shared core allows rapid deployment of new businesses by reusing existing Inventory, Sales, and Finance modules.
**Consequences:** Developers must strictly adhere to data scoping rules (Global Scopes) to prevent data leakage between business units.

---

## ADR-002
**Title:** Centralized Authentication & Context Switching
**Status:** Approved
**Date:** 2026-09-03
**Decision:** Users will log in once globally, and then "Switch Context" to a specific Business Unit they are authorized for.
**Context:** Many managers or executives oversee multiple BUs. Requiring different logins for the Restaurant vs Catering is poor UX.
**Reason:** Seamless navigation and unified user management.
**Consequences:** Authorization logic becomes more complex (Tripartite Matrix: User + Permission + BU Context).

---

## ADR-003
**Title:** Documentation-First Development for AI Agents
**Status:** Approved
**Date:** 2026-09-03
**Decision:** All core architectural rules and capability maps must be documented in `/docs` before feature development begins.
**Context:** The project will utilize AI coding agents. AI agents lack implicit business context and can quickly diverge from architectural intent if left unguided.
**Reason:** The `/docs` directory serves as the explicit, static "brain" and boundary-setter for AI agents (and human developers).
**Consequences:** Any architectural shift must be updated in the documentation first; code follows docs.

---

## ADR-004
**Title:** (TBD) Frontend Framework Selection
**Status:** Unresolved
**Date:** 2026-09-03
**Decision:** TBD
**Context:** Need to select between Livewire, Inertia+Vue, or a pure API+React approach.
**Impact:** Dictates the entire UI development workflow and ability to easily spin off mobile apps.
**Recommended:** If heavy mobile app development is expected later, pure API + React is best. If rapid web development is prioritized, Inertia.js is recommended.
