How pathangufran/url-shortener works
This is a Django REST backend for shortening URLs. The main workflow is an authenticated user creating and managing a short URL, then a visitor resolving its code: the redirect handler asks the URL service to check Redis and fall back to PostgreSQL, redirects to the destination, and initiates click analytics. Separate account and analytics APIs support authentication, reporting, and event retrieval; analytics can record click details asynchronously. The README documents PostgreSQL, Redis, and API capabilities; some routes and integrations are not shown in sampled source, so those links are documented or left unverified.
Main entry points: shortener/views.py URL APIs · shortener/services.py URL service · analytics/services.py Analytics service · accounts/views.py Account APIs
Components 23
API layer
- Account APIs
apps/accounts/views.py - Authentication
apps/accounts/services.py - Account serializers
apps/accounts/serializers.py
URL management
- URL APIs
apps/shortener/views.py - URL service
apps/shortener/services.py - URL serializers
apps/shortener/serializers.py - Short URL records
apps/shortener/models.py - QR generation
apps/shortener/utils/qr.py - URL background task
apps/shortener/tasks.py
Click analytics
- Analytics APIs
apps/analytics/views.py - Analytics service
apps/analytics/services.py - Analytics serializers
apps/analytics/serializers.py - Click event records
apps/analytics/models.py - Click event worker
apps/analytics/tasks.py
Shared services
- Request throttling
apps/shortener/utils/throttling.py - Rate limiter
apps/shortener/utils/rate_limiter.py - URL cache
apps/shortener/utils/redis_client.py - Runtime settings
config/settings/base.py - API error handling
config/exceptions.py
Other components
- Client
- Redis
- PostgreSQL
- Celery worker
Connections 30
- Client → Account APIs: authenticates
README.md - Account APIs → Authentication: delegates to
apps/accounts/views.py - Account APIs → Account serializers: serializes with
apps/accounts/views.py - Client → URL APIs: manages URLs
README.md - URL APIs → URL service: delegates to
apps/shortener/views.py - URL APIs → URL serializers: serializes with
apps/shortener/views.py - URL service → Short URL records: reads and writes
apps/shortener/services.py - URL APIs → QR generation: generates QR
apps/shortener/views.py - Client → URL APIs: resolves code
README.md - URL APIs → URL service: resolves code
apps/shortener/views.py - URL service → URL cache: checks and fills
apps/shortener/services.py - URL cache → Redis: reads and writes
apps/shortener/utils/redis_client.py - URL APIs → Analytics service: records click
apps/shortener/views.py - URL service → PostgreSQL: loads URL
apps/shortener/services.py - Client → Analytics APIs: requests reports
README.md - Analytics APIs → Analytics service: queries
apps/analytics/views.py - Analytics APIs → Analytics serializers: serializes with
apps/analytics/views.py - Analytics service → Short URL records: checks ownership
apps/analytics/services.py - Analytics service → Click event records: queries events
apps/analytics/services.py - Analytics service → Click event worker: queues event
apps/analytics/services.py - Click event worker → Click event records: persists event
apps/analytics/tasks.py - Request throttling → Rate limiter: checks quota
apps/shortener/utils/throttling.py - Account APIs → Request throttling: applies throttles
apps/accounts/views.py - URL APIs → Request throttling: applies throttles
apps/shortener/views.py - Analytics APIs → Request throttling: applies throttles
apps/analytics/views.py - Runtime settings → Redis: configures cache
README.md - Runtime settings → PostgreSQL: configures database
README.md - Click event worker → Celery worker: runs asynchronously
README.md - URL background task → Celery worker: runs asynchronously
README.md - Runtime settings → API error handling: sets handler
config/settings/base.py