How thrigunchandra/c4_shortroute works
This is a FastAPI URL-shortening service. Visitors create short links and follow short-code or username/custom-slug redirects; registered users can manage links, while authentication provides session-based access and premium custom slugs. Redirect resolution checks Redis, falls back to PostgreSQL, validates expiry, and counts clicks for owned links. The graph also includes link-management, rate limiting, and session cleanup. Relationships for unsampled route handlers rely on the SOURCE INDEX; the README is empty, so undocumented capabilities and connections are omitted.
Main entry points: database.py Database access · create.py Link creation · auth Auth handlers · auth.py Session authentication
Components 24
API entry and routes
- FastAPI app
app/main.py - Authentication routes
app/routes/auth - Link management routes
app/routes/links - Redirect routes
app/routes/redirects
Identity and access
- Session authentication
app/dependencies/auth.py - Creation rate limit
app/dependencies/rate_limit.py - Auth handlers
app/routes/auth - Login sessions
app/models/session.py - Users
app/models/user.py - Session cleanup
app/scripts/cleanup_sessions.py
Link lifecycle
- Link creation
app/routes/links/create.py - Link management
app/routes/links - Redirect resolution
app/services/link_redirect.py - Short links
app/models/link.py - Request and response schemas
app/schemas/all_schemas.py
Services and persistence
- Token and password utilities
app/services/all_services.py - Link cache
app/services/link_cache.py - Rate limiter
app/services/rate_limiter.py - Database access
app/database/database.py - PostgreSQL
- Redis client
app/database/redis_client.py - Redis
- Runtime configuration
app/config.py
Other components
- Visitor or user
Connections 39
- Visitor or user → FastAPI app: sends requests
app/main.py - FastAPI app → Link management routes: mounts
app/main.py - FastAPI app → Authentication routes: mounts
app/main.py - FastAPI app → Redirect routes: mounts
app/main.py - Authentication routes → Auth handlers: routes to
app/routes/auth/__init__.py - Link management routes → Link creation: routes to
app/routes/links/__init__.py - Redirect routes → Redirect resolution: resolves with
app/routes/redirects/short_code.py - Auth handlers → Database access: queries
app/routes/auth/login.py - Auth handlers → Token and password utilities: uses
app/routes/auth/login.py - Auth handlers → Request and response schemas: validates with
app/routes/auth/login.py - Auth handlers → Login sessions: creates sessions
app/routes/auth/login.py - Auth handlers → Users: queries users
app/routes/auth/login.py - Session authentication → Database access: queries
app/dependencies/auth.py - Session authentication → Token and password utilities: hashes tokens
app/dependencies/auth.py - Session authentication → Login sessions: checks sessions
app/dependencies/auth.py - Session authentication → Users: loads user
app/dependencies/auth.py - Link creation → Session authentication: checks user
app/routes/links/create.py - Link creation → Creation rate limit: requires limit
app/routes/links/create.py - Link creation → Database access: persists link
app/routes/links/create.py - Link creation → Token and password utilities: generates code
app/routes/links/create.py - Link creation → Request and response schemas: uses schemas
app/routes/links/create.py - Link creation → Short links: creates record
app/routes/links/create.py - Link management → Database access: queries links
app/routes/links/list.py - Link management → Session authentication: checks access
app/routes/links/delete.py - Link management → Short links: reads or deletes
app/routes/links/detail.py - Link management → Link cache: invalidates cache
app/routes/links/delete.py - Redirect resolution → Link cache: checks and fills
app/services/link_redirect.py - Redirect resolution → Database access: queries and counts
app/services/link_redirect.py - Redirect resolution → Short links: loads link
app/services/link_redirect.py - Redirect resolution → Users: joins owner
app/services/link_redirect.py - Creation rate limit → Rate limiter: applies limit
app/dependencies/rate_limit.py - Database access → PostgreSQL: opens connection
app/database/database.py - Link cache → Redis client: uses client
app/services/link_cache.py - Rate limiter → Redis client: uses client
app/services/rate_limiter.py - Redis client → Redis: connects to
app/database/redis_client.py - Database access → Runtime configuration: reads URL
app/database/database.py - Redis client → Runtime configuration: reads URL
app/database/redis_client.py - Session cleanup → Database access: uses database
app/scripts/cleanup_sessions.py - Session cleanup → Login sessions: cleans sessions
app/scripts/cleanup_sessions.py