# manicharan0485/oauth-integration architecture

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

- Interactive diagram: https://gitdiagram.com/manicharan0485/oauth-integration
- Repository: https://github.com/manicharan0485/oauth-integration

## Overview

This is a small Express demo for Microsoft Entra ID and GitHub sign-in, profile retrieval, token refresh, and webhook handling. The main workflow starts in the browser, creates session-bound state and a PKCE challenge, redirects to a provider, validates the callback, exchanges the code, fetches a profile, and stores tokens and profile in memory. Separate branches handle refresh, profile/event display, and GitHub and Graph webhooks. The map follows the shown routes and calls; provider endpoints and webhook semantics are also documented in the README.

Main entry points: [`src/server.js`](https://github.com/manicharan0485/oauth-integration/blob/main/src/server.js) (HTTP routes), [`src/oauth.js`](https://github.com/manicharan0485/oauth-integration/blob/main/src/oauth.js) (OAuth and PKCE), [`src/providers.js`](https://github.com/manicharan0485/oauth-integration/blob/main/src/providers.js) (Provider definitions), [`src/webhooks.js`](https://github.com/manicharan0485/oauth-integration/blob/main/src/webhooks.js) (Graph notification check)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["OAuth flow"]
  node_oauth["OAuth and PKCE<br/>[oauth.js]"]
  node_providers["Provider definitions<br/>[providers.js]"]
end

subgraph group_app["App and sessions"]
  node_server["HTTP routes<br/>[server.js]"]
  node_session[("Session state<br/>[server.js]")]
  node_ui["Profile and events views<br/>[server.js]"]
end

subgraph group_hooks["Webhooks"]
  node_github_hook["GitHub signature check<br/>[webhooks.js]"]
  node_graph_hook["Graph notification check<br/>[webhooks.js]"]
  node_event_log[("In-memory events<br/>[server.js]")]
end

node_browser(("Browser"))
node_identity{{"Entra ID and GitHub"}}
node_profile_apis{{"Graph and GitHub profile APIs"}}
node_github_sender(("GitHub webhook sender"))
node_graph_sender(("Microsoft Graph"))

node_browser -->|"starts sign-in"| node_server
node_server -->|"binds state"| node_session
node_server -->|"builds redirect"| node_oauth
node_oauth -->|"reads endpoints"| node_providers
node_browser -->|"follows redirect"| node_identity
node_identity -->|"returns callback"| node_server
node_server -->|"checks state"| node_session
node_server -->|"exchanges code"| node_oauth
node_oauth -->|"posts token request"| node_identity
node_server -->|"fetches profile"| node_providers
node_providers -->|"requests profile"| node_profile_apis
node_server -->|"stores tokens and profile"| node_session
node_browser -->|"requests refresh"| node_server
node_server -->|"refreshes token"| node_oauth
node_server -->|"serves views"| node_ui
node_ui -->|"reads profile"| node_session
node_github_sender -->|"posts webhook"| node_server
node_server -->|"verifies signature"| node_github_hook
node_server -->|"records event"| node_event_log
node_graph_sender -->|"posts notification"| node_server
node_server -->|"checks notification"| node_graph_hook
node_graph_hook -->|"returns valid events"| node_event_log
node_ui -->|"reads events"| node_event_log

click node_server "https://github.com/manicharan0485/oauth-integration/blob/main/src/server.js"
click node_session "https://github.com/manicharan0485/oauth-integration/blob/main/src/server.js"
click node_ui "https://github.com/manicharan0485/oauth-integration/blob/main/src/server.js"
click node_oauth "https://github.com/manicharan0485/oauth-integration/blob/main/src/oauth.js"
click node_providers "https://github.com/manicharan0485/oauth-integration/blob/main/src/providers.js"
click node_github_hook "https://github.com/manicharan0485/oauth-integration/blob/main/src/webhooks.js"
click node_graph_hook "https://github.com/manicharan0485/oauth-integration/blob/main/src/webhooks.js"
click node_event_log "https://github.com/manicharan0485/oauth-integration/blob/main/src/server.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_oauth,node_providers,node_browser toneBlue
class node_server,node_session,node_ui toneAmber
class node_github_hook,node_graph_hook,node_event_log,node_profile_apis,node_github_sender toneMint
class node_identity,node_graph_sender toneIndigo
```

## Components

### OAuth flow

- [OAuth and PKCE](https://github.com/manicharan0485/oauth-integration/blob/main/src/oauth.js): `src/oauth.js`
- [Provider definitions](https://github.com/manicharan0485/oauth-integration/blob/main/src/providers.js): `src/providers.js`

### App and sessions

- [HTTP routes](https://github.com/manicharan0485/oauth-integration/blob/main/src/server.js): `src/server.js`
- [Session state](https://github.com/manicharan0485/oauth-integration/blob/main/src/server.js): `src/server.js`
- [Profile and events views](https://github.com/manicharan0485/oauth-integration/blob/main/src/server.js): `src/server.js`

### Webhooks

- [GitHub signature check](https://github.com/manicharan0485/oauth-integration/blob/main/src/webhooks.js): `src/webhooks.js`
- [Graph notification check](https://github.com/manicharan0485/oauth-integration/blob/main/src/webhooks.js): `src/webhooks.js`
- [In-memory events](https://github.com/manicharan0485/oauth-integration/blob/main/src/server.js): `src/server.js`

### Other components

- **Browser**
- **Entra ID and GitHub**
- **Graph and GitHub profile APIs**
- **GitHub webhook sender**
- **Microsoft Graph**

## Connections

- Browser → HTTP routes: starts sign-in (evidence: `README.md`)
- HTTP routes → Session state: binds state (evidence: `src/server.js`)
- HTTP routes → OAuth and PKCE: builds redirect (evidence: `src/server.js`)
- OAuth and PKCE → Provider definitions: reads endpoints (evidence: `src/oauth.js`)
- Browser → Entra ID and GitHub: follows redirect (evidence: `README.md`)
- Entra ID and GitHub → HTTP routes: returns callback (evidence: `README.md`)
- HTTP routes → Session state: checks state (evidence: `src/server.js`)
- HTTP routes → OAuth and PKCE: exchanges code (evidence: `src/server.js`)
- OAuth and PKCE → Entra ID and GitHub: posts token request (evidence: `src/oauth.js`)
- HTTP routes → Provider definitions: fetches profile (evidence: `src/server.js`)
- Provider definitions → Graph and GitHub profile APIs: requests profile (evidence: `src/providers.js`)
- HTTP routes → Session state: stores tokens and profile (evidence: `src/server.js`)
- Browser → HTTP routes: requests refresh (evidence: `src/server.js`)
- HTTP routes → OAuth and PKCE: refreshes token (evidence: `src/server.js`)
- HTTP routes → Profile and events views: serves views (evidence: `src/server.js`)
- Profile and events views → Session state: reads profile (evidence: `src/server.js`)
- GitHub webhook sender → HTTP routes: posts webhook (evidence: `README.md`)
- HTTP routes → GitHub signature check: verifies signature (evidence: `src/server.js`)
- HTTP routes → In-memory events: records event (evidence: `src/server.js`)
- Microsoft Graph → HTTP routes: posts notification (evidence: `README.md`)
- HTTP routes → Graph notification check: checks notification (evidence: `src/server.js`)
- Graph notification check → In-memory events: returns valid events (evidence: `src/server.js`)
- Profile and events views → In-memory events: reads events (evidence: `src/server.js`)
