How antormojumdar/url-shortener works
This is a FastAPI URL-shortening service with optional Redis acceleration and rate limiting. A user submits a validated link request; the API enforces limits, creates a link, and returns its short URL. Visits resolve the code, check expiry, record privacy-conscious click details, and redirect. Separate API operations list links, report browser/device/day analytics, and delete links. The graph follows calls visible in the excerpts and capabilities documented in the README; unsampled behavior is not inferred.
Main entry points: main.py FastAPI routes · crud.py Link operations · rate_limit.py Request rate limiter · database.py SQLAlchemy database setup
Components 14
HTTP API
- FastAPI routes
url_shortener/app/main.py - Request and response schemas
url_shortener/app/schemas.py
Link Management
- Link operations
url_shortener/app/crud.py - Code generation
url_shortener/app/utils.py - Link and click models
url_shortener/app/models.py
Click Analytics
- Click detail parsing and hashing
url_shortener/app/utils.py - Click aggregation
url_shortener/app/crud.py
Persistence and Acceleration
- SQLAlchemy database setup
url_shortener/app/database.py - SQLite or PostgreSQL
- Redirect cache
url_shortener/app/cache.py - Request rate limiter
url_shortener/app/rate_limit.py - Redis
- Runtime settings
url_shortener/app/config.py
Other components
- API user
Connections 19
- API user → FastAPI routes: sends requests
README.md - FastAPI routes → Request and response schemas: validates and shapes
url_shortener/app/main.py - FastAPI routes → Request rate limiter: enforces limits
url_shortener/app/main.py - FastAPI routes → Link operations: creates, reads, deletes
url_shortener/app/main.py - FastAPI routes → Redirect cache: reads and updates
url_shortener/app/main.py - FastAPI routes → Click detail parsing and hashing: parses and hashes
url_shortener/app/main.py - FastAPI routes → Click aggregation: requests breakdown
url_shortener/app/main.py - Link operations → Code generation: generates codes
url_shortener/app/crud.py - Link operations → Link and click models: queries and records
url_shortener/app/crud.py - Link operations → SQLAlchemy database setup: uses sessions
url_shortener/app/crud.py - Click aggregation → Link and click models: aggregates click events
url_shortener/app/crud.py - SQLAlchemy database setup → Runtime settings: loads connection settings
url_shortener/app/database.py - SQLAlchemy database setup → SQLite or PostgreSQL: connects to
README.md - Link and click models → SQLAlchemy database setup: uses declarative base
url_shortener/app/models.py - Redirect cache → Runtime settings: loads Redis settings
url_shortener/app/cache.py - Redirect cache → Redis: caches URLs
url_shortener/app/cache.py - Request rate limiter → Runtime settings: loads limit settings
url_shortener/app/rate_limit.py - Request rate limiter → Redirect cache: uses Redis client
url_shortener/app/rate_limit.py - Request rate limiter → Redis: checks distributed limits
url_shortener/app/rate_limit.py