# anurag-sarkar/url_shortner architecture

> Architecture diagram of the GitHub repository anurag-sarkar/url_shortner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anurag-sarkar/url_shortner
- Repository: https://github.com/anurag-sarkar/url_shortner

## Overview

This is a URL-shortening web application: visitors can create short links, and users can register, log in, and retrieve their saved links. The backend also resolves short codes by redirecting to their original URLs. The graph shows the sampled backend request, service, and data-access paths, plus frontend entry points and feature modules named in the tree. Frontend component wiring and API request behavior were not sampled, so those connections are left unspecified; model and database internals are likewise not inferred.

Main entry points: [`BACKEND/app.js`](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/app.js) (Backend app), [`BACKEND/src/dao/short_url.js`](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/dao/short_url.js) (Short URL data access), [`BACKEND/src/dao/user.dao.js`](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/dao/user.dao.js) (User data access), [`BACKEND/src/routes/auth.routes.js`](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/routes/auth.routes.js) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_frontend_app["Frontend app<br/>[main.jsx]"]
  node_home["Home page<br/>[HomePage.jsx]"]
  node_url_form["URL form<br/>[UrlForm.jsx]"]
  node_auth_page["Auth page<br/>[AuthPage.jsx]"]
  node_login_form["Login form<br/>[LoginForm.jsx]"]
  node_register_form["Register form<br/>[RegisterForm.jsx]"]
  node_dashboard["Dashboard<br/>[DashboardPage.jsx]"]
  node_user_urls["User URL list<br/>[UserUrl.jsx]"]
  node_short_api["Short URL API client<br/>[shortUrl.api.js]"]
  node_user_api["User API client<br/>[user.api.js]"]
end

subgraph group_http["HTTP entry points"]
  node_app_server["Backend app<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[auth.routes.js]"]
  node_url_routes["Short URL routes<br/>[short_url.route.js]"]
  node_user_routes["User routes<br/>[user.routes.js]"]
end

subgraph group_identity["Identity"]
  node_auth_controller["Auth controller<br/>[auth.controller.js]"]
  node_auth_service["Auth service<br/>[auth.service.js]"]
  node_auth_middleware["Auth middleware<br/>[auth.middleware.js]"]
  node_user_controller["User controller<br/>[user.controller.js]"]
  node_user_dao["User data access<br/>[user.dao.js]"]
  node_user_model["User model<br/>[user.model.js]"]
end

subgraph group_shortlinks["Short-link lifecycle"]
  node_short_controller["Short URL controller"]
  node_short_service["Short URL service"]
  node_short_dao["Short URL data access<br/>[short_url.js]"]
  node_short_model["Short URL model<br/>[short_url.model.js]"]
  node_database[("MongoDB<br/>[monogo.config.js]")]
end

node_visitor(("Visitor"))

node_visitor -->|"uses"| node_frontend_app
node_app_server -->|"mounts routes"| node_auth_routes
node_app_server -->|"mounts routes"| node_url_routes
node_app_server -->|"mounts routes"| node_user_routes
node_app_server -->|"dispatches redirects"| node_short_controller
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"protects profile"| node_auth_middleware
node_user_routes -->|"protects URLs"| node_auth_middleware
node_user_routes -->|"dispatches"| node_user_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"reads and creates users"| node_user_dao
node_auth_middleware -->|"loads user"| node_user_dao
node_user_controller -->|"loads saved URLs"| node_user_dao
node_short_controller -->|"creates short URL"| node_short_service
node_short_controller -->|"looks up code"| node_short_dao
node_short_service -->|"checks and saves"| node_short_dao
node_user_dao -->|"uses model"| node_user_model
node_short_dao -->|"uses model"| node_short_model
node_short_dao -->|"persists links"| node_database

