# shahbaz957/engram architecture

> Architecture diagram of the GitHub repository shahbaz957/engram, 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/shahbaz957/engram
- Repository: https://github.com/shahbaz957/engram

## Overview

ENGRAM is a PHP second-brain and personal knowledge-management web app. Users create an account, sign in, then use a dashboard to track activity and manage a vault of books, resources, ideas, insights, quotes, and links; administrators have a separate platform overview. Page handlers combine access checks, shared database helpers, and MySQL queries. The tree and excerpts establish the dashboard, books, ideas, authentication, and admin flows; other vault pages are documented by the source index, but their internal behavior was not sampled.

Main entry points: [`includes/user_guard.php`](https://github.com/shahbaz957/engram/blob/main/includes/user_guard.php) (Vault access guard), [`includes/guard.php`](https://github.com/shahbaz957/engram/blob/main/includes/guard.php) (Login guard), [`config/database.php`](https://github.com/shahbaz957/engram/blob/main/config/database.php) (MySQL connection), [`includes/functions.php`](https://github.com/shahbaz957/engram/blob/main/includes/functions.php) (Database and vault helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and shared services"]
  node_signup["Account signup<br/>[signup.php]"]
  node_login["Login and logout<br/>[login.php]"]
  node_auth["Session and roles<br/>[auth.php]"]
  node_userguard["Vault access guard<br/>[user_guard.php]"]
  node_adminguard["Login guard<br/>[guard.php]"]
  node_helpers["Database and vault helpers<br/>[functions.php]"]
  node_connection["MySQL connection<br/>[database.php]"]
  node_store[("ENGRAM data<br/>[schema.sql]")]
end

subgraph group_vault["Personal knowledge vault"]
  node_books["Book tracking<br/>[books.php]"]
  node_ideas["Ideas and steps<br/>[ideas.php]"]
  node_resources["Resource library<br/>[resources.php]"]
  node_insights["Insights<br/>[insights.php]"]
  node_quotes["Quotes and motivation<br/>[motivation.php]"]
  node_links["Knowledge links<br/>[links.php]"]
  node_delete["Vault deletion<br/>[delete.php]"]
end

subgraph group_overview["Dashboards and administration"]
  node_dashboard["Personal dashboard<br/>[index.php]"]
  node_admin["Admin overview<br/>[index.php]"]
  node_profile["Profile<br/>[profile.php]"]
end

subgraph group_presentation["Shared presentation"]
  node_header["Navigation and layout<br/>[header.php]"]
  node_footer["Page footer<br/>[footer.php]"]
end

node_visitor(("Visitor"))

node_visitor -->|"registers"| node_signup
node_visitor -->|"signs in"| node_login
node_signup -->|"starts session"| node_auth
node_signup -->|"creates account"| node_connection
node_login -->|"checks session"| node_auth
node_login -->|"queries account"| node_connection
node_userguard -->|"checks role"| node_auth
node_userguard -->|"opens connection"| node_connection
node_userguard -->|"loads helpers"| node_helpers
node_adminguard -->|"checks login"| node_auth
node_adminguard -->|"opens connection"| node_connection
node_adminguard -->|"loads helpers"| node_helpers
node_connection -.->|"connects to"| node_store
node_books -->|"requires access"| node_userguard
node_books -->|"uses helpers"| node_helpers
node_ideas -->|"requires access"| node_userguard
node_ideas -->|"uses helpers"| node_helpers
node_dashboard -->|"requires access"| node_userguard
node_dashboard -->|"loads linked items"| node_helpers
node_admin -->|"requires access"| node_adminguard
node_resources -->|"requires access"| node_userguard
node_insights -->|"requires access"| node_userguard
node_quotes -->|"requires access"| node_userguard
node_links -->|"requires access"| node_userguard
node_profile -->|"requires login"| node_adminguard
node_delete -->|"requires access"| node_userguard
node_books -->|"renders with"| node_header
node_ideas -->|"renders with"| node_header
node_dashboard -->|"renders with"| node_header
node_admin -->|"renders with"| node_header
node_books -->|"renders with"| node_footer
node_ideas -->|"renders with"| node_footer
node_dashboard -->|"renders with"| node_footer
node_admin -->|"renders with"| node_footer

click node_signup "https://github.com/shahbaz957/engram/blob/main/public/signup.php"
click node_login "https://github.com/shahbaz957/engram/blob/main/public/login.php"
click node_auth "https://github.com/shahbaz957/engram/blob/main/includes/auth.php"
click node_userguard "https://github.com/shahbaz957/engram/blob/main/includes/user_guard.php"
click node_adminguard "https://github.com/shahbaz957/engram/blob/main/includes/guard.php"
click node_helpers "https://github.com/shahbaz957/engram/blob/main/includes/functions.php"
click node_connection "https://github.com/shahbaz957/engram/blob/main/config/database.php"
click node_store "https://github.com/shahbaz957/engram/blob/main/sql/schema.sql"
click node_books "https://github.com/shahbaz957/engram/blob/main/public/books.php"
click node_ideas "https://github.com/shahbaz957/engram/blob/main/public/ideas.php"
click node_resources "https://github.com/shahbaz957/engram/blob/main/public/resources.php"
click node_insights "https://github.com/shahbaz957/engram/blob/main/public/insights.php"
click node_quotes "https://github.com/shahbaz957/engram/blob/main/public/motivation.php"
click node_links "https://github.com/shahbaz957/engram/blob/main/public/links.php"
click node_dashboard "https://github.com/shahbaz957/engram/blob/main/public/index.php"
click node_admin "https://github.com/shahbaz957/engram/blob/main/public/admin/index.php"
click node_profile "https://github.com/shahbaz957/engram/blob/main/public/profile.php"
click node_delete "https://github.com/shahbaz957/engram/blob/main/public/delete.php"
click node_header "https://github.com/shahbaz957/engram/blob/main/includes/header.php"
click node_footer "https://github.com/shahbaz957/engram/blob/main/includes/footer.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_signup,node_login,node_auth,node_userguard,node_adminguard,node_helpers,node_connection,node_store toneBlue
class node_books,node_ideas,node_resources,node_insights,node_quotes,node_links,node_delete toneAmber
class node_dashboard,node_admin,node_profile toneMint
class node_header,node_footer toneRose
class node_visitor toneIndigo
```

## Components

### Access and shared services

- [Account signup](https://github.com/shahbaz957/engram/blob/main/public/signup.php): `public/signup.php`
- [Login and logout](https://github.com/shahbaz957/engram/blob/main/public/login.php): `public/login.php`
- [Session and roles](https://github.com/shahbaz957/engram/blob/main/includes/auth.php): `includes/auth.php`
- [Vault access guard](https://github.com/shahbaz957/engram/blob/main/includes/user_guard.php): `includes/user_guard.php`
- [Login guard](https://github.com/shahbaz957/engram/blob/main/includes/guard.php): `includes/guard.php`
- [Database and vault helpers](https://github.com/shahbaz957/engram/blob/main/includes/functions.php): `includes/functions.php`
- [MySQL connection](https://github.com/shahbaz957/engram/blob/main/config/database.php): `config/database.php`
- [ENGRAM data](https://github.com/shahbaz957/engram/blob/main/sql/schema.sql): `sql/schema.sql`

### Personal knowledge vault

- [Book tracking](https://github.com/shahbaz957/engram/blob/main/public/books.php): `public/books.php`
- [Ideas and steps](https://github.com/shahbaz957/engram/blob/main/public/ideas.php): `public/ideas.php`
- [Resource library](https://github.com/shahbaz957/engram/blob/main/public/resources.php): `public/resources.php`
- [Insights](https://github.com/shahbaz957/engram/blob/main/public/insights.php): `public/insights.php`
- [Quotes and motivation](https://github.com/shahbaz957/engram/blob/main/public/motivation.php): `public/motivation.php`
- [Knowledge links](https://github.com/shahbaz957/engram/blob/main/public/links.php): `public/links.php`
- [Vault deletion](https://github.com/shahbaz957/engram/blob/main/public/delete.php): `public/delete.php`

### Dashboards and administration

- [Personal dashboard](https://github.com/shahbaz957/engram/blob/main/public/index.php): `public/index.php`
- [Admin overview](https://github.com/shahbaz957/engram/blob/main/public/admin/index.php): `public/admin/index.php`
- [Profile](https://github.com/shahbaz957/engram/blob/main/public/profile.php): `public/profile.php`

### Shared presentation

- [Navigation and layout](https://github.com/shahbaz957/engram/blob/main/includes/header.php): `includes/header.php`
- [Page footer](https://github.com/shahbaz957/engram/blob/main/includes/footer.php): `includes/footer.php`

### Other components

- **Visitor**

## Connections

- Visitor → Account signup: registers (evidence: `public/signup.php`)
- Visitor → Login and logout: signs in (evidence: `public/login.php`)
- Account signup → Session and roles: starts session (evidence: `public/signup.php`)
- Account signup → MySQL connection: creates account (evidence: `public/signup.php`)
- Login and logout → Session and roles: checks session (evidence: `public/login.php`)
- Login and logout → MySQL connection: queries account (evidence: `public/login.php`)
- Vault access guard → Session and roles: checks role (evidence: `includes/user_guard.php`)
- Vault access guard → MySQL connection: opens connection (evidence: `includes/user_guard.php`)
- Vault access guard → Database and vault helpers: loads helpers (evidence: `includes/user_guard.php`)
- Login guard → Session and roles: checks login (evidence: `includes/guard.php`)
- Login guard → MySQL connection: opens connection (evidence: `includes/guard.php`)
- Login guard → Database and vault helpers: loads helpers (evidence: `includes/guard.php`)
- MySQL connection → ENGRAM data: connects to
- Book tracking → Vault access guard: requires access (evidence: `public/books.php`)
- Book tracking → Database and vault helpers: uses helpers (evidence: `public/books.php`)
- Ideas and steps → Vault access guard: requires access (evidence: `public/ideas.php`)
- Ideas and steps → Database and vault helpers: uses helpers (evidence: `public/ideas.php`)
- Personal dashboard → Vault access guard: requires access (evidence: `public/index.php`)
- Personal dashboard → Database and vault helpers: loads linked items (evidence: `public/index.php`)
- Admin overview → Login guard: requires access (evidence: `public/admin/index.php`)
- Resource library → Vault access guard: requires access (evidence: `public/resources.php`)
- Insights → Vault access guard: requires access (evidence: `public/insights.php`)
- Quotes and motivation → Vault access guard: requires access (evidence: `public/motivation.php`)
- Knowledge links → Vault access guard: requires access (evidence: `public/links.php`)
- Profile → Login guard: requires login (evidence: `public/profile.php`)
- Vault deletion → Vault access guard: requires access (evidence: `public/delete.php`)
- Book tracking → Navigation and layout: renders with (evidence: `public/books.php`)
- Ideas and steps → Navigation and layout: renders with (evidence: `public/ideas.php`)
- Personal dashboard → Navigation and layout: renders with (evidence: `public/index.php`)
- Admin overview → Navigation and layout: renders with (evidence: `public/admin/index.php`)
- Book tracking → Page footer: renders with (evidence: `public/books.php`)
- Ideas and steps → Page footer: renders with (evidence: `public/ideas.php`)
- Personal dashboard → Page footer: renders with (evidence: `public/index.php`)
- Admin overview → Page footer: renders with (evidence: `public/admin/index.php`)
