How brick-24/url-shorten works
This is a server-rendered URL-shortening service. A user signs in, submits a URL, receives a short code and admin key, and visitors use the code to redirect to the destination while click data is recorded. Owners can view their links and click counts; authenticated users can also request admin-key-protected analytics. The graph includes the separately implemented Google login and rate limiting. Source excerpts show route-to-service calls, but not deployment wiring, so Cloud Run is omitted.
Main entry points: routes.py HTTP routes · links.py Link operations · database.py Database sessions · main.py FastAPI application
Components 17
Web interface
- HTTP routes
src/routes.py - HTML templates
src/templates - Static assets
src/static
Identity and access
- OAuth clients
src/auth.py - GitHub OAuth
- Google OAuth
- Session middleware
src/main.py
Links and analytics
- Link operations
src/links.py - Link and click models
src/models.py
Runtime and storage
- Rate limiting
src/rate_limiting.py - Database sessions
src/database.py - PostgreSQL
- FastAPI application
src/main.py
Other components
- Visitor
- Link owner
- Web browser
- Original destination
Connections 19
- Link owner → Web browser: uses
- Visitor → Web browser: opens links
- Web browser → HTTP routes: HTTP requests
- HTTP routes → HTML templates: renders
- Web browser → Static assets: loads assets
- HTTP routes → OAuth clients: uses OAuth clients
- HTTP routes → GitHub OAuth: starts or completes OAuth
- HTTP routes → Google OAuth: starts or completes OAuth
- HTTP routes → Session middleware: reads or updates session
- HTTP routes → Link operations: creates, looks up, and queries
- HTTP routes → Link and click models: queries URL maps
- Link operations → Link and click models: queries and persists
- HTTP routes → Database sessions: gets sessions
- Database sessions → PostgreSQL: opens sessions and initializes tables
- Link operations → PostgreSQL: reads and writes links and clicks
- HTTP routes → Rate limiting: applies limits
- FastAPI application → HTTP routes: mounts router
- FastAPI application → Database sessions: initializes tables
- HTTP routes → Original destination: redirects visitor