How alexwithstars/shortlink works
This is a URL-shortening service with a browser-based link administration UI. The main workflow is to submit and validate a link, create or edit it through the API, persist it through the configured model, and redirect visitors through its alias while recording clicks. The API also exposes link lists, aliases, individual links, and click counts. MongoDB is shown from sampled implementation; Firebase exists in the tree, but its runtime wiring was not verified. The README is empty, so feature coverage relies on the source index and excerpts.
Main entry points: index.js Express server · routes/shortener.js API routes · mongodb/shortener.js Mongo link model · controllers/shortener.js Link controller
Components 19
HTTP service
- Express server
src/index.js - API routes
src/routes/shortener.js - Development tracking
src/middlewares/development.js
Link operations
- Link controller
src/controllers/shortener.js - Request validation
src/middlewares/shortener.js - Link schema
src/schemas/links.js
Persistence
- Mongo link model
src/models/mongodb/shortener.js - Mongo link schema
src/models/mongodb/models.js - MongoDB
- Firebase model
src/models/firebase/shortener.js
Admin interface
- Admin UI
src/view/main.js - Browser API client
src/view/apis/links.js - Admin page assets
src/view/index.html
Shared support
- Validation errors
src/schemas/all.js - API responses
src/utils/reponse.js - Debug diagnostics
src/debug.js - Routes and config
src/utils/consts.js
Other components
- Link visitor
- Admin user
Connections 20
- Link visitor → Express server: requests
src/index.js - Admin user → Admin UI: manages links
src/view/main.js - Express server → API routes: mounts router
src/index.js - Express server → Development tracking: uses in development
src/index.js - Express server → Debug diagnostics: runs when enabled
src/index.js - Express server → Mongo link model: selects configured model
- Express server → Firebase model: may select model
- API routes → Link controller: dispatches handlers
src/routes/shortener.js - API routes → Request validation: validates mutations
src/routes/shortener.js - Request validation → Link schema: validates payload
src/middlewares/shortener.js - Request validation → Validation errors: formats errors
src/middlewares/shortener.js - API routes → API responses: returns auth errors
src/routes/shortener.js - Link controller → Mongo link model: performs link operations
- Mongo link model → Mongo link schema: uses Link model
src/models/mongodb/shortener.js - Mongo link model → MongoDB: reads and writes
src/models/mongodb/shortener.js - Admin UI → Browser API client: calls
src/view/main.js - Browser API client → API routes: sends HTTP requests
src/view/apis/links.js - Express server → Admin page assets: serves static UI
src/index.js - Express server → Routes and config: reads configuration
src/index.js - Link controller → API responses: returns link errors
src/controllers/shortener.js