# userdavidgar03/fastapi-url-shortener architecture

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

- Interactive diagram: https://gitdiagram.com/userdavidgar03/fastapi-url-shortener
- Repository: https://github.com/userdavidgar03/fastapi-url-shortener

## Overview

Fast URL Shortener is a full-stack service for creating, managing, analyzing, and resolving short links. Users start as guests or authenticate, submit URLs, then manage link history and analytics; short-link visits resolve through the backend and may use Redis before PostgreSQL. The frontend also generates downloadable QR codes locally. The README documents PostgreSQL, Redis, JWT, guest quotas, analytics, and QR support; sampled source establishes the main UI/API and redirect relationships, while some detailed backend route behavior is not shown.

Main entry points: [`frontend/src/App.jsx`](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/App.jsx) (App orchestration), [`app/routes.py`](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/routes.py) (URL API and redirect), [`frontend/src/services/api.js`](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/services/api.js) (API client), [`app/main.py`](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app_ui["App orchestration<br/>[App.jsx]"]
  node_welcome["Welcome and guest<br/>[WelcomeView.jsx]"]
  node_auth_view["Login and signup<br/>[AuthView.jsx]"]
  node_short_form["Shorten form<br/>[ShortenerForm.jsx]"]
  node_result["Short link result<br/>[ResultCard.jsx]"]
  node_history["Link history"]
  node_stats["Summary statistics<br/>[StatsCards.jsx]"]
  node_navbar["Session navigation<br/>[Navbar.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_backend["API and identity"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_routes["URL API and redirect<br/>[routes.py]"]
  node_auth_logic["JWT and guest identity<br/>[auth.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
  node_orm["ORM entities<br/>[models.py]"]
  node_db_session["Database sessions<br/>[database.py]"]
end

subgraph group_data["Persistence and cache"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis cache")]
end

subgraph group_link_features["Link features"]
  node_qr["QR generation and download<br/>[QrModal.jsx]"]
  node_analytics["Click analytics<br/>[AnalyticsModal.jsx]"]
  node_click_events["Click event records<br/>[models.py]"]
end

node_visitor(("Visitor"))

node_visitor -->|"uses"| node_app_ui
node_app_ui -->|"renders"| node_welcome
node_app_ui -->|"renders"| node_auth_view
node_app_ui -->|"renders"| node_short_form
node_app_ui -->|"renders"| node_result
node_app_ui -->|"renders"| node_history
node_app_ui -->|"renders"| node_stats
node_app_ui -->|"renders"| node_navbar
node_app_ui -->|"renders"| node_qr
node_app_ui -->|"renders"| node_analytics
node_welcome -->|"submits URL"| node_api_client
node_auth_view -->|"authenticates"| node_api_client
node_app_ui -->|"manages links"| node_api_client
node_history -->|"invokes actions"| node_app_ui
node_api_client -->|"REST requests"| node_backend
node_backend -->|"registers routes"| node_routes
node_backend -->|"uses identity"| node_auth_logic
node_routes -->|"resolves actor"| node_auth_logic
node_routes -->|"validates payloads"| node_schemas
node_routes -->|"queries and updates"| node_orm
node_routes -->|"opens sessions"| node_db_session
node_backend -->|"initializes schema"| node_db_session
node_db_session -->|"persists records"| node_postgres
node_routes -->|"looks up short links"| node_redis
node_routes -->|"loads redirect target"| node_postgres
node_routes -->|"records visits"| node_click_events
node_qr -->|"offers PNG download"| node_visitor
node_analytics -->|"requests metrics"| node_api_client
node_routes -.->|"provides analytics"| node_click_events

click node_app_ui "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/App.jsx"
click node_welcome "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/WelcomeView.jsx"
click node_auth_view "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/AuthView.jsx"
click node_short_form "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/ShortenerForm.jsx"
click node_result "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/ResultCard.jsx"
click node_history "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/UrlHistoryTable.jsx"
click node_stats "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/StatsCards.jsx"
click node_navbar "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/Navbar.jsx"
click node_api_client "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/services/api.js"
click node_backend "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/main.py"
click node_routes "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/routes.py"
click node_auth_logic "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/auth.py"
click node_schemas "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/schemas.py"
click node_orm "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/models.py"
click node_db_session "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/database.py"
click node_qr "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/QrModal.jsx"
click node_analytics "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/AnalyticsModal.jsx"
click node_click_events "https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/models.py"

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_ui,node_welcome,node_auth_view,node_short_form,node_result,node_history,node_stats,node_navbar,node_api_client toneBlue
class node_backend,node_routes,node_auth_logic,node_schemas,node_orm,node_db_session toneAmber
class node_postgres,node_redis toneMint
class node_qr,node_analytics,node_click_events toneRose
class node_visitor toneIndigo
```

## Components

### Web interface

- [App orchestration](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Welcome and guest](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/WelcomeView.jsx): `frontend/src/components/WelcomeView.jsx`
- [Login and signup](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/AuthView.jsx): `frontend/src/components/AuthView.jsx`
- [Shorten form](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/ShortenerForm.jsx): `frontend/src/components/ShortenerForm.jsx`
- [Short link result](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/ResultCard.jsx): `frontend/src/components/ResultCard.jsx`
- [Link history](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/UrlHistoryTable.jsx): `frontend/src/components/UrlHistoryTable.jsx`
- [Summary statistics](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/StatsCards.jsx): `frontend/src/components/StatsCards.jsx`
- [Session navigation](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [API client](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and identity

- [FastAPI application](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/main.py): `app/main.py`
- [URL API and redirect](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/routes.py): `app/routes.py`
- [JWT and guest identity](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/auth.py): `app/auth.py`
- [Request and response schemas](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/schemas.py): `app/schemas.py`
- [ORM entities](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/models.py): `app/models.py`
- [Database sessions](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/database.py): `app/database.py`

### Persistence and cache

- **PostgreSQL**
- **Redis cache**

### Link features

- [QR generation and download](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/QrModal.jsx): `frontend/src/components/QrModal.jsx`
- [Click analytics](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/frontend/src/components/AnalyticsModal.jsx): `frontend/src/components/AnalyticsModal.jsx`
- [Click event records](https://github.com/userdavidgar03/fastapi-url-shortener/blob/main/app/models.py): `app/models.py`

### Other components

- **Visitor**

## Connections

- Visitor → App orchestration: uses (evidence: `README.md`)
- App orchestration → Welcome and guest: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Login and signup: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Shorten form: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Short link result: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Link history: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Summary statistics: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Session navigation: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → QR generation and download: renders (evidence: `frontend/src/App.jsx`)
- App orchestration → Click analytics: renders (evidence: `frontend/src/App.jsx`)
- Welcome and guest → API client: submits URL (evidence: `frontend/src/components/WelcomeView.jsx`)
- Login and signup → API client: authenticates (evidence: `frontend/src/components/AuthView.jsx`)
- App orchestration → API client: manages links (evidence: `frontend/src/App.jsx`)
- Link history → App orchestration: invokes actions (evidence: `frontend/src/App.jsx`)
- API client → FastAPI application: REST requests (evidence: `README.md`)
- FastAPI application → URL API and redirect: registers routes (evidence: `app/main.py`)
- FastAPI application → JWT and guest identity: uses identity (evidence: `app/main.py`)
- URL API and redirect → JWT and guest identity: resolves actor (evidence: `app/routes.py`)
- URL API and redirect → Request and response schemas: validates payloads (evidence: `app/routes.py`)
- URL API and redirect → ORM entities: queries and updates (evidence: `app/routes.py`)
- URL API and redirect → Database sessions: opens sessions (evidence: `app/routes.py`)
- FastAPI application → Database sessions: initializes schema (evidence: `app/main.py`)
- Database sessions → PostgreSQL: persists records (evidence: `README.md`)
- URL API and redirect → Redis cache: looks up short links (evidence: `app/routes.py`)
- URL API and redirect → PostgreSQL: loads redirect target (evidence: `app/routes.py`)
- URL API and redirect → Click event records: records visits (evidence: `app/routes.py`)
- QR generation and download → Visitor: offers PNG download (evidence: `frontend/src/components/QrModal.jsx`)
- Click analytics → API client: requests metrics (evidence: `frontend/src/components/AnalyticsModal.jsx`)
- URL API and redirect → Click event records: provides analytics (evidence: `README.md`)
