# awpetrik/shawtylink architecture

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

- Interactive diagram: https://gitdiagram.com/awpetrik/shawtylink
- Repository: https://github.com/awpetrik/shawtylink

## Overview

ShawtyLink is a self-hostable URL-shortening SaaS. Users can create and manage links, then share and track them; authentication, protected-link unlocking, analytics, account settings, and administrator functions are additional workflows. The frontend routes users into these experiences and calls a FastAPI backend, which applies authentication and persists domain data. README capabilities such as Redis-backed redirects and email flows are represented where documented, but sampled backend excerpts do not show their full implementation or wiring.

Main entry points: [`backend/app/main.py`](https://github.com/awpetrik/shawtylink/blob/main/backend/app/main.py) (FastAPI routes), [`frontend/src/App.jsx`](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/App.jsx) (Route application), [`frontend/src/pages/Links.jsx`](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Links.jsx) (Link management), [`backend/app/auth.py`](https://github.com/awpetrik/shawtylink/blob/main/backend/app/auth.py) (JWT and access control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_webapp["Route application<br/>[App.jsx]"]
  node_authstate["Auth context<br/>[AuthContext.jsx]"]
  node_linkui["Link management<br/>[Links.jsx]"]
  node_linkdialogs["Link modals"]
  node_dashboard["User dashboard<br/>[Dashboard.jsx]"]
  node_analyticsui["Analytics view<br/>[Analytics.jsx]"]
  node_settings["Account settings<br/>[Settings.jsx]"]
  node_unlockui["Unlock page<br/>[UnlockLinkView.jsx]"]
  node_adminui["Admin workspace<br/>[AdminView.jsx]"]
  node_adminusers["User administration<br/>[AdminUsers.jsx]"]
  node_toast["Toast feedback<br/>[ToastContext.jsx]"]
  node_home["Public home<br/>[HomeView.jsx]"]
end

subgraph group_backend["API and identity"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_auth["JWT and access control<br/>[auth.py]"]
  node_email["Email utilities<br/>[email_utils.py]"]
end

subgraph group_domain["Link and account data"]
  node_dbsession["Database sessions<br/>[database.py]"]
  node_models["User and URL models<br/>[models.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_services["External services"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis cache")]
  node_mailservice["Email service"]
  node_browser(("Browser"))
end

node_visitor(("Visitor or user"))

node_visitor -->|"uses"| node_webapp
node_webapp -->|"provides auth"| node_authstate
node_webapp -->|"routes to"| node_home
node_webapp -->|"routes to"| node_linkui
node_webapp -->|"routes to"| node_dashboard
node_webapp -->|"routes to"| node_analyticsui
node_webapp -->|"routes to"| node_settings
node_webapp -->|"routes to"| node_unlockui
node_webapp -->|"routes to"| node_adminui
node_webapp -->|"routes to"| node_adminusers
node_linkui -->|"renders"| node_linkdialogs
node_linkui -.->|"requests links"| node_api
node_dashboard -.->|"requests dashboard"| node_api
node_analyticsui -.->|"requests analytics"| node_api
node_settings -.->|"requests account"| node_api
node_unlockui -.->|"requests unlock"| node_api
node_adminusers -.->|"requests users"| node_api
node_authstate -->|"calls API"| node_browser
node_browser -.->|"HTTP requests"| node_api
node_api -->|"checks access"| node_auth
node_auth -->|"queries session"| node_dbsession
node_api -->|"opens sessions"| node_dbsession
node_dbsession -.->|"connects"| node_postgres
node_api -->|"queries records"| node_models
node_auth -->|"loads user"| node_models
node_api -->|"validates payloads"| node_schemas
node_auth -->|"builds token data"| node_schemas
node_models -->|"uses base"| node_dbsession
node_api -.->|"stores reset token"| node_redis
node_api -.->|"requests email"| node_email
node_email -.->|"sends mail"| node_mailservice
node_home -.->|"uses feedback"| node_toast
node_linkui -->|"uses feedback"| node_toast

click node_webapp "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/App.jsx"
click node_authstate "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/context/AuthContext.jsx"
click node_linkui "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Links.jsx"
click node_linkdialogs "https://github.com/awpetrik/shawtylink/tree/main/frontend/src/components/links"
click node_dashboard "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Dashboard.jsx"
click node_analyticsui "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Analytics.jsx"
click node_settings "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Settings.jsx"
click node_unlockui "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/views/UnlockLinkView.jsx"
click node_adminui "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/views/AdminView.jsx"
click node_adminusers "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/views/admin/AdminUsers.jsx"
click node_toast "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/context/ToastContext.jsx"
click node_home "https://github.com/awpetrik/shawtylink/blob/main/frontend/src/views/HomeView.jsx"
click node_api "https://github.com/awpetrik/shawtylink/blob/main/backend/app/main.py"
click node_auth "https://github.com/awpetrik/shawtylink/blob/main/backend/app/auth.py"
click node_email "https://github.com/awpetrik/shawtylink/blob/main/backend/app/email_utils.py"
click node_dbsession "https://github.com/awpetrik/shawtylink/blob/main/backend/app/database.py"
click node_models "https://github.com/awpetrik/shawtylink/blob/main/backend/app/models.py"
click node_schemas "https://github.com/awpetrik/shawtylink/blob/main/backend/app/schemas.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_webapp,node_authstate,node_linkui,node_linkdialogs,node_dashboard,node_analyticsui,node_settings,node_unlockui,node_adminui,node_adminusers,node_toast,node_home,node_visitor toneBlue
class node_api,node_auth,node_email toneAmber
class node_dbsession,node_models,node_schemas toneMint
class node_postgres,node_redis,node_mailservice,node_browser toneRose
```

## Components

### Web application

- [Route application](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Link management](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Links.jsx): `frontend/src/pages/Links.jsx`
- [Link modals](https://github.com/awpetrik/shawtylink/tree/main/frontend/src/components/links): `frontend/src/components/links`
- [User dashboard](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Analytics view](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Analytics.jsx): `frontend/src/pages/Analytics.jsx`
- [Account settings](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/pages/Settings.jsx): `frontend/src/pages/Settings.jsx`
- [Unlock page](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/views/UnlockLinkView.jsx): `frontend/src/views/UnlockLinkView.jsx`
- [Admin workspace](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/views/AdminView.jsx): `frontend/src/views/AdminView.jsx`
- [User administration](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/views/admin/AdminUsers.jsx): `frontend/src/views/admin/AdminUsers.jsx`
- [Toast feedback](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/context/ToastContext.jsx): `frontend/src/context/ToastContext.jsx`
- [Public home](https://github.com/awpetrik/shawtylink/blob/main/frontend/src/views/HomeView.jsx): `frontend/src/views/HomeView.jsx`

### API and identity

- [FastAPI routes](https://github.com/awpetrik/shawtylink/blob/main/backend/app/main.py): `backend/app/main.py`
- [JWT and access control](https://github.com/awpetrik/shawtylink/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Email utilities](https://github.com/awpetrik/shawtylink/blob/main/backend/app/email_utils.py): `backend/app/email_utils.py`

### Link and account data

- [Database sessions](https://github.com/awpetrik/shawtylink/blob/main/backend/app/database.py): `backend/app/database.py`
- [User and URL models](https://github.com/awpetrik/shawtylink/blob/main/backend/app/models.py): `backend/app/models.py`
- [API schemas](https://github.com/awpetrik/shawtylink/blob/main/backend/app/schemas.py): `backend/app/schemas.py`

### External services

- **PostgreSQL**
- **Redis cache**
- **Email service**
- **Browser**

### Other components

- **Visitor or user**

## Connections

- Visitor or user → Route application: uses (evidence: `frontend/src/App.jsx`)
- Route application → Auth context: provides auth (evidence: `frontend/src/App.jsx`)
- Route application → Public home: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Link management: routes to (evidence: `frontend/src/App.jsx`)
- Route application → User dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Analytics view: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Account settings: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Unlock page: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Admin workspace: routes to (evidence: `frontend/src/App.jsx`)
- Route application → User administration: routes to (evidence: `frontend/src/App.jsx`)
- Link management → Link modals: renders (evidence: `frontend/src/pages/Links.jsx`)
- Link management → FastAPI routes: requests links
- User dashboard → FastAPI routes: requests dashboard
- Analytics view → FastAPI routes: requests analytics
- Account settings → FastAPI routes: requests account
- Unlock page → FastAPI routes: requests unlock
- User administration → FastAPI routes: requests users
- Auth context → Browser: calls API (evidence: `frontend/src/context/AuthContext.jsx`)
- Browser → FastAPI routes: HTTP requests
- FastAPI routes → JWT and access control: checks access (evidence: `backend/app/main.py`)
- JWT and access control → Database sessions: queries session (evidence: `backend/app/auth.py`)
- FastAPI routes → Database sessions: opens sessions (evidence: `backend/app/main.py`)
- Database sessions → PostgreSQL: connects
- FastAPI routes → User and URL models: queries records (evidence: `backend/app/main.py`)
- JWT and access control → User and URL models: loads user (evidence: `backend/app/auth.py`)
- FastAPI routes → API schemas: validates payloads (evidence: `backend/app/main.py`)
- JWT and access control → API schemas: builds token data (evidence: `backend/app/auth.py`)
- User and URL models → Database sessions: uses base (evidence: `backend/app/models.py`)
- FastAPI routes → Redis cache: stores reset token
- FastAPI routes → Email utilities: requests email (evidence: `backend/app/main.py`)
- Email utilities → Email service: sends mail
- Public home → Toast feedback: uses feedback (evidence: `frontend/src/views/HomeView.jsx`)
- Link management → Toast feedback: uses feedback (evidence: `frontend/src/pages/Links.jsx`)
