How nxd010/url-shortener works
URL Shortener is a FastAPI service for registration/login, URL creation, and short-code redirects. Its principal flow is HTTP routing through business services into repositories, with links read through Redis caching and persisted in PostgreSQL; redirect handling also records clicks asynchronously. The graph preserves authentication, expiration/status validation, Base62 code generation, and click tracking. Relationships are limited to calls and integrations visible in excerpts, the source index, or README; unsampled modules are represented only where their role or connection is documented.
Main entry points: link_service.py Link Service · redirect.py Redirect Route · link_repository.py Link Repository · main.py FastAPI App
Components 24
HTTP API
- FastAPI App
app/main.py - Auth Routes
app/routers/auth.py - Link Routes
app/routers/links.py - Redirect Route
app/routers/redirect.py - Link Schemas
app/schemas/link.py - User Schemas
app/schemas/user.py
Domain Services
- Link Service
app/services/link_service.py - User Service
app/services/user_service.py - Click Service
app/services/click_service.py - Base62 Encoder
app/utils/base62.py - Link Errors
app/exceptions.py
Persistence
- Link Repository
app/repositories/link_repository.py - User Repository
app/repositories/user_repository.py - Click Repository
app/repositories/click_repository.py - Link Model
app/models/link.py - User Model
app/models/user.py - Click Model
app/models/click.py - ORM Base
app/models/base.py - DB Sessions
app/database.py
Authentication
- JWT And Passwords
app/security.py - App Configuration
app/config.py
Other components
- API Client
- PostgreSQL
- Redis Cache
Connections 33
- API Client → FastAPI App: sends requests
README.md - FastAPI App → Auth Routes: registers routes
app/main.py - FastAPI App → Link Routes: registers routes
app/main.py - FastAPI App → Redirect Route: registers routes
app/main.py - Auth Routes → User Service: calls
app/routers/auth.py - Auth Routes → User Schemas: accepts and returns
app/routers/auth.py - Auth Routes → JWT And Passwords: creates token
app/routers/auth.py - Link Routes → Link Service: calls
app/routers/links.py - Link Routes → Link Schemas: uses contracts
app/routers/links.py - Redirect Route → Link Service: validates links
app/routers/redirect.py - Redirect Route → Click Service: schedules tracking
app/routers/redirect.py - Redirect Route → Link Repository: constructs repository
app/routers/redirect.py - Redirect Route → Click Repository: constructs repository
app/routers/redirect.py - Link Service → Link Repository: reads and writes
app/services/link_service.py - Link Service → Base62 Encoder: encodes IDs
app/services/link_service.py - Link Service → Link Schemas: accepts input
app/services/link_service.py - Link Service → Link Errors: raises status errors
app/services/link_service.py - User Service → User Repository: reads and writes
app/services/user_service.py - User Service → User Schemas: accepts input
app/services/user_service.py - User Service → JWT And Passwords: hashes and verifies
app/services/user_service.py - Click Service → Click Repository: persists clicks
app/services/click_service.py - Link Repository → Link Model: queries and persists
app/repositories/link_repository.py - Link Repository → Redis Cache: reads and caches
app/repositories/link_repository.py - User Repository → User Model: queries and persists
app/repositories/user_repository.py - Click Repository → Click Model: persists
app/repositories/click_repository.py - Link Repository → DB Sessions: uses session
app/repositories/link_repository.py - User Repository → DB Sessions: uses session
app/repositories/user_repository.py - Click Repository → DB Sessions: uses session
app/repositories/click_repository.py - DB Sessions → PostgreSQL: opens sessions
app/database.py - Link Model → ORM Base: inherits
app/models/link.py - User Model → ORM Base: inherits
app/models/user.py - Click Model → ORM Base: inherits
app/models/click.py - JWT And Passwords → App Configuration: loads signing key
app/security.py