Longless is a full-stack URL shortening service built with Node.js and Express. It allows users to create shortened URLs, track clicks, and manage their links through a personalized dashboard.
- Features
- Technologies Used
- Database Schema
- Project Structure
- Installation & Setup
- Logging System
- Credits
- User Authentication: Secure registration and login with bcrypt password hashing
- URL Shortening: Generate short, unique alphanumeric codes for long URLs
- Click Analytics: Track every click with timestamp, IP address and user agent
- User Dashboard: View all your links, clicks statistics, and manage your URLs
- Link Management: Copy links to clipboard and delete unwanted URLs
- Responsive Design: Clean, modern interface built with Tailwind CSS
- Production logging for monitoring and debugging
- Node.js & Express.js: Server and routing
- SQLite (better-sqlite3): Lightweight database with synchronous API
- bcrypt.js: Password hashing for security
- express-session: Session management
- EJS: Server-side templating
- Tailwind CSS: Utility-first CSS framework
- Vanilla Javascript: Interactive features (copy to clipboard)
id: Primary keyusername: Unique usernameemail: Unique emailhash: Bcrypt hashed passwordcreated_at: Registration timestamp
id: Primary keyuser_id: Foreign key to usersshort_code: Unique short code (e.g., "abc123")original_url: The original long URLcreated_at: Creation timestamptitle: Optional link title
id: Primary keyurl_id: Foreign key to urls (CASCADE on delete)clicked_at: Click timestampip_address: Visitor IPuser_agent: Browser/device info
longless/
├── config/
│ ├── database.js # SQLite connection and schema
│ └── dbHelpers.js # Database query functions
├── middleware/
│ ├── auth.js # requireAuth, requireGuest
│ ├── render.js # Custom render wrapper
│ └── notFound.js # 404 handler
├── routes/
│ ├── auth.js # Login, register, logout
│ ├── links.js # Link CRUD operations
│ └── redirect.js # Short code redirect
├── utils/
│ └── helpers.js # generateShortCode, isValidUrl
├── views/
│ ├── layouts/
│ │ └── main.ejs # Base layout
│ ├── index.ejs # Landing page
│ ├── login.ejs # Login page
│ ├── register.ejs # Registration page
│ ├── dashboard.ejs # User dashboard
│ ├── notFound.ejs # Not found page
│ └── error.ejs # Error page
├── public/
│ └── (static assets)
├── app.js # Main application file
├── package.json
└── .env # Environment variables
1.Clone the repository
git clone https://github.com/omaresaa/longless.git
cd longless2.Install dependencies
npm i3.Set up environment variables
cp .env.example .env
# Edit .env and add your SESSION_SECRET4.Run the application
npm run dev5.Open in browser
http://localhost:3000
The application includes comprehensive structured logging for monitoring and debugging:
- Structured JSON Format: Easy to parse and analyze
- Multiple Log Levels: INFO, WARN, DEBUG, ERROR
- Separate Error Logs: Quick access to failures
- Contextual Meta Data: User IDs, timestamps, request details
- Development Console: Colored output for easier local debugging
log/app.log- All application logslog/error.log- Error-level log only
- User registration and authentication
- Link creation and deletion
- Failed login attempts (security monitoring)
- Short link redirects and clicks
- Application errors with full stack traces
- Invalid URL attempts
- HTTP Requests
Example log entry:
{
"timestamp": "2025-12-18T15:30:45.123Z",
"level": "INFO",
"message": "Link created",
"userId": 5,
"shortCode": "abc123",
"originalUrl": "https://github.com"
}Created by Omar Esa for CS50x Final Project.