click node_frontend_app "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/main.jsx"
click node_home "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/pages/HomePage.jsx"
click node_url_form "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/components/UrlForm.jsx"
click node_auth_page "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/pages/AuthPage.jsx"
click node_login_form "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/components/LoginForm.jsx"
click node_register_form "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/components/RegisterForm.jsx"
click node_dashboard "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/pages/DashboardPage.jsx"
click node_user_urls "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/components/UserUrl.jsx"
click node_short_api "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/api/shortUrl.api.js"
click node_user_api "https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/api/user.api.js"
click node_app_server "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/app.js"
click node_auth_routes "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/routes/auth.routes.js"
click node_url_routes "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/routes/short_url.route.js"
click node_user_routes "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/routes/user.routes.js"
click node_auth_controller "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/controller/auth.controller.js"
click node_auth_service "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/services/auth.service.js"
click node_auth_middleware "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/middleware/auth.middleware.js"
click node_user_controller "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/controller/user.controller.js"
click node_short_controller "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/controller/short_url.controller.js"
click node_short_service "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/services/short_url.service.js"
click node_user_dao "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/dao/user.dao.js"
click node_short_dao "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/dao/short_url.js"
click node_user_model "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/models/user.model.js"
click node_short_model "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/models/short_url.model.js"
click node_database "https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/config/monogo.config.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_frontend_app,node_home,node_url_form,node_auth_page,node_login_form,node_register_form,node_dashboard,node_user_urls,node_short_api,node_user_api toneBlue
class node_app_server,node_auth_routes,node_url_routes,node_user_routes toneAmber
class node_auth_controller,node_auth_service,node_auth_middleware,node_user_controller,node_user_dao,node_user_model toneMint
class node_short_controller,node_short_service,node_short_dao,node_short_model,node_database toneRose
class node_visitor toneIndigo
```

## Components

### Web interface

- [Frontend app](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/main.jsx): `FRONTEND/src/main.jsx`
- [Home page](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/pages/HomePage.jsx): `FRONTEND/src/pages/HomePage.jsx`
- [URL form](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/components/UrlForm.jsx): `FRONTEND/src/components/UrlForm.jsx`
- [Auth page](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/pages/AuthPage.jsx): `FRONTEND/src/pages/AuthPage.jsx`
- [Login form](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/components/LoginForm.jsx): `FRONTEND/src/components/LoginForm.jsx`
- [Register form](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/components/RegisterForm.jsx): `FRONTEND/src/components/RegisterForm.jsx`
- [Dashboard](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/pages/DashboardPage.jsx): `FRONTEND/src/pages/DashboardPage.jsx`
- [User URL list](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/components/UserUrl.jsx): `FRONTEND/src/components/UserUrl.jsx`
- [Short URL API client](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/api/shortUrl.api.js): `FRONTEND/src/api/shortUrl.api.js`
- [User API client](https://github.com/anurag-sarkar/url_shortner/blob/master/FRONTEND/src/api/user.api.js): `FRONTEND/src/api/user.api.js`

### HTTP entry points

- [Backend app](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/app.js): `BACKEND/app.js`
- [Auth routes](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/routes/auth.routes.js): `BACKEND/src/routes/auth.routes.js`
- [Short URL routes](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/routes/short_url.route.js): `BACKEND/src/routes/short_url.route.js`
- [User routes](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/routes/user.routes.js): `BACKEND/src/routes/user.routes.js`

### Identity

- [Auth controller](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/controller/auth.controller.js): `BACKEND/src/controller/auth.controller.js`
- [Auth service](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/services/auth.service.js): `BACKEND/src/services/auth.service.js`
- [Auth middleware](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/middleware/auth.middleware.js): `BACKEND/src/middleware/auth.middleware.js`
- [User controller](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/controller/user.controller.js): `BACKEND/src/controller/user.controller.js`
- [User data access](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/dao/user.dao.js): `BACKEND/src/dao/user.dao.js`
- [User model](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/models/user.model.js): `BACKEND/src/models/user.model.js`

### Short-link lifecycle

- [Short URL controller](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/controller/short_url.controller.js): `BACKEND/src/controller/short_url.controller.js`
- [Short URL service](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/services/short_url.service.js): `BACKEND/src/services/short_url.service.js`
- [Short URL data access](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/dao/short_url.js): `BACKEND/src/dao/short_url.js`
- [Short URL model](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/models/short_url.model.js): `BACKEND/src/models/short_url.model.js`
- [MongoDB](https://github.com/anurag-sarkar/url_shortner/blob/master/BACKEND/src/config/monogo.config.js): `BACKEND/src/config/monogo.config.js`

### Other components

- **Visitor**

## Connections

- Visitor → Frontend app: uses
- Backend app → Auth routes: mounts routes
- Backend app → Short URL routes: mounts routes
- Backend app → User routes: mounts routes
- Backend app → Short URL controller: dispatches redirects
- Auth routes → Auth controller: dispatches
- Auth routes → Auth middleware: protects profile
- User routes → Auth middleware: protects URLs
- User routes → User controller: dispatches
- Auth controller → Auth service: calls
- Auth service → User data access: reads and creates users
- Auth middleware → User data access: loads user
- User controller → User data access: loads saved URLs
- Short URL controller → Short URL service: creates short URL
- Short URL controller → Short URL data access: looks up code
- Short URL service → Short URL data access: checks and saves
- User data access → User model: uses model
- Short URL data access → Short URL model: uses model
- Short URL data access → MongoDB: persists links
