# Design Pastebin.com

## Use case and requirements

- `User` enters a block of text and gets a randomly generated `shortlink`
- `User` enters a paste's url and views the contents

### SQL `paste` table schema

```
shortlink char(7) NOT NULL
created_at datetime NOT NULL
paste_path varchar(255) NOT NULL
PRIMARY KEY(shortlink)
```

### `Write` API

```bash
// Write API Request
curl -X POST https://pastebin.com/api/v1/paste \
--data '{"paste_contents": "Hello world!"}'

// Write API Response
{
   "shortlink": "random_string"
}
```

### `Read` API

```bash
// Read API Request
curl https://pastebin.com/api/v1/paste?shortlink=random_string

// Read API Response
{
   "paste_contents": "Hello world!"
   "create_at": "YYYY-MM-DD HH:MM:SS"
}
```

*Based on Donne Martin's [System Design Primer](https://github.com/donnemartin/system-design-primer)*
