Skip to content

Commit 9e9d34e

Browse files
committed
Add project documentation
1 parent 136c3b4 commit 9e9d34e

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Tiny URL Like Application
2+
3+
![Tiny URL Like Application](docs/tiny-url-application.png)
4+
5+
Why do we need in a first place a URL shortener such as [Tiny url](http://tinyurl.com) ? Simply put, it allows us to
6+
shorten long URLs and make message more concise and also save a lot of space when used in social media like tweeter
7+
where messages are constrained in terms of size. When a user hit the shortened url it is redirected to the original URL.
8+
9+
However, behind this simplicity, lies many technical challenges. For example:
10+
* How do we generate a short URL?
11+
* How do we ensure that short URL that is unique and does not collide with other URLs ?
12+
* How do we store the mapping between the short URL and the original URL ?
13+
* How do we handle high traffic and ensure that the service is scalable ?
14+
15+
This repository contains a simple implementation of a URL shortener service. It is not meant to be a production-ready
16+
service, but rather a proof of concept to demonstrate the basic functionality of a URL shortener. In addition, a system
17+
design document is provided to explain the design choices made in the implementation.
18+
19+
Happy learning !
20+
21+
# Table of contents
22+
23+
* [How to run the application locally](docs/how-to-build-run-the-app-locally.md)
24+
* [System design](docs/system-design.md)
25+
* [References](docs/references.md)
26+
* Ensure interoperability between backend and frontend: consumer driven contract testing
27+
* References
28+
29+
30+
31+
32+
33+
34+
35+
# How to run the application
36+
37+
# System design
38+
39+
# References
40+
41+
* [System Design : Scalable URL shortener service like TinyURL](https://medium.com/@sandeep4.verma/system-design-scalable-url-shortener-service-like-tinyurl-106f30f23a82)
42+
*
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# 🛠 Prerequisites
2+
3+
* Node v18.18+
4+
* Docker v27+
5+
* Yarn or Npm
6+
7+
# 🔨 Build & Test
8+
9+
You can build and test the application manually by following the instructions below, or refer to the CI pipeline defined
10+
in `.github/workflows/ci.yaml` for automated testing.
11+
12+
## WebApp
13+
14+
```bash
15+
cd webapp
16+
cp .env-dev .env
17+
yarn install
18+
yarn test
19+
```
20+
21+
## API server
22+
* CD to the `api` directory
23+
* Open a terminal and run the following command to install dependencies:
24+
```bash
25+
cd api
26+
cp .env-dev .env
27+
yarn install
28+
yarn test
29+
```
30+
31+
# 🚀 Running the App
32+
33+
## Option 1: Run Everything via Docker Compose
34+
The fastest way to launch the entire stack (API, WebApp, Redis, DynamoDB, RedisInsight) is with Docker Compose.
35+
```bash
36+
docker compose -f docker-compose.yml up -d --build
37+
```
38+
This builds and starts all services defined in the docker-compose.yml.
39+
40+
## Option 2: Run Infrastructure with Docker + App Locally from Your IDE or Terminal
41+
42+
### Step 1: Start Infrastructure Only
43+
44+
```bash
45+
docker compose up -d redis redisinsight dynamodb dynamodb-init
46+
```
47+
ℹ️ Optional: Use In-Memory Mode for Fast Testing
48+
You can run the API server in in-memory mode (without Redis or DynamoDB) by setting the following environment variable
49+
in your .env file:
50+
```
51+
USE_PERSISTENT_STORAGE=false
52+
```
53+
### Step 2: Run WebApp Locally
54+
```bash
55+
cd webapp
56+
cp .env-dev .env
57+
yarn start:dev
58+
```
59+
### Step 3: Run API Server Locally
60+
```bash
61+
cd api
62+
cp .env-dev .env
63+
yarn start:dev
64+
```

docs/references.md

Whitespace-only changes.

docs/system-design.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# System Design

docs/tiny-url-application.png

59 KB
Loading

0 commit comments

Comments
 (0)