TinyTrace

TinyURL

Table of Contents

Design

General Architecture Diagram

Diagram

Java Spring boot (Backend) Architecture Diagram

Spring Boot Security backend-security

React (Frontend) Architecture Diagram

react-component-diagram Context diagrams These diagrams are based on the idea of State Diagrams

front-end-auth-context-diagram front-end-url-context-diagram front-end-page-context-diagram

API Design

Public Endpoints

Authenticated Endpoints

Database Schema

I chose a NoSql design because of the high read-write requests that will be expected of the application. The only purpose of using a relational database for this application is the consideration of race-conditions where 2 users decide to shorten a longUrl with the shortening algorithm generating a similar shortUrlId (In the case of a distributed environment), the use of a relational database will be able to ensure consistency of data. However in a NoSql database this isn’t the case and could cause an issue. A point in consideration is to seperate the shortener service to a microservice that has its own independent relational database to generate the shortUrlIds.

er-diagram

Shortening Algorithm

I chose to use a simple random generator for the shortUrlId with a backoff algorithm that will sent out an error just in case it took too long to generate a random shortUrlId.

I did not use a base conversion technique. While it make ensure uniqueness in the generation of the shortUrlId, the generation is in linear order and could be predictable. I didn’t use a hashing algorithm because of the possibility of a collision that could happen, while it is unlikely.

Structure

Error Handling

I chose to use @ControllerAdvice global exception handling instead of using ResponseStatusExcepion handling because I don’t want to fill my controllers with many try-catch blocks and I still find myself needing to create exception classes to handle different errors. ResponseStatusException goal was to try to fix this, but this is mainly for the same exception type but providing the flexibility of sending different status error code which doesn’t fit in my user.

Requirements

User Stories

Non-Functional Requirements

Resources