How shubhankarraj9/url-shortener-project works
This is a FastAPI URL-shortening service. Users register and authenticate, create links, and request public redirects; admins can manage users and links. Redirects resolve through a Redis cache with PostgreSQL fallback, while clicks are buffered and flushed exactly once. The repository also documents Traefik ingress and a Prometheus/Grafana/Alertmanager stack. Some infrastructure and route implementations were not sampled, so those relationships are included only where the README documents them.
Main entry points: main.py Application startup · auth.py Authentication routes · links.py Link creation and lookup · clicks.py Click recording and flush
Components 21
Ingress and monitoring
- Traefik
traefik - Prometheus
monitoring/prometheus - Grafana
monitoring/grafana - Alertmanager
monitoring/alertmanager
API and identity
- Application startup
app/main.py - Authentication routes
app/routers/auth.py - User routes
app/routers/users.py - Admin routes
app/routers/admin.py - Identity and access
app/deps.py - Password and JWT
app/security.py - Email tokens
app/services/tokens.py - Outbound email
app/emailer.py
Links and redirects
- Link management
app/routers/links.py - Link creation and lookup
app/services/links.py - Public redirects
app/routers/redirect.py - Click recording and flush
app/services/clicks.py
Persistence and telemetry
- PostgreSQL
- Redis
- Application metrics
app/metrics.py
Other components
- Internet user
- Administrator
Connections 28
- Internet user → Traefik: sends requests
README.md - Administrator → Traefik: uses admin UI
README.md - Traefik → Application startup: routes API traffic
README.md - Prometheus → Application startup: scrapes metrics
README.md - Prometheus → Alertmanager: sends alerts
README.md - Prometheus → Grafana: supplies dashboards
README.md - Application startup → Authentication routes: registers routes
app/main.py - Application startup → User routes: registers routes
app/main.py - Application startup → Admin routes: registers routes
app/main.py - Application startup → Link management: registers routes
app/main.py - Application startup → Public redirects: registers routes
app/main.py - Authentication routes → Password and JWT: checks credentials
app/routers/auth.py - Authentication routes → Email tokens: issues tokens
app/routers/auth.py - Authentication routes → Outbound email: sends email
app/routers/auth.py - Authentication routes → Identity and access: uses dependencies
app/routers/auth.py - User routes → Identity and access: requires identity
app/routers/users.py - Admin routes → Identity and access: requires admin
app/routers/admin.py - Admin routes → Link creation and lookup: invalidates cache
app/routers/admin.py - Link management → Link creation and lookup: creates and invalidates
app/routers/links.py - Public redirects → Link creation and lookup: resolves code
app/routers/redirect.py - Public redirects → Click recording and flush: records click
app/routers/redirect.py - Application startup → Click recording and flush: starts flush loop
app/main.py - Link creation and lookup → PostgreSQL: reads and writes links
app/services/links.py - Link creation and lookup → Redis: caches resolutions
app/services/links.py - Click recording and flush → Redis: buffers click stream
app/services/clicks.py - Click recording and flush → PostgreSQL: flushes click counts
app/services/clicks.py - Application startup → PostgreSQL: initializes database
app/main.py - Application startup → Application metrics: exposes metrics