A modern, full-stack URL shortener application built with Next.js and NestJS, featuring user authentication, analytics, and a clean, responsive interface.
- URL Shortening: Create short, shareable links from long URLs
- User Authentication: Secure sign-up and sign-in functionality
- Analytics Dashboard: Track click statistics with interactive charts
- Date Range Filtering: Analyze URL performance over custom time periods
- Responsive Design: Works seamlessly on desktop and mobile devices
- Copy to Clipboard: One-click copying of shortened URLs
- Real-time Statistics: Live tracking of URL clicks and engagement
This is a monorepo application built with modern technologies and best practices:
- Framework: Next.js 15 with App Router
- Language: TypeScript
- UI Library: React 19 with Radix UI components
- Styling: TailwindCSS v4
- Forms: React Hook Form with Zod validation
- Charts: Recharts for analytics visualization
- Authentication: JWT with Jose library
- Date Handling: date-fns and React Day Picker
- Framework: NestJS with TypeScript
- Architecture: Domain-Driven Design (DDD) with CQRS pattern
- Database: PostgreSQL with Prisma ORM
- Caching: Redis with ioredis
- Authentication: JWT with Passport.js strategies
- Password Hashing: Argon2
- Job Queue: BullMQ for background processing
- Testing: Jest with comprehensive test coverage
- Containerization: Docker Compose for local development
- Database: PostgreSQL with persistent volumes
- Cache: Redis with persistent storage
- Monorepo: Turborepo for efficient builds and development
- Package Manager: npm with workspaces
| Category | Technologies |
|---|---|
| Frontend | Next.js, React, TypeScript, TailwindCSS |
| Backend | NestJS, TypeScript, Prisma, PostgreSQL |
| Caching | Redis, BullMQ |
| UI/UX | Radix UI, Lucide Icons, Recharts |
| Authentication | JWT, Passport.js, Argon2 |
| Development | Turborepo, ESLint, Prettier |
| Infrastructure | Docker, Docker Compose |
- Node.js >= 18
- npm >= 11.5.1
- Docker and Docker Compose
-
Clone the repository
git clone <repository-url> cd link-shortener-app
-
Install dependencies
npm install
-
Start the infrastructure services
docker-compose up -d
-
Setup the database
cd apps/api npm run db:migrate -
Start the development servers
# From the root directory npm run dev
This will start:
- Web app on
http://localhost:3000 - API server on
http://localhost:3003 - PostgreSQL on
localhost:5432 - Redis on
localhost:6379
- Sign Up/Sign In: Create an account or log in to access the dashboard
- Shorten URLs: Enter a long URL to generate a short, shareable link
- View Analytics: Track clicks, view statistics, and analyze performance
- Manage URLs: View all your shortened URLs in one place
- Copy Links: Use the copy-to-clipboard feature for easy sharing
# Development
npm run dev # Start all apps in development mode
npm run build # Build all apps for production
npm run lint # Lint all code
npm run format # Format code with Prettier
# Database operations (from apps/api)
npm run db:migrate # Run database migrations
npm run db:studio # Open Prisma Studio
# Testing (from apps/api)
npm run test # Run unit tests
npm run test:e2e # Run end-to-end tests
npm run test:cov # Run tests with coveragelink-shortener-app/
├── apps/
│ ├── web/ # Next.js frontend application
│ │ ├── src/
│ │ │ ├── app/ # Next.js App Router pages
│ │ │ ├── features/ # Feature-based modules
│ │ │ └── components/ # Reusable UI components
│ │ └── package.json
│ └── api/ # NestJS backend application
│ ├── src/
│ │ ├── gateway/ # API controllers
│ │ ├── shortener/ # URL shortening domain
│ │ ├── analytics/ # Analytics domain
│ │ └── auth/ # Authentication domain
│ └── package.json
├── docker-compose.yml # Infrastructure services
├── turbo.json # Turborepo configuration
└── package.json # Root package configuration
- Domain-Driven Design: Business logic organized into domains
- CQRS Pattern: Separate command and query handling
- Feature-Based Structure: Frontend organized by features
- Clean Architecture: Clear separation of concerns
- Migrations: Use Prisma migrations for schema changes
- Seeding: Populate database with initial data
- Studio: Visual database browser with Prisma Studio
- TypeScript: Full type safety across the stack
- ESLint: Code linting with consistent rules
- Prettier: Automated code formatting
- Password Hashing: Argon2 for secure password storage
- JWT Authentication: Stateless authentication with secure tokens
- Input Validation: Comprehensive validation with Zod schemas
- SQL Injection Protection: Prisma ORM with prepared statements
- Rate Limiting: Built-in protection against abuse
- Caching: Redis for fast URL lookups
- Background Jobs: BullMQ for processing analytics
- Database Optimization: Indexed queries and efficient schemas
- Frontend Optimization: Next.js optimizations and code splitting
This project is licensed under the UNLICENSED license.
Built with ❤️ using modern web technologies and best practices.