How pratyushmjm/url-shortner works
This is an Express URL-shortening service. A client submits a long URL; the route delegates to a controller that generates an ID and stores the mapping. A request to that ID records a visit and redirects to the saved URL; analytics returns the recorded visits and click count. MongoDB holds URL records, and Nano ID supplies short IDs. The graph reflects the supplied source; it does not imply behavior beyond the documented features and sampled implementation.
Main entry points: index.js Express app · controller/url.js URL controller · models/url.js URL model · routes/url.js URL routes
Components 8
HTTP interface
- Express app
urlshortener/index.js - URL routes
urlshortener/routes/url.js
Shortening and analytics
- URL controller
urlshortener/controller/url.js - Nano ID
Persistence
- URL model
urlshortener/models/url.js - Mongo connector
urlshortener/connect.js - MongoDB
Other components
- API client
Connections 12
- API client → Express app: sends requests
- Express app → URL routes: mounts at /url
- URL routes → URL controller: delegates POST
- URL controller → Nano ID: generates ID
- URL controller → URL model: creates mapping
- Express app → URL model: records visit
- Express app → URL controller: requests analytics
- URL controller → URL model: reads analytics
- Express app → Mongo connector: connects to database
- URL model → MongoDB: reads and writes
- Mongo connector → MongoDB: establishes connection
- Express app → API client: redirects or returns analytics