- URL encoding: Convert long URLs into short ones
- URL decoding: Retrieves original URLs from shortened versions
- Input validation: Ensures URLs are valid and properly formatted
- In-memory storage: Stores URL mappings temporarily
- RESTful API: JSON-based endpoints
- Tests: Full test coverage
- SOLID Principles: The codebase adheres to SOLID principles for maintainability and extensibility
- Single Responsibility: Each class has a clear, focused purpose
- Open/Closed: The service is open for extension but closed for modification
- Liskov Substitution: Interfaces ensure consistent behaviour across implementations
- Interface Segregation: Focused interfaces for specific responsibilities
- Dependency Inversion: High-level modules depend on abstractions, not concretions
- Clean Architecture: Separation of concerns through controllers, services, and contracts
- Validation: Dedicated request class for consistent input validation
- API Responses: Standardised JSON responses with appropriate HTTP status codes
- Testing: Comprehensive test coverage using PHPUnit
-
Clone the repository:
git clone https://github.com/cjmellor/atarim-tech-test.git cd atarim-tech-test
-
Install dependencies:
composer install
-
Copy the environment file:
cp .env.example .env
-
Generate application key:
php artisan key:generate
-
Configure the base URL in
.env
(can be anything):URLSHORTENER_BASE_URL=http://short.est/
-
Run the development server:
php artisan serve
POST /api/encode
Request:
{
"url": "https://www.example.com/some/long/path"
}
Response:
{
"short_url": "http://short.est/abc123"
}
POST /api/decode
Request:
{
"url": "http://short.est/abc123"
}
Response:
{
"original_url": "https://www.example.com/some/long/path"
}
To run the test suite:
./vendor/bin/phpunit
(I used an LLM to make this more presentable)