A scalable URL shortener service built with TypeScript and Clean Architecture principles.
- Create shortened URLs
- Custom alias support (up to 16 characters)
- Click tracking and analytics
- RESTful API with Swagger documentation
- In-memory SQLite database
- Clean Architecture implementation
- CQRS pattern
- Comprehensive test coverage
The project follows Clean Architecture principles with the following layers:
- Core: Contains entities and repository interfaces
- Application: Implements use cases (commands and queries)
- Infrastructure: Contains concrete implementations (database, external services)
- API: Handles HTTP routes and controllers
POST /api/urls
: Create a new shortened URLGET /:shortCode
: Redirect to original URLGET /api/urls/most-clicked
: Get most clicked URLs
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
View API documentation: Open http://localhost:3000/documentation
Run the test suite:
npm test
- Clean Architecture: Ensures separation of concerns and maintainability
- CQRS Pattern: Separates read and write operations
- In-memory SQLite: Fast and reliable for development/testing
- Fastify: High-performance web framework
- Zod: Runtime validation for request payloads
- nanoid: Generates unique, URL-safe identifiers
- In-memory database for fast access
- Efficient URL lookup using indexes
- Minimal dependencies
- Request validation at the edge