# mahaveer-rulaniya/authorization-and-security architecture

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

- Interactive diagram: https://gitdiagram.com/mahaveer-rulaniya/authorization-and-security
- Repository: https://github.com/mahaveer-rulaniya/authorization-and-security

## Overview

This is an Express/EJS secrets-sharing application. Users register or sign in locally or with Google, then authenticated users can submit a secret; visitors can view secrets shared by users. Passport manages authentication and sessions, while Mongoose stores user accounts and secrets in MongoDB. The graph follows the routes and database operations visible in app.js; the README describes additional encryption examples, but the active schema shown here does not enable the encryption plugin.

Main entry points: [`app.js`](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js) (Express routes), [`views/login.ejs`](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/login.ejs) (Login page), [`views/secrets.ejs`](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/secrets.ejs) (Secrets page), [`views/home.ejs`](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/home.ejs) (Home page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_app["Express routes<br/>[app.js]"]
  node_home["Home page<br/>[home.ejs]"]
  node_login["Login page<br/>[login.ejs]"]
  node_register["Registration page<br/>[register.ejs]"]
  node_submit_view["Submit page<br/>[submit.ejs]"]
  node_secrets_view["Secrets page<br/>[secrets.ejs]"]
end

subgraph group_auth["Authentication"]
  node_passport["Passport auth<br/>[app.js]"]
  node_session["Session middleware<br/>[app.js]"]
  node_google["Google OAuth<br/>[app.js]"]
end

subgraph group_data["User data"]
  node_user_model["User model<br/>[app.js]"]
  node_mongodb[("MongoDB")]
end

subgraph group_secrets["Secrets workflow"]
  node_secret_submit["Secret submission<br/>[app.js]"]
  node_secret_listing["Secret listing<br/>[app.js]"]
end

node_visitor(("Visitor"))

node_visitor -->|"sends requests"| node_app
node_app -->|"renders"| node_home
node_app -->|"renders"| node_login
node_app -->|"renders"| node_register
node_app -->|"renders"| node_submit_view
node_app -->|"renders"| node_secrets_view
node_app -->|"configures"| node_session
node_app -->|"configures"| node_passport
node_app -->|"defines"| node_user_model
node_app -->|"configures"| node_google
node_google -.->|"redirects to"| node_visitor
node_google -->|"finds or creates"| node_user_model
node_app -->|"authenticates locally"| node_passport
node_passport -->|"uses strategy"| node_user_model
node_app -->|"registers users"| node_user_model
node_app -->|"handles submission"| node_secret_submit
node_secret_submit -->|"loads and saves"| node_user_model
node_app -->|"handles listing"| node_secret_listing
node_secret_listing -->|"queries secrets"| node_user_model
node_user_model -->|"persists users"| node_mongodb
node_app -->|"redirects unauthenticated users"| node_login
node_app -->|"renders secret results"| node_secrets_view

click node_app "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js"
click node_home "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/home.ejs"
click node_login "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/login.ejs"
click node_register "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/register.ejs"
click node_submit_view "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/submit.ejs"
click node_secrets_view "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/secrets.ejs"
click node_passport "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js"
click node_session "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js"
click node_google "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js"
click node_user_model "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js"
click node_secret_submit "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js"
click node_secret_listing "https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.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_app,node_home,node_login,node_register,node_submit_view,node_secrets_view toneBlue
class node_passport,node_session,node_google toneAmber
class node_user_model,node_mongodb toneMint
class node_secret_submit,node_secret_listing toneRose
class node_visitor toneIndigo
```

## Components

### Web interface

- [Express routes](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js): `app.js`
- [Home page](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/home.ejs): `views/home.ejs`
- [Login page](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/login.ejs): `views/login.ejs`
- [Registration page](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/register.ejs): `views/register.ejs`
- [Submit page](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/submit.ejs): `views/submit.ejs`
- [Secrets page](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/views/secrets.ejs): `views/secrets.ejs`

### Authentication

- [Passport auth](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js): `app.js`
- [Session middleware](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js): `app.js`
- [Google OAuth](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js): `app.js`

### User data

- [User model](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js): `app.js`
- **MongoDB**

### Secrets workflow

- [Secret submission](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js): `app.js`
- [Secret listing](https://github.com/mahaveer-rulaniya/authorization-and-security/blob/main/app.js): `app.js`

### Other components

- **Visitor**

## Connections

- Visitor → Express routes: sends requests (evidence: `app.js`)
- Express routes → Home page: renders (evidence: `app.js`)
- Express routes → Login page: renders (evidence: `app.js`)
- Express routes → Registration page: renders (evidence: `app.js`)
- Express routes → Submit page: renders (evidence: `app.js`)
- Express routes → Secrets page: renders (evidence: `app.js`)
- Express routes → Session middleware: configures (evidence: `app.js`)
- Express routes → Passport auth: configures (evidence: `app.js`)
- Express routes → User model: defines (evidence: `app.js`)
- Express routes → Google OAuth: configures (evidence: `app.js`)
- Google OAuth → Visitor: redirects to
- Google OAuth → User model: finds or creates (evidence: `app.js`)
- Express routes → Passport auth: authenticates locally (evidence: `app.js`)
- Passport auth → User model: uses strategy (evidence: `app.js`)
- Express routes → User model: registers users (evidence: `app.js`)
- Express routes → Secret submission: handles submission (evidence: `app.js`)
- Secret submission → User model: loads and saves (evidence: `app.js`)
- Express routes → Secret listing: handles listing (evidence: `app.js`)
- Secret listing → User model: queries secrets (evidence: `app.js`)
- User model → MongoDB: persists users (evidence: `app.js`)
- Express routes → Login page: redirects unauthenticated users (evidence: `app.js`)
- Express routes → Secrets page: renders secret results (evidence: `app.js`)
