How karthikeyapolakonda/url-shortener works
Stub is an authenticated URL-shortening product: users sign in, create owned short links, inspect or delete them, while visitors resolve codes to redirects and generate click analytics. The graph includes the frontend-to-API path, backend domain stages, persistence, and Redis-backed services. README documents frontend history and stats; several route/service implementations were not excerpted, so those links are shown only where documentation or indexed references support them.
Main entry points: main.py FastAPI app · redirect.py Redirect route · links.py Link routes · auth.py Auth routes
Components 24
Web experience
- Shortener UI
frontend/app/page.tsx - Dashboard
frontend/app/dashboard/page.tsx - Link stats
frontend/app/stats/[code]/page.tsx - Browser history
frontend/lib/storage.ts - Fetch client
frontend/lib/api.ts - Link API service
frontend/services/links.ts - Auth experience
frontend/contexts/AuthContext.tsx - Auth API service
frontend/services/auth.ts
API surface
- FastAPI app
backend/app/main.py - Link routes
backend/app/routers/links.py - Redirect route
backend/app/routers/redirect.py - Auth routes
backend/app/routers/auth.py - Health routes
backend/app/routers/health.py - Request schemas
backend/app/schemas.py
Identity and links
- Link and user logic
backend/app/crud.py - Token security
backend/app/core/security.py - Domain models
backend/app/models.py
Runtime services
- SQL database
backend/app/database.py - Link cache
backend/app/services/cache.py - Click analytics
backend/app/services/analytics.py - Rate limiter
backend/app/services/rate_limit.py - Redis gateway
backend/app/services/redis_client.py
Other components
- Visitor
- Destination URL
Connections 33
- Visitor → Shortener UI: uses
- Shortener UI → Link API service: requests links
- Dashboard → Link API service: loads links
- Link stats → Link API service: loads stats
- Shortener UI → Browser history: stores codes
- Browser history → Link API service: refreshes stats
- Link API service → Fetch client: calls
- Fetch client → FastAPI app: HTTP requests
- Auth experience → Auth API service: auth requests
- Auth API service → Fetch client: uses
- FastAPI app → Link routes: registers
backend/app/main.py - FastAPI app → Redirect route: registers last
backend/app/main.py - FastAPI app → Auth routes: registers
backend/app/main.py - FastAPI app → Health routes: registers
backend/app/main.py - Link routes → Request schemas: validates and responds
backend/app/routers/links.py - Auth routes → Request schemas: validates and responds
backend/app/routers/auth.py - Link routes → Link and user logic: creates and manages
backend/app/routers/links.py - Redirect route → Link and user logic: looks up link
backend/app/routers/redirect.py - Auth routes → Link and user logic: manages users
backend/app/routers/auth.py - Auth routes → Token security: hashes and signs
backend/app/routers/auth.py - Link routes → Link cache: caches and invalidates
backend/app/routers/links.py - Redirect route → Link cache: reads cache
backend/app/routers/redirect.py - Redirect route → Click analytics: records clicks
backend/app/routers/redirect.py - Link routes → Rate limiter: checks limits
backend/app/routers/links.py - Auth routes → Rate limiter: checks limits
backend/app/routers/auth.py - Redirect route → Rate limiter: checks limits
backend/app/routers/redirect.py - Rate limiter → Redis gateway: increments counters
backend/app/services/rate_limit.py - Link and user logic → Domain models: queries and persists
backend/app/crud.py - Domain models → SQL database: maps to
backend/app/models.py - Health routes → SQL database: checks connection
backend/app/routers/health.py - FastAPI app → Redis gateway: closes on shutdown
backend/app/main.py - Redis gateway → Link cache: backs storage
- Redirect route → Destination URL: redirects