How onlyarchanos/url-shortener works
This is a local URL-shortening product with both a command-line interface and a Flask API. Users create links with generated Base62 codes or custom aliases, then resolve, list, inspect, or delete them. The API adds accounts and API-key authentication, expiry, rate limiting, per-link statistics, and an analytics page. Shared URL, account, and persistence logic lives in database.py. The excerpts show direct calls between the entry points and that shared logic; some endpoint details are documented only in the README.
Main entry points: database.py SQLite database · main.py CLI commands · app.py Shorten endpoint
Components 18
User interfaces
- CLI commands
main.py
Web API
- Flask routes
app.py - Rate limiter
app.py - Registration and login
app.py - Shorten endpoint
app.py - Redirect endpoint
app.py - Stats and deletion
app.py - Analytics page
app.py
Shared domain logic
- URL and alias validation
database.py - Base62 code generation
database.py - URL record operations
database.py - Expiry checks
database.py - Account and API keys
database.py - Click tracking
database.py - Top-link query
database.py
Persistence
- SQLite database
database.py
Other components
- CLI user
- API client
Connections 22
- CLI user → CLI commands: runs commands
README.md - API client → Flask routes: sends requests
README.md - CLI commands → URL and alias validation: validates links
main.py - CLI commands → Base62 code generation: gets code
main.py - CLI commands → URL record operations: manages links
main.py - Flask routes → Rate limiter: checks limits
app.py - Registration and login → Account and API keys: registers and authenticates
app.py - Shorten endpoint → URL and alias validation: validates input
app.py - Shorten endpoint → Base62 code generation: gets code
app.py - Shorten endpoint → URL record operations: saves link
app.py - Redirect endpoint → URL record operations: looks up link
app.py - Redirect endpoint → Expiry checks: checks expiry
app.py - Stats and deletion → Account and API keys: authenticates user
app.py - Stats and deletion → URL record operations: reads and deletes
app.py - Analytics page → Account and API keys: authenticates user
app.py - Analytics page → Top-link query: requests top links
app.py - URL and alias validation → SQLite database: checks aliases
database.py - Base62 code generation → SQLite database: updates counter
database.py - URL record operations → SQLite database: reads and writes
database.py - Account and API keys → SQLite database: reads and writes
database.py - Click tracking → SQLite database: updates clicks
database.py - Top-link query → SQLite database: queries links
database.py