# jendryh30/arganotakehome-jh architecture

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

- Interactive diagram: https://gitdiagram.com/jendryh30/arganotakehome-jh
- Repository: https://github.com/jendryh30/arganotakehome-jh

## Overview

#### Purpose and Runtime
Argano Dispatch is a small internal PHP document-sharing system. Staff create and manage documents, generate recipient share links, and recipients retrieve documents through those links. It runs as a Docker Compose service using PHP and SQLite; startup reseeds the database for a deterministic local environment. Core runtime definitions: `Dockerfile`, `docker-compose.yml`, `public/index.php`.

#### HTTP Entry Points and UI
The application is server-rendered PHP, with each public script acting as a request handler/page rather than a routed framework controller. Staff-facing flows include login, administration, document editing, and access requests; recipient-facing flows resolve and display shared documents.
- `public/login.php`
- `public/admin.php`
- `public/edit.php`
- `public/share.php`
- `public/view.php`
- `public/request-access.php`

Shared HTML framing and styling are centralized separately from request logic in `lib/layout.php` and `public/assets/style.css`.

#### Application Bootstrap and Cross-Cutting Policy
`lib/bootstrap.php` is the central application boundary for database initialization/access, authentication/session behavior, and reusable domain helpers. It also establishes the audit-log pattern required for document creation, scheduling changes, and share activity. Request handlers should rely on this layer instead of directly duplicating connection, authorization, or audit behavior.
- `lib/bootstrap.php`
- `lib/layout.php`

#### Document Authoring and Administration
Staff administration is the primary control plane: it lists or manages documents and exposes document creation/editing actions. `public/edit.php` owns document authoring/update interactions, while `public/admin.php` is the operational discovery/management surface. The repository includes an `edit.php.bak`, which is not a production entry point and should not be treated as authoritative.
- `public/admin.php`
- `public/edit.php`

Document identity, uniqueness, availability scheduling, and access rules are persisted in SQLite. The later migrations indicate the intended feature evolution: unique titles, `available_at` scheduling, and voice/readable codes for shares.
- `migrations/20260710_unique_document_titles.sql`
- `migrations/20260709_add_available_at_to_documents.sql`
- `migrations/20260706_add_voice_code_to_shares.sql`

#### Sharing and Recipient Access Boundary
Sharing is a distinct capability boundary: staff generate or manage recipient access through `public/share.php`; recipients consume a link through `public/view.php`. The initial schema/migrations establish document-level ACL and single-use-share concerns, while the voice-code migration suggests a human-friendly alternate identifier layered onto existing share access rather than necessarily replacing opaque tokens.
- `public/share.php`
- `public/view.php`
- `migrations/0002_document_access_control.sql`
- `migrations/20260706_add_voice_code_to_shares.sql`

The recipient view must enforce both authorization/link validity and document availability. Scheduling is therefore not merely an admin-field concern: it gates content disclosure at the public/recipient-facing boundary.

#### Persistence and Migration Lifecycle
SQLite is the sole datastore. `schema.sql` defines the base schema used when reseeding, while ordered SQL files in `migrations/` record schema evolution. `lib/migrate.php` is the migration execution boundary and should track/apply migrations consistently during bootstrap or container initialization. Seed data supplies the fresh local dataset.
- `schema.sql`
- `lib/migrate.php`
- `seed.php`
- `migrations/0001_accounts_and_roles.sql`
- `migrations/0003_document_scheduling.sql`

#### Authentication, Roles, and Auditability
Staff operations are authenticated through the login/logout handlers and account/role schema. Recipient access is link-based and intentionally separate from staff session authentication. Audit records form an operational accountability stream for sensitive mutations and sharing actions.
- `public/login.php`
- `public/logout.php`
- `migrations/0001_accounts_and_roles.sql`
- `lib/bootstrap.php`

#### Verification and Delivery
The project’s executable verification is a custom PHP test runner, executed inside the same Compose container/runtime as the app. CI is defined through GitHub Actions and should validate the Docker/PHP-compatible workflow.
- `tests/test.php`
- `.github/workflows/ci.yml`
- `docker-compose.yml`

