# prathameshbankar/urlshortner-and-user-authentication architecture

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

- Interactive diagram: https://gitdiagram.com/prathameshbankar/urlshortner-and-user-authentication
- Repository: https://github.com/prathameshbankar/urlshortner-and-user-authentication

## Overview

This is an Express URL shortener with employee signup/login. The main workflow accepts a URL, creates a short ID and stored redirect record, then records visits when the short link is opened; a separate endpoint returns visit analytics. Static routes serve the home, signup, and login pages. The excerpts show route mounting, controller/model calls, and Mongo connection setup. MongoDB model persistence is inferred from Mongoose schemas, so those data-store links are marked unverified; no README was provided.

Main entry points: [`controllers/url.js`](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/controllers/url.js) (URL controller), [`index.js`](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/index.js) (Express app), [`routes/staticRoutes.js`](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/routes/staticRoutes.js) (Static routes), [`controllers/employee.js`](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/controllers/employee.js) (Employee controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web routing"]
  node_app["Express app<br/>[index.js]"]
  node_static_routes["Static routes<br/>[staticRoutes.js]"]
  node_url_routes["URL routes<br/>[url.js]"]
  node_employee_routes["Employee routes<br/>[employes.js]"]
  node_db_connector["Mongo connector<br/>[connection.js]"]
end

subgraph group_shortlinks["Short links"]
  node_url_controller["URL controller<br/>[url.js]"]
  node_url_model["URL records<br/>[urls.js]"]
end

subgraph group_employees["Employee accounts"]
  node_employee_controller["Employee controller<br/>[employee.js]"]
  node_employee_model["Employee records<br/>[employee.js]"]
end

subgraph group_presentation["Rendered pages"]
  node_home_view["Home page<br/>[home.ejs]"]
  node_signup_view["Signup page<br/>[signup.ejs]"]
  node_login_view["Login page<br/>[login.ejs]"]
end

node_visitor(("Visitor"))
node_mongodb[("MongoDB")]
node_redirect_target(("Redirect destination"))

node_visitor -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_static_routes
node_app -->|"mounts routes"| node_url_routes
node_app -->|"mounts routes"| node_employee_routes
node_app -->|"connects with"| node_db_connector
node_db_connector -->|"connects to"| node_mongodb
node_static_routes -->|"reads URLs"| node_url_model
node_static_routes -->|"renders"| node_home_view
node_static_routes -->|"renders"| node_signup_view
node_static_routes -->|"renders"| node_login_view
node_url_routes -->|"dispatches to"| node_url_controller
node_url_controller -->|"creates records"| node_url_model
node_url_controller -->|"updates visits"| node_url_model
node_url_controller -->|"reads analytics"| node_url_model
node_url_controller -->|"renders"| node_home_view
node_url_controller -->|"redirects to"| node_redirect_target
node_employee_routes -->|"dispatches to"| node_employee_controller
node_employee_controller -->|"creates account"| node_employee_model
node_employee_controller -->|"checks credentials"| node_employee_model
node_employee_controller -->|"renders"| node_home_view
node_employee_controller -->|"renders"| node_login_view
node_url_model -.->|"persists records"| node_mongodb
node_employee_model -.->|"persists accounts"| node_mongodb

click node_app "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/index.js"
click node_static_routes "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/routes/staticRoutes.js"
click node_url_routes "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/routes/url.js"
click node_employee_routes "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/routes/employes.js"
click node_url_controller "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/controllers/url.js"
click node_url_model "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/models/urls.js"
click node_employee_controller "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/controllers/employee.js"
click node_employee_model "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/models/employee.js"
click node_db_connector "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/connection.js"
click node_home_view "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/views/home.ejs"
click node_signup_view "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/views/signup.ejs"
click node_login_view "https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/views/login.ejs"

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_static_routes,node_url_routes,node_employee_routes,node_db_connector toneBlue
class node_url_controller,node_url_model,node_mongodb toneAmber
class node_employee_controller,node_employee_model toneMint
class node_home_view,node_signup_view,node_login_view toneRose
class node_visitor,node_redirect_target toneIndigo
```

## Components

### Web routing

- [Express app](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/index.js): `index.js`
- [Static routes](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/routes/staticRoutes.js): `routes/staticRoutes.js`
- [URL routes](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/routes/url.js): `routes/url.js`
- [Employee routes](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/routes/employes.js): `routes/employes.js`
- [Mongo connector](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/connection.js): `connection.js`

### Short links

- [URL controller](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/controllers/url.js): `controllers/url.js`
- [URL records](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/models/urls.js): `models/urls.js`

### Employee accounts

- [Employee controller](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/controllers/employee.js): `controllers/employee.js`
- [Employee records](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/models/employee.js): `models/employee.js`

### Rendered pages

- [Home page](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/views/home.ejs): `views/home.ejs`
- [Signup page](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/views/signup.ejs): `views/signup.ejs`
- [Login page](https://github.com/prathameshbankar/urlshortner-and-user-authentication/blob/main/views/login.ejs): `views/login.ejs`

### Other components

- **Visitor**
- **MongoDB**
- **Redirect destination**

## Connections

- Visitor → Express app: sends requests (evidence: `index.js`)
- Express app → Static routes: mounts routes (evidence: `index.js`)
- Express app → URL routes: mounts routes (evidence: `index.js`)
- Express app → Employee routes: mounts routes (evidence: `index.js`)
- Express app → Mongo connector: connects with (evidence: `index.js`)
- Mongo connector → MongoDB: connects to (evidence: `connection.js`)
- Static routes → URL records: reads URLs (evidence: `routes/staticRoutes.js`)
- Static routes → Home page: renders (evidence: `routes/staticRoutes.js`)
- Static routes → Signup page: renders (evidence: `routes/staticRoutes.js`)
- Static routes → Login page: renders (evidence: `routes/staticRoutes.js`)
- URL routes → URL controller: dispatches to (evidence: `routes/url.js`)
- URL controller → URL records: creates records (evidence: `controllers/url.js`)
- URL controller → URL records: updates visits (evidence: `controllers/url.js`)
- URL controller → URL records: reads analytics (evidence: `controllers/url.js`)
- URL controller → Home page: renders (evidence: `controllers/url.js`)
- URL controller → Redirect destination: redirects to (evidence: `controllers/url.js`)
- Employee routes → Employee controller: dispatches to (evidence: `routes/employes.js`)
- Employee controller → Employee records: creates account (evidence: `controllers/employee.js`)
- Employee controller → Employee records: checks credentials (evidence: `controllers/employee.js`)
- Employee controller → Home page: renders (evidence: `controllers/employee.js`)
- Employee controller → Login page: renders (evidence: `controllers/employee.js`)
- URL records → MongoDB: persists records
- Employee records → MongoDB: persists accounts
