# redspaxz/captable architecture

> Architecture diagram of the GitHub repository redspaxz/captable, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/redspaxz/captable
- Repository: https://github.com/redspaxz/captable

## Overview

STOCKBASE-X is a PHP MVC application for multi-company OHADA share-capital management. A user request enters through the web front controller and routes to a domain controller; the controller validates and scopes the operation, domain services apply share-register and ownership rules, and the application returns a view or updates persisted state. The graph preserves the documented governance, compliance, documents, portal, and tenant-management branches. Relationships are limited to those shown in excerpts, the source index, or the README; unsampled implementations are represented by their exact tree paths.

Main entry points: [`app/Core/Router.php`](https://github.com/redspaxz/captable/blob/main/app/Core/Router.php) (Route dispatch), [`app/Modules/CapTable/OwnershipService.php`](https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/OwnershipService.php) (Ownership ledger), [`app/Core/Database.php`](https://github.com/redspaxz/captable/blob/main/app/Core/Database.php) (SQL database), [`app/Modules/Shares/ShareService.php`](https://github.com/redspaxz/captable/blob/main/app/Modules/Shares/ShareService.php) (Share operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web and identity"]
  node_front["Web entry<br/>[index.php]"]
  node_routing["Route dispatch<br/>[Router.php]"]
  node_auth["Authentication<br/>[AuthController.php]"]
end

subgraph group_capital["Capital operations"]
  node_shareholders["Shareholders"]
  node_share_ops["Share operations<br/>[ShareService.php]"]
  node_share_routes["Issuance and transfer"]
  node_ownership["Ownership ledger"]
  node_captable["Cap table views"]
  node_options["Options and vesting<br/>[OptionService.php]"]
  node_convertibles["Convertible modeling"]
  node_waterfall["Liquidation waterfall"]
end

subgraph group_oversight["Governance and compliance"]
  node_voting["Voting and meetings<br/>[VotingService.php]"]
  node_compliance["Compliance checks"]
  node_compliance_ui["Compliance workflows"]
  node_documents["Corporate documents"]
end

subgraph group_workspace["Company workspace"]
  node_dashboard["Capital dashboard"]
  node_portal["Stakeholder portal"]
  node_tenants["Company management"]
  node_settings["Company settings"]
end

subgraph group_platform["Shared infrastructure"]
  node_database[("SQL database<br/>[Database.php]")]
  node_tenant_context["Tenant context<br/>[Tenancy.php]"]
  node_view["Server-rendered views<br/>[View.php]"]
end

node_user(("Company user"))

node_user -->|"sends request"| node_front
node_front -->|"dispatches"| node_routing
node_routing -->|"routes to"| node_auth
node_routing -->|"routes to"| node_share_routes
node_routing -->|"routes to"| node_captable
node_routing -->|"routes to"| node_compliance_ui
node_routing -->|"routes to"| node_documents
node_routing -->|"routes to"| node_portal
node_routing -->|"routes to"| node_tenants
node_auth -->|"reads users"| node_database
node_auth -->|"sets tenant"| node_tenant_context
node_share_routes -->|"records movements"| node_share_ops
node_share_routes -->|"checks restrictions"| node_compliance
node_share_ops -->|"updates holdings"| node_ownership
node_share_ops -->|"writes register"| node_database
node_ownership -->|"reads projection"| node_database
node_captable -->|"calculates ownership"| node_ownership
node_options -->|"issues shares"| node_share_ops
node_convertibles -->|"models dilution"| node_ownership
node_compliance_ui -->|"runs checks"| node_compliance
node_compliance -->|"uses holdings"| node_ownership
node_compliance_ui -->|"requests voting rules"| node_voting
node_documents -->|"checks holdings"| node_ownership
node_documents -->|"issues certificates"| node_share_ops
node_dashboard -->|"summarizes ownership"| node_ownership
node_portal -->|"shows holdings"| node_ownership
node_portal -->|"shows vesting"| node_options
node_tenants -->|"creates company"| node_database
node_tenants -->|"switches company"| node_tenant_context
node_captable -->|"reads cap data"| node_database
node_settings -->|"stores settings"| node_database
node_front -->|"renders responses"| node_view

click node_front "https://github.com/redspaxz/captable/blob/main/public/index.php"
click node_routing "https://github.com/redspaxz/captable/blob/main/app/Core/Router.php"
click node_auth "https://github.com/redspaxz/captable/blob/main/app/Modules/Security/AuthController.php"
click node_shareholders "https://github.com/redspaxz/captable/blob/main/app/Modules/Shareholders/ShareholderController.php"
click node_share_ops "https://github.com/redspaxz/captable/blob/main/app/Modules/Shares/ShareService.php"
click node_share_routes "https://github.com/redspaxz/captable/blob/main/app/Modules/Shares/TransferController.php"
click node_ownership "https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/OwnershipService.php"
click node_captable "https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/CapTableController.php"
click node_options "https://github.com/redspaxz/captable/blob/main/app/Modules/Options/OptionService.php"
click node_convertibles "https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/ConvertibleService.php"
click node_waterfall "https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/WaterfallController.php"
click node_voting "https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/VotingService.php"
click node_compliance "https://github.com/redspaxz/captable/blob/main/app/Modules/Compliance/ComplianceService.php"
click node_compliance_ui "https://github.com/redspaxz/captable/blob/main/app/Modules/Compliance/ComplianceController.php"
click node_documents "https://github.com/redspaxz/captable/blob/main/app/Modules/Documents/DocumentController.php"
click node_dashboard "https://github.com/redspaxz/captable/blob/main/app/Modules/Dashboard/DashboardController.php"
click node_portal "https://github.com/redspaxz/captable/blob/main/app/Modules/Portals/PortalController.php"
click node_tenants "https://github.com/redspaxz/captable/blob/main/app/Modules/Tenants/TenantController.php"
click node_settings "https://github.com/redspaxz/captable/blob/main/app/Modules/Settings/SettingsController.php"
click node_database "https://github.com/redspaxz/captable/blob/main/app/Core/Database.php"
click node_tenant_context "https://github.com/redspaxz/captable/blob/main/app/Core/Tenancy.php"
click node_view "https://github.com/redspaxz/captable/blob/main/app/Core/View.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_front,node_routing,node_auth,node_user toneBlue
class node_shareholders,node_share_ops,node_share_routes,node_ownership,node_captable,node_options,node_convertibles,node_waterfall toneAmber
class node_voting,node_compliance,node_compliance_ui,node_documents toneMint
class node_dashboard,node_portal,node_tenants,node_settings toneRose
class node_database,node_tenant_context,node_view toneIndigo
```

## Components

### Web and identity

- [Web entry](https://github.com/redspaxz/captable/blob/main/public/index.php): `public/index.php`
- [Route dispatch](https://github.com/redspaxz/captable/blob/main/app/Core/Router.php): `app/Core/Router.php`
- [Authentication](https://github.com/redspaxz/captable/blob/main/app/Modules/Security/AuthController.php): `app/Modules/Security/AuthController.php`

### Capital operations

- [Shareholders](https://github.com/redspaxz/captable/blob/main/app/Modules/Shareholders/ShareholderController.php): `app/Modules/Shareholders/ShareholderController.php`
- [Share operations](https://github.com/redspaxz/captable/blob/main/app/Modules/Shares/ShareService.php): `app/Modules/Shares/ShareService.php`
- [Issuance and transfer](https://github.com/redspaxz/captable/blob/main/app/Modules/Shares/TransferController.php): `app/Modules/Shares/TransferController.php`
- [Ownership ledger](https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/OwnershipService.php): `app/Modules/CapTable/OwnershipService.php`
- [Cap table views](https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/CapTableController.php): `app/Modules/CapTable/CapTableController.php`
- [Options and vesting](https://github.com/redspaxz/captable/blob/main/app/Modules/Options/OptionService.php): `app/Modules/Options/OptionService.php`
- [Convertible modeling](https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/ConvertibleService.php): `app/Modules/CapTable/ConvertibleService.php`
- [Liquidation waterfall](https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/WaterfallController.php): `app/Modules/CapTable/WaterfallController.php`

### Governance and compliance

- [Voting and meetings](https://github.com/redspaxz/captable/blob/main/app/Modules/CapTable/VotingService.php): `app/Modules/CapTable/VotingService.php`
- [Compliance checks](https://github.com/redspaxz/captable/blob/main/app/Modules/Compliance/ComplianceService.php): `app/Modules/Compliance/ComplianceService.php`
- [Compliance workflows](https://github.com/redspaxz/captable/blob/main/app/Modules/Compliance/ComplianceController.php): `app/Modules/Compliance/ComplianceController.php`
- [Corporate documents](https://github.com/redspaxz/captable/blob/main/app/Modules/Documents/DocumentController.php): `app/Modules/Documents/DocumentController.php`

### Company workspace

- [Capital dashboard](https://github.com/redspaxz/captable/blob/main/app/Modules/Dashboard/DashboardController.php): `app/Modules/Dashboard/DashboardController.php`
- [Stakeholder portal](https://github.com/redspaxz/captable/blob/main/app/Modules/Portals/PortalController.php): `app/Modules/Portals/PortalController.php`
- [Company management](https://github.com/redspaxz/captable/blob/main/app/Modules/Tenants/TenantController.php): `app/Modules/Tenants/TenantController.php`
- [Company settings](https://github.com/redspaxz/captable/blob/main/app/Modules/Settings/SettingsController.php): `app/Modules/Settings/SettingsController.php`

### Shared infrastructure

- [SQL database](https://github.com/redspaxz/captable/blob/main/app/Core/Database.php): `app/Core/Database.php`
- [Tenant context](https://github.com/redspaxz/captable/blob/main/app/Core/Tenancy.php): `app/Core/Tenancy.php`
- [Server-rendered views](https://github.com/redspaxz/captable/blob/main/app/Core/View.php): `app/Core/View.php`

### Other components

- **Company user**

## Connections

- Company user → Web entry: sends request
- Web entry → Route dispatch: dispatches
- Route dispatch → Authentication: routes to
- Route dispatch → Issuance and transfer: routes to
- Route dispatch → Cap table views: routes to
- Route dispatch → Compliance workflows: routes to
- Route dispatch → Corporate documents: routes to
- Route dispatch → Stakeholder portal: routes to
- Route dispatch → Company management: routes to
- Authentication → SQL database: reads users
- Authentication → Tenant context: sets tenant (evidence: `app/Modules/Security/AuthController.php`)
- Issuance and transfer → Share operations: records movements (evidence: `app/Modules/Shares/TransferController.php`)
- Issuance and transfer → Compliance checks: checks restrictions (evidence: `app/Modules/Shares/TransferController.php`)
- Share operations → Ownership ledger: updates holdings (evidence: `app/Modules/Shares/ShareService.php`)
- Share operations → SQL database: writes register (evidence: `app/Modules/Shares/ShareService.php`)
- Ownership ledger → SQL database: reads projection (evidence: `app/Modules/CapTable/OwnershipService.php`)
- Cap table views → Ownership ledger: calculates ownership (evidence: `app/Modules/CapTable/CapTableController.php`)
- Options and vesting → Share operations: issues shares (evidence: `app/Modules/Options/OptionService.php`)
- Convertible modeling → Ownership ledger: models dilution (evidence: `app/Modules/CapTable/ConvertibleController.php`)
- Compliance workflows → Compliance checks: runs checks (evidence: `app/Modules/Compliance/ComplianceController.php`)
- Compliance checks → Ownership ledger: uses holdings (evidence: `app/Modules/Compliance/ComplianceService.php`)
- Compliance workflows → Voting and meetings: requests voting rules (evidence: `app/Modules/Compliance/ComplianceController.php`)
- Corporate documents → Ownership ledger: checks holdings (evidence: `app/Modules/Documents/DocumentController.php`)
- Corporate documents → Share operations: issues certificates (evidence: `app/Modules/Documents/DocumentController.php`)
- Capital dashboard → Ownership ledger: summarizes ownership (evidence: `app/Modules/Dashboard/DashboardController.php`)
- Stakeholder portal → Ownership ledger: shows holdings (evidence: `app/Modules/Portals/PortalController.php`)
- Stakeholder portal → Options and vesting: shows vesting (evidence: `app/Modules/Portals/PortalController.php`)
- Company management → SQL database: creates company (evidence: `app/Modules/Tenants/TenantController.php`)
- Company management → Tenant context: switches company (evidence: `app/Modules/Tenants/TenantController.php`)
- Cap table views → SQL database: reads cap data (evidence: `app/Modules/CapTable/CapTableController.php`)
- Company settings → SQL database: stores settings (evidence: `app/Modules/Settings/SettingsController.php`)
- Web entry → Server-rendered views: renders responses
