Coder Social home page Coder Social logo

url-shortener's Introduction

URL-shortener

Ozon fintech internship task.

URL-shortener is a service for creating shortened links and getting their original reference.

Table of Contents

Architecture

The project can be divided into 3 main components:

  • gRPC server - main component of the service. It is a web application that provides a gRPC API for shortening links and getting their original references.
  • Database - there are two options: in-memory storage and on disk. In-memory storage is implemented using Redis when as disk storage is implemented using PostgreSQL
  • HTTP proxy server - gRPC Gateway implementation. It is provides a REST API for interacting with the gRPC server

Architecture of the system

URL encoding algorithm

The basic principle is as follows - the transition from a number system based on 10 to a number system based on 63. Collisions are handled by shuffling the base alphabet in random order. The number that is encoded is a randomly generated value.

Deployment

All components are dockerized and can be deployed using docker compose.

Deploy with PostgreSQL database

docker compose -f docker-compose-postgres.yaml up

Deploy with Redis database

docker compose -f docker-compose-redis.yaml up

Documentation

gRPC only

You can see a protobuf file right here.

With gRPC Gateway

Here service has two endpoints:

For getting original URL:

Endpoint

/v1/url/{shortUrl}

shortUrl - is a given earlier shortened URL

For posting original URL and getting a short one:

Endpoint:

/v1/url

Request body:

{
  "longUrl": "http://localhost:8080/test_url"
}

Response body:

{
  "shortUrl": "{shortUrl}"
}

Also, service provides a swagger documentation. You can download it here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.