# the-akanksha-foundation-pune/access-portal architecture

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

- Interactive diagram: https://gitdiagram.com/the-akanksha-foundation-pune/access-portal
- Repository: https://github.com/the-akanksha-foundation-pune/access-portal

## Overview

Access Portal is a config-driven CLI for safely changing access in applications’ own databases. The principal workflow resolves an email to all engagement records, derives target subjects, authorizes and guards the requested change, plans it, then—only when explicitly enabled—writes transactionally, verifies the result, and audits it. Separate CLI capabilities validate configuration, inspect current access, measure blast radius, and scaffold an app config. Wiring and database access are shown from excerpts; some subsystem relationships rely on README descriptions because their implementation excerpts were not provided.

Main entry points: [`src/cli.ts`](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/cli.ts) (CLI commands), [`src/engine/engine.ts`](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/engine.ts) (Operation engine), [`src/adapters/index.ts`](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/index.ts) (Adapter registry), [`src/config/load.ts`](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/load.ts) (Load config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Operator interface"]
  node_cli["CLI commands<br/>[cli.ts]"]
end

subgraph group_configuration["Configuration"]
  node_config_load["Load config<br/>[load.ts]"]
  node_config_schema["Config grammar<br/>[schema.ts]"]
  node_config_validate["Config validation<br/>[validate.ts]"]
  node_config_introspect["DB introspection<br/>[introspect.ts]"]
  node_config_scaffold["App scaffolding<br/>[scaffold.ts]"]
end

subgraph group_decision["Identity and safety"]
  node_principal["Principal resolver<br/>[resolve.ts]"]
  node_subjects["Subject resolver<br/>[subjects.ts]"]
  node_authorizer["Delegation authorizer<br/>[authorize.ts]"]
  node_guards["Production guards<br/>[guard.ts]"]
end

subgraph group_execution["Execution and persistence"]
  node_engine["Operation engine<br/>[engine.ts]"]
  node_adapter_registry["Adapter registry<br/>[index.ts]"]
  node_row_adapter["Row adapters<br/>[rowCommon.ts]"]
  node_column_adapter["Column flags<br/>[columnFlags.ts]"]
  node_json_adapter["JSON policy<br/>[jsonPolicy.ts]"]
  node_set_adapter["Set replacement<br/>[setReplace.ts]"]
  node_db_access["DB registry<br/>[db.ts]"]
  node_audit["Audit sink<br/>[audit.ts]"]
  node_identifiers["SQL identifiers<br/>[ident.ts]"]
end

node_operator(("Operator"))
node_app_databases[("App databases")]
node_audit_table[("Portal audit table")]

node_operator -->|"runs command"| node_cli
node_cli -->|"loads config"| node_config_load
node_config_load -->|"parses against"| node_config_schema
node_config_load -->|"validates"| node_config_validate
node_cli -->|"runs validation"| node_config_validate
node_cli -->|"introspects tables"| node_config_introspect
node_cli -->|"drafts app config"| node_config_scaffold
node_config_scaffold -->|"uses introspection"| node_config_introspect
node_config_validate -->|"checks live claims"| node_app_databases
node_cli -->|"resolves email"| node_principal
node_principal -->|"reads directories"| node_app_databases
node_cli -->|"executes operation"| node_engine
node_engine -->|"resolves person"| node_principal
node_engine -->|"derives subjects"| node_subjects
node_engine -->|"checks delegation"| node_authorizer
node_engine -->|"checks write guards"| node_guards
node_engine -->|"plans and applies"| node_adapter_registry
node_adapter_registry -->|"dispatches row shapes"| node_row_adapter
node_adapter_registry -->|"dispatches flags"| node_column_adapter
node_adapter_registry -->|"dispatches policies"| node_json_adapter
node_adapter_registry -->|"dispatches sets"| node_set_adapter
node_row_adapter -->|"reads and writes rows"| node_app_databases
node_column_adapter -->|"changes flags"| node_app_databases
node_json_adapter -->|"changes policy"| node_app_databases
node_set_adapter -->|"replaces set"| node_app_databases
node_db_access -->|"opens connections"| node_app_databases
node_engine -->|"records operation"| node_audit
node_audit -->|"writes audit rows"| node_audit_table
node_cli -->|"creates registry"| node_db_access
node_db_access -->|"resolves schema refs"| node_identifiers
node_engine -->|"writes and verifies"| node_app_databases

click node_cli "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/cli.ts"
click node_config_load "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/load.ts"
click node_config_schema "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/schema.ts"
click node_config_validate "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/validate.ts"
click node_config_introspect "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/introspect.ts"
click node_config_scaffold "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/scaffold.ts"
click node_principal "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/principal/resolve.ts"
click node_subjects "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/principal/subjects.ts"
click node_authorizer "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/authorize.ts"
click node_guards "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/guard.ts"
click node_engine "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/engine.ts"
click node_adapter_registry "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/index.ts"
click node_row_adapter "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/rowCommon.ts"
click node_column_adapter "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/columnFlags.ts"
click node_json_adapter "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/jsonPolicy.ts"
click node_set_adapter "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/setReplace.ts"
click node_db_access "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/db.ts"
click node_audit "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/audit.ts"
click node_identifiers "https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/ident.ts"

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_cli toneBlue
class node_config_load,node_config_schema,node_config_validate,node_config_introspect,node_config_scaffold,node_app_databases,node_audit_table toneAmber
class node_principal,node_subjects,node_authorizer,node_guards toneMint
class node_engine,node_adapter_registry,node_row_adapter,node_column_adapter,node_json_adapter,node_set_adapter,node_db_access,node_audit,node_identifiers toneRose
class node_operator toneIndigo
```

## Components

### Operator interface

- [CLI commands](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/cli.ts): `src/cli.ts`

### Configuration

- [Load config](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/load.ts): `src/config/load.ts`
- [Config grammar](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/schema.ts): `src/config/schema.ts`
- [Config validation](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/validate.ts): `src/config/validate.ts`
- [DB introspection](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/introspect.ts): `src/config/introspect.ts`
- [App scaffolding](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/config/scaffold.ts): `src/config/scaffold.ts`

### Identity and safety

- [Principal resolver](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/principal/resolve.ts): `src/principal/resolve.ts`
- [Subject resolver](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/principal/subjects.ts): `src/principal/subjects.ts`
- [Delegation authorizer](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/authorize.ts): `src/engine/authorize.ts`
- [Production guards](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/guard.ts): `src/engine/guard.ts`

### Execution and persistence

- [Operation engine](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/engine.ts): `src/engine/engine.ts`
- [Adapter registry](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/index.ts): `src/adapters/index.ts`
- [Row adapters](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/rowCommon.ts): `src/adapters/rowCommon.ts`
- [Column flags](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/columnFlags.ts): `src/adapters/columnFlags.ts`
- [JSON policy](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/jsonPolicy.ts): `src/adapters/jsonPolicy.ts`
- [Set replacement](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/adapters/setReplace.ts): `src/adapters/setReplace.ts`
- [DB registry](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/db.ts): `src/db.ts`
- [Audit sink](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/engine/audit.ts): `src/engine/audit.ts`
- [SQL identifiers](https://github.com/the-akanksha-foundation-pune/access-portal/blob/main/src/ident.ts): `src/ident.ts`

### Other components

- **Operator**
- **App databases**
- **Portal audit table**

## Connections

- Operator → CLI commands: runs command (evidence: `README.md`)
- CLI commands → Load config: loads config (evidence: `src/cli.ts`)
- Load config → Config grammar: parses against (evidence: `src/config/load.ts`)
- Load config → Config validation: validates (evidence: `src/config/load.ts`)
- CLI commands → Config validation: runs validation (evidence: `README.md`)
- CLI commands → DB introspection: introspects tables (evidence: `src/cli.ts`)
- CLI commands → App scaffolding: drafts app config (evidence: `src/cli.ts`)
- App scaffolding → DB introspection: uses introspection (evidence: `src/config/scaffold.ts`)
- Config validation → App databases: checks live claims (evidence: `src/config/validate.ts`)
- CLI commands → Principal resolver: resolves email (evidence: `src/cli.ts`)
- Principal resolver → App databases: reads directories (evidence: `src/principal/resolve.ts`)
- CLI commands → Operation engine: executes operation (evidence: `src/cli.ts`)
- Operation engine → Principal resolver: resolves person (evidence: `src/engine/engine.ts`)
- Operation engine → Subject resolver: derives subjects (evidence: `src/engine/engine.ts`)
- Operation engine → Delegation authorizer: checks delegation (evidence: `src/wire.ts`)
- Operation engine → Production guards: checks write guards (evidence: `src/engine/engine.ts`)
- Operation engine → Adapter registry: plans and applies (evidence: `src/engine/engine.ts`)
- Adapter registry → Row adapters: dispatches row shapes (evidence: `src/adapters/index.ts`)
- Adapter registry → Column flags: dispatches flags (evidence: `src/adapters/index.ts`)
- Adapter registry → JSON policy: dispatches policies (evidence: `src/adapters/index.ts`)
- Adapter registry → Set replacement: dispatches sets (evidence: `src/adapters/index.ts`)
- Row adapters → App databases: reads and writes rows (evidence: `README.md`)
- Column flags → App databases: changes flags (evidence: `README.md`)
- JSON policy → App databases: changes policy (evidence: `README.md`)
- Set replacement → App databases: replaces set (evidence: `README.md`)
- DB registry → App databases: opens connections (evidence: `src/db.ts`)
- Operation engine → Audit sink: records operation (evidence: `src/engine/engine.ts`)
- Audit sink → Portal audit table: writes audit rows (evidence: `README.md`)
- CLI commands → DB registry: creates registry (evidence: `src/cli.ts`)
- DB registry → SQL identifiers: resolves schema refs (evidence: `src/db.ts`)
- Operation engine → App databases: writes and verifies (evidence: `README.md`)
