How damodarpurohit29/url_shortener works
This is a FastAPI URL-shortening service. A client submits a target URL and optional custom code or expiry; the API validates the request, generates a code when needed, and stores the mapping. A later code request checks the mapping and expiry, updates visit statistics, and redirects the client. A separate stats route returns mapping and visit details. Source excerpts show the API and ORM behavior; the README is empty, and no separate analytics or background-processing subsystem is evident.
Main entry points: url_api.py URL Routes · main.py FastAPI App · session.py DB Session · url_model.py URL ORM Model
Components 9
HTTP API
- FastAPI App
main.py - URL Routes
api/url_api.py - Request and Response Schemas
schemas/url_schema.py
Shortening Logic
- Code Generator
utils.py
Persistence
- URL ORM Model
models/url_model.py - DB Session
db/session.py - URL Store
Other components
- Client
- Target Website
Connections 9
- Client → FastAPI App: sends HTTP requests
- FastAPI App → URL Routes: dispatches routes
- URL Routes → Request and Response Schemas: validates and serializes
- URL Routes → Code Generator: generates code
- URL Routes → DB Session: gets DB session
- URL Routes → URL Store: reads and writes mappings
- URL ORM Model → URL Store: maps URL records
- DB Session → URL Store: creates DB connection
- URL Routes → Target Website: redirects client