Convert long urls into short urls. With added backend complexity for a production-ready build.
-
Choose a custom path name for the short url, i.e. 127.0.0.1/mypathname
-
Measure the amount of times a short url was used
- The original url and the short url with custom path is stored as a row in the database.
- When the short url is entered into the browser, the backend api will lookup the corresponding original url and perform a redirect.
- The backend api will also increment the click count for a short url whenever it is used.
This app uses 6 services:
- Frontend - Javascript with React (create-react-app) for front-end UI.
- Backend - Python with Django for back-end API.
- Database - PostgreSQL to store the url pairs and click count.
- Cache - Memcached to cache url pairs for faster redirects.
- Message Queue - RabbitMQ to asynchronously increment click count in database.
- Reverse Proxy - Nginx to serve the application.
The app is packaged into a docker compose container for easy startup and deployment.
- Install docker compose
- Clone this repository
git clone https://github.com/colin-ho/URL-Shortener.git
- Run
docker-compose -f docker-compose-dev.yml up
- Open the app at http://localhost:3000/
This web app has been configured for easy AWS ECS deployment using AWS Fargate. This step requires an AWS account and IAM permissions. More info here
- Create a docker compose ecs context
docker context create ecs myecscontext docker context use myecscontext
- Run
docker compose -f docker-compose-prod.yml up
- Check the application url with
docker-compose -f docker-compose-prod.yml ps