How dunkrick/url-shortener works
Nip shortens submitted URLs, redirects visitors, and reports an aggregate redirect count. The browser app submits URLs and polls statistics through a shared API client; the Go API uses PostgreSQL for mappings and Redis for redirect caching, creation limits, and the total count. The README documents the backend storage behavior and API routes, but backend implementation excerpts were not provided, so backend relationships rely on README evidence rather than inspected handler code.
Main entry points: App.tsx Shortener app · main.go Go HTTP API · api-client.ts HTTP client · init.sql URL mappings
Components 20
Web application
- Shortener app
frontend/src/App.tsx - URL form
frontend/src/components/UrlForm.tsx - Link result
frontend/src/components/ShortUrlResult.tsx - Shorten state
frontend/src/features/shorten/useShortenUrl.ts - Shorten API
frontend/src/features/shorten/api.ts - Stats polling
frontend/src/features/stats/useStats.ts - Stats API
frontend/src/features/stats/api.ts - HTTP client
frontend/src/lib/api-client.ts - API configuration
frontend/src/config/env.ts
Go API
- Go HTTP API
main.go - URL creation
main.go - Redirect resolution
main.go - Creation rate limit
main.go - Redirect statistics
main.go
Persistence and cache
- URL mappings
init.sql - Redis state
- PostgreSQL
Other components
- Link visitor
- Browser user
- Redis service
Connections 23
- Browser user → Shortener app: uses
frontend/src/App.tsx - Shortener app → URL form: renders
frontend/src/App.tsx - Shortener app → Link result: renders
frontend/src/App.tsx - Shortener app → Shorten state: uses
frontend/src/App.tsx - Shortener app → Stats polling: uses
frontend/src/App.tsx - Shorten state → Shorten API: calls
frontend/src/features/shorten/useShortenUrl.ts - Stats polling → Stats API: polls
frontend/src/features/stats/useStats.ts - Shorten API → HTTP client: calls
frontend/src/features/shorten/api.ts - Stats API → HTTP client: calls
frontend/src/features/stats/api.ts - HTTP client → API configuration: reads
frontend/src/lib/api-client.ts - HTTP client → Go HTTP API: requests
README.md - Link visitor → Redirect resolution: requests code
README.md - Go HTTP API → URL creation: routes
README.md - Go HTTP API → Redirect resolution: routes
README.md - Go HTTP API → Redirect statistics: routes
README.md - URL creation → Creation rate limit: applies
README.md - URL creation → URL mappings: stores mapping
README.md - Redirect resolution → Redis state: checks cache
README.md - Redirect resolution → URL mappings: reads on miss
README.md - Redirect statistics → Redis state: reads count
README.md - Creation rate limit → Redis state: uses limits
README.md - URL mappings → PostgreSQL: stored in
README.md - Redis state → Redis service: uses
README.md