Simple, maintainable backend for shortening links and tracking clicks.
- Node.js & Express: Core server framework.
- MongoDB: Database for users, URLs, and analytics.
- EJS: Server-side rendering (keeps the frontend simple).
- Auth: Custom in-memory session management.
- Architecture: Standard MVC pattern (Models, Views, Controllers).
- Authentication:
- Uses
service/auth.jsto map session IDs to users. - Note: This is in-memory only. Restarting the server wipes active sessions.
- Scaling: If we scale to multiple instances, we'll need to move this state to Redis.
- Uses
- Database: Ensure a local MongoDB instance is running.
- Install:
npm install
- Run:
npm start
- Access: Server runs on port
8001by default.