# soladzpro-ai/apiuytin architecture

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

- Interactive diagram: https://gitdiagram.com/soladzpro-ai/apiuytin
- Repository: https://github.com/soladzpro-ai/apiuytin

## Overview

APIUYTIN is a Cloudflare Pages identity broker: users authenticate or add accounts, bind them to a device, choose an account and approve profile sharing; the integrating app receives a one-time code to exchange for an APIUYTIN token and retrieve user information. The dashboard also manages projects and credentials. The graph includes documented API and account capabilities, but unsampled route implementations are represented at their supported directory or route path; edges are limited to visible calls and documented relationships.

Main entry points: [`functions/_lib/auth.js`](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/_lib/auth.js) (Identity core), [`functions/_lib/oauth.js`](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/_lib/oauth.js) (OAuth transactions), [`functions/oauth/consent.js`](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/consent.js) (Account chooser), [`functions/api/auth/[[path]].js`](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/%5B%5Bpath%5D%5D.js) (Auth API routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Dashboard and account UI"]
  node_dashboard["Dashboard UI<br/>[app.js]"]
  node_authform["Login forms<br/>[auth.js]"]
  node_accountui["Account settings<br/>[account-me.js]"]
  node_overviewui["Project overview<br/>[overview.js]"]
  node_docsui["API documentation UI<br/>[docs.js]"]
end

subgraph group_identity["Identity and sessions"]
  node_googleweb["Google bootstrap<br/>[google.js]"]
  node_googlecallback["Google callback<br/>[callback.js]"]
  node_githubweb["GitHub sign-in<br/>[github.js]"]
  node_githubcallback["GitHub callback<br/>[callback.js]"]
  node_authcore["Identity core<br/>[auth.js]"]
end

subgraph group_oauth["Project OAuth"]
  node_projectstart["OAuth start<br/>[google.js]"]
  node_consent["Account chooser<br/>[consent.js]"]
  node_localaccount["Local account login<br/>[local-login.js]"]
  node_consentview["Consent rendering<br/>[consent.js]"]
  node_oauthcore["OAuth transactions<br/>[oauth.js]"]
  node_oauthcallback["OAuth callback<br/>[callback.js]"]
end

subgraph group_api["API and persistence"]
  node_authapi["Auth API routes<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_projectapi["Project routes<br/>[&#91;projectId&#93;.js]"]
  node_overviewapi["Overview route<br/>[&#91;projectId&#93;.js]"]
  node_sanity[("Sanity datastore")]
end

node_user(("Account user"))
node_client(("Integrating app"))
node_google["Google OAuth"]
node_github["GitHub OAuth"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"initializes"| node_authform
node_user -->|"starts sign-in"| node_googleweb
node_googleweb -.->|"redirects"| node_googlecallback
node_googlecallback -->|"exchanges code"| node_google
node_googlecallback -->|"creates session"| node_authcore
node_user -->|"starts sign-in"| node_githubweb
node_githubcallback -->|"exchanges code"| node_github
node_githubcallback -->|"links account"| node_authcore
node_client -->|"starts authorization"| node_projectstart
node_projectstart -.->|"creates transaction"| node_oauthcore
node_consent -->|"loads transaction"| node_oauthcore
node_consent -->|"loads accounts"| node_authcore
node_consent -->|"renders chooser"| node_consentview
node_user -->|"selects account"| node_consent
node_localaccount -->|"checks transaction"| node_oauthcore
node_localaccount -->|"links account"| node_authcore
node_oauthcore -->|"uses helpers"| node_authcore
node_oauthcallback -.->|"issues code"| node_oauthcore
node_consent -.->|"redirects with code"| node_oauthcallback
node_client -->|"exchanges code"| node_authapi
node_authapi -->|"reads and writes"| node_sanity
node_authcore -->|"reads and writes"| node_sanity
node_oauthcore -->|"stores transactions"| node_sanity
node_dashboard -.->|"manages projects"| node_authapi
node_accountui -.->|"manages account"| node_authapi
node_overviewui -.->|"loads overview"| node_overviewapi
node_projectapi -->|"uses helpers"| node_authcore
node_overviewapi -->|"uses helpers"| node_authcore

click node_dashboard "https://github.com/soladzpro-ai/apiuytin/blob/main/public/app.js"
click node_authform "https://github.com/soladzpro-ai/apiuytin/blob/main/public/auth.js"
click node_accountui "https://github.com/soladzpro-ai/apiuytin/blob/main/public/account-me.js"
click node_overviewui "https://github.com/soladzpro-ai/apiuytin/blob/main/public/overview.js"
click node_docsui "https://github.com/soladzpro-ai/apiuytin/blob/main/public/docs.js"
click node_googleweb "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/auth/google.js"
click node_googlecallback "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/auth/google/callback.js"
click node_githubweb "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/auth/github.js"
click node_githubcallback "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/github/callback.js"
click node_authcore "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/_lib/auth.js"
click node_projectstart "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/google.js"
click node_consent "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/consent.js"
click node_localaccount "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/consent/local-login.js"
click node_consentview "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/_lib/consent.js"
click node_oauthcore "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/_lib/oauth.js"
click node_oauthcallback "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/google/callback.js"
click node_authapi "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/%5B%5Bpath%5D%5D.js"
click node_projectapi "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/projects/%5BprojectId%5D.js"
click node_overviewapi "https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/overview/%5BprojectId%5D.js"

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_dashboard,node_authform,node_accountui,node_overviewui,node_docsui,node_user toneBlue
class node_googleweb,node_googlecallback,node_githubweb,node_githubcallback,node_authcore toneAmber
class node_projectstart,node_consent,node_localaccount,node_consentview,node_oauthcore,node_oauthcallback toneMint
class node_authapi,node_projectapi,node_overviewapi,node_sanity toneRose
class node_client,node_google,node_github toneIndigo
```

## Components

### Dashboard and account UI

- [Dashboard UI](https://github.com/soladzpro-ai/apiuytin/blob/main/public/app.js): `public/app.js`
- [Login forms](https://github.com/soladzpro-ai/apiuytin/blob/main/public/auth.js): `public/auth.js`
- [Account settings](https://github.com/soladzpro-ai/apiuytin/blob/main/public/account-me.js): `public/account-me.js`
- [Project overview](https://github.com/soladzpro-ai/apiuytin/blob/main/public/overview.js): `public/overview.js`
- [API documentation UI](https://github.com/soladzpro-ai/apiuytin/blob/main/public/docs.js): `public/docs.js`

### Identity and sessions

- [Google bootstrap](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/auth/google.js): `functions/auth/google.js`
- [Google callback](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/auth/google/callback.js): `functions/auth/google/callback.js`
- [GitHub sign-in](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/auth/github.js): `functions/auth/github.js`
- [GitHub callback](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/github/callback.js): `functions/api/auth/github/callback.js`
- [Identity core](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/_lib/auth.js): `functions/_lib/auth.js`

### Project OAuth

- [OAuth start](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/google.js): `functions/oauth/google.js`
- [Account chooser](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/consent.js): `functions/oauth/consent.js`
- [Local account login](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/consent/local-login.js): `functions/oauth/consent/local-login.js`
- [Consent rendering](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/_lib/consent.js): `functions/_lib/consent.js`
- [OAuth transactions](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/_lib/oauth.js): `functions/_lib/oauth.js`
- [OAuth callback](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/oauth/google/callback.js): `functions/oauth/google/callback.js`

### API and persistence

- [Auth API routes](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/%5B%5Bpath%5D%5D.js): `functions/api/auth/[[path]].js`
- [Project routes](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/projects/%5BprojectId%5D.js): `functions/api/auth/projects/[projectId].js`
- [Overview route](https://github.com/soladzpro-ai/apiuytin/blob/main/functions/api/auth/overview/%5BprojectId%5D.js): `functions/api/auth/overview/[projectId].js`
- **Sanity datastore**

### Other components

- **Account user**
- **Integrating app**
- **Google OAuth**
- **GitHub OAuth**

## Connections

- Account user → Dashboard UI: uses (evidence: `README.md`)
- Dashboard UI → Login forms: initializes (evidence: `public/app.js`)
- Account user → Google bootstrap: starts sign-in (evidence: `README.md`)
- Google bootstrap → Google callback: redirects
- Google callback → Google OAuth: exchanges code (evidence: `functions/auth/google/callback.js`)
- Google callback → Identity core: creates session (evidence: `functions/auth/google/callback.js`)
- Account user → GitHub sign-in: starts sign-in (evidence: `functions/auth/github.js`)
- GitHub callback → GitHub OAuth: exchanges code (evidence: `functions/api/auth/github/callback.js`)
- GitHub callback → Identity core: links account (evidence: `functions/api/auth/github/callback.js`)
- Integrating app → OAuth start: starts authorization (evidence: `README.md`)
- OAuth start → OAuth transactions: creates transaction (evidence: `functions/oauth/google.js`)
- Account chooser → OAuth transactions: loads transaction (evidence: `functions/oauth/consent.js`)
- Account chooser → Identity core: loads accounts (evidence: `functions/oauth/consent.js`)
- Account chooser → Consent rendering: renders chooser (evidence: `functions/oauth/consent.js`)
- Account user → Account chooser: selects account (evidence: `functions/oauth/consent.js`)
- Local account login → OAuth transactions: checks transaction (evidence: `functions/oauth/consent/local-login.js`)
- Local account login → Identity core: links account (evidence: `functions/oauth/consent/local-login.js`)
- OAuth transactions → Identity core: uses helpers (evidence: `functions/_lib/oauth.js`)
- OAuth callback → OAuth transactions: issues code (evidence: `functions/oauth/google/callback.js`)
- Account chooser → OAuth callback: redirects with code
- Integrating app → Auth API routes: exchanges code (evidence: `README.md`)
- Auth API routes → Sanity datastore: reads and writes (evidence: `functions/api/auth/[[path]].js`)
- Identity core → Sanity datastore: reads and writes (evidence: `functions/_lib/auth.js`)
- OAuth transactions → Sanity datastore: stores transactions (evidence: `functions/_lib/oauth.js`)
- Dashboard UI → Auth API routes: manages projects
- Account settings → Auth API routes: manages account
- Project overview → Overview route: loads overview
- Project routes → Identity core: uses helpers (evidence: `functions/api/auth/projects/[projectId].js`)
- Overview route → Identity core: uses helpers (evidence: `functions/api/auth/overview/[projectId].js`)