Main entry points: [`lib/bootstrap.php`](https://github.com/jendryh30/arganotakehome-jh/blob/master/lib/bootstrap.php) (Application bootstrap), [`docker-compose.yml`](https://github.com/jendryh30/arganotakehome-jh/blob/master/docker-compose.yml) (Compose service), [`lib/migrate.php`](https://github.com/jendryh30/arganotakehome-jh/blob/master/lib/migrate.php) (Migration runner), [`public/admin.php`](https://github.com/jendryh30/arganotakehome-jh/blob/master/public/admin.php) (Staff control plane)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_compose{{"Compose service<br/>container runtime<br/>[docker-compose.yml]"}}
  node_dockerfile["PHP image<br/>container build"]
end

subgraph group_app["PHP Application"]
  node_index["Web entry<br/>PHP entry point<br/>[index.php]"]
  node_staff_handlers["Staff control plane<br/>PHP pages<br/>[admin.php]"]
  node_edit["Document authoring<br/>PHP page<br/>[edit.php]"]
  node_auth["Staff authentication<br/>PHP pages<br/>[login.php]"]
  node_share["Share management<br/>PHP page<br/>[share.php]"]
  node_recipient_view["Recipient access<br/>PHP page<br/>[view.php]"]
  node_bootstrap["Application bootstrap<br/>PHP boundary<br/>[bootstrap.php]"]
  node_layout["Shared presentation<br/>PHP layout<br/>[layout.php]"]
end

subgraph group_data["Persistence"]
  node_sqlite[("SQLite datastore<br/>SQLite database")]
  node_base_schema["Base schema<br/>SQL schema<br/>[schema.sql]"]
  node_migrator["Migration runner<br/>PHP migration boundary<br/>[migrate.php]"]
  node_migrations["Schema evolution<br/>SQL migrations"]
  node_seed["Seed dataset<br/>PHP seed script<br/>[seed.php]"]
end

subgraph group_delivery["Verification"]
  node_tests["PHP test runner<br/>executable verification<br/>[test.php]"]
  node_ci["GitHub Actions CI<br/>CI workflow<br/>[ci.yml]"]
end

node_compose -->|"builds"| node_dockerfile
node_compose -->|"serves"| node_index
node_compose -->|"initializes with"| node_migrator
node_compose -->|"reseeds with"| node_seed
node_index -->|"loads"| node_bootstrap
node_staff_handlers -->|"uses policy"| node_bootstrap
node_edit -->|"uses policy"| node_bootstrap
node_auth -->|"establishes sessions"| node_bootstrap
node_share -->|"records share activity"| node_bootstrap
node_recipient_view -->|"validates access"| node_bootstrap
node_staff_handlers -->|"manages documents"| node_edit
node_staff_handlers -->|"renders with"| node_layout
node_recipient_view -->|"renders with"| node_layout
node_bootstrap -->|"reads and writes"| node_sqlite
node_migrator -->|"starts from"| node_base_schema
node_migrator -->|"applies"| node_migrations
node_migrator -->|"updates"| node_sqlite
node_seed -->|"populates"| node_sqlite
node_ci -->|"uses runtime"| node_compose
node_ci -->|"runs"| node_tests
node_tests -->|"executes in"| node_compose

click node_compose "https://github.com/jendryh30/arganotakehome-jh/blob/master/docker-compose.yml"
click node_dockerfile "https://github.com/jendryh30/arganotakehome-jh/blob/master/Dockerfile"
click node_index "https://github.com/jendryh30/arganotakehome-jh/blob/master/public/index.php"
click node_staff_handlers "https://github.com/jendryh30/arganotakehome-jh/blob/master/public/admin.php"
click node_edit "https://github.com/jendryh30/arganotakehome-jh/blob/master/public/edit.php"
click node_auth "https://github.com/jendryh30/arganotakehome-jh/blob/master/public/login.php"
click node_share "https://github.com/jendryh30/arganotakehome-jh/blob/master/public/share.php"
click node_recipient_view "https://github.com/jendryh30/arganotakehome-jh/blob/master/public/view.php"
click node_bootstrap "https://github.com/jendryh30/arganotakehome-jh/blob/master/lib/bootstrap.php"
click node_layout "https://github.com/jendryh30/arganotakehome-jh/blob/master/lib/layout.php"
click node_base_schema "https://github.com/jendryh30/arganotakehome-jh/blob/master/schema.sql"
click node_migrator "https://github.com/jendryh30/arganotakehome-jh/blob/master/lib/migrate.php"
click node_migrations "https://github.com/jendryh30/arganotakehome-jh/blob/master/migrations/0001_accounts_and_roles.sql"
click node_seed "https://github.com/jendryh30/arganotakehome-jh/blob/master/seed.php"
click node_tests "https://github.com/jendryh30/arganotakehome-jh/blob/master/tests/test.php"
click node_ci "https://github.com/jendryh30/arganotakehome-jh/blob/master/.github/workflows/ci.yml"

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_compose,node_dockerfile toneBlue
class node_index,node_staff_handlers,node_edit,node_auth,node_share,node_recipient_view,node_bootstrap,node_layout toneAmber
class node_sqlite,node_base_schema,node_migrator,node_migrations,node_seed toneMint
class node_tests,node_ci toneRose
```

## Components

### Runtime

- [Compose service](https://github.com/jendryh30/arganotakehome-jh/blob/master/docker-compose.yml): container runtime · Runs PHP with SQLite and reseeds the local database. · `docker-compose.yml`
- [PHP image](https://github.com/jendryh30/arganotakehome-jh/blob/master/Dockerfile): container build · `Dockerfile`

### PHP Application

- [Web entry](https://github.com/jendryh30/arganotakehome-jh/blob/master/public/index.php): PHP entry point · `public/index.php`
- [Staff control plane](https://github.com/jendryh30/arganotakehome-jh/blob/master/public/admin.php): PHP pages · Login, administration, authoring, and access-request flows. · `public/admin.php`
- [Document authoring](https://github.com/jendryh30/arganotakehome-jh/blob/master/public/edit.php): PHP page · Creates and updates documents. · `public/edit.php`
- [Staff authentication](https://github.com/jendryh30/arganotakehome-jh/blob/master/public/login.php): PHP pages · Session login and logout are separate from recipient access. · `public/login.php`
- [Share management](https://github.com/jendryh30/arganotakehome-jh/blob/master/public/share.php): PHP page · Staff creates or manages recipient share links. · `public/share.php`
- [Recipient access](https://github.com/jendryh30/arganotakehome-jh/blob/master/public/view.php): PHP page · Validates a share and enforces document availability before disclosure. · `public/view.php`
- [Application bootstrap](https://github.com/jendryh30/arganotakehome-jh/blob/master/lib/bootstrap.php): PHP boundary · Centralizes database access, sessions, authorization, domain helpers, and audit logging. · `lib/bootstrap.php`
- [Shared presentation](https://github.com/jendryh30/arganotakehome-jh/blob/master/lib/layout.php): PHP layout · Provides common HTML framing and styling. · `lib/layout.php`

### Persistence

- **SQLite datastore**: SQLite database · Stores accounts, documents, access rules, shares, and audit records.
- [Base schema](https://github.com/jendryh30/arganotakehome-jh/blob/master/schema.sql): SQL schema · Defines the fresh reseeded database. · `schema.sql`
- [Migration runner](https://github.com/jendryh30/arganotakehome-jh/blob/master/lib/migrate.php): PHP migration boundary · Tracks and applies ordered schema evolution. · `lib/migrate.php`
- [Schema evolution](https://github.com/jendryh30/arganotakehome-jh/blob/master/migrations/0001_accounts_and_roles.sql): SQL migrations · Adds roles, ACLs, scheduling, unique titles, and share voice codes. · `migrations/0001_accounts_and_roles.sql`
- [Seed dataset](https://github.com/jendryh30/arganotakehome-jh/blob/master/seed.php): PHP seed script · Supplies deterministic local data. · `seed.php`

### Verification

- [PHP test runner](https://github.com/jendryh30/arganotakehome-jh/blob/master/tests/test.php): executable verification · Runs inside the Compose PHP runtime. · `tests/test.php`
- [GitHub Actions CI](https://github.com/jendryh30/arganotakehome-jh/blob/master/.github/workflows/ci.yml): CI workflow · `.github/workflows/ci.yml`

## Connections

- Compose service → PHP image: builds
- Compose service → Web entry: serves
- Compose service → Migration runner: initializes with
- Compose service → Seed dataset: reseeds with
- Web entry → Application bootstrap: loads
- Staff control plane → Application bootstrap: uses policy
- Document authoring → Application bootstrap: uses policy
- Staff authentication → Application bootstrap: establishes sessions
- Share management → Application bootstrap: records share activity
- Recipient access → Application bootstrap: validates access
- Staff control plane → Document authoring: manages documents
- Staff control plane → Shared presentation: renders with
- Recipient access → Shared presentation: renders with
- Application bootstrap → SQLite datastore: reads and writes
- Migration runner → Base schema: starts from
- Migration runner → Schema evolution: applies
- Migration runner → SQLite datastore: updates
- Seed dataset → SQLite datastore: populates
- GitHub Actions CI → Compose service: uses runtime
- GitHub Actions CI → PHP test runner: runs
- PHP test runner → Compose service: executes in
