Git Product home page Git Product logo

pravelin's Introduction

Pravelin Code Test

This project is an implementation of Golang HTTP server that will accept POST requests from multiple clients' websites

Technologies Used

  • Go 1.19
  • Limited to Go standard library as per the problem statement

Assumptions and Limitations

  • Session ID is not validated if it is a UUID. Validation only checks if it is a non-empty string. This is done as regex validation on UUID is slower and other validations require importing external libraries
  • At every stage of Event struct construction, printing is done to stdout
  • Assumed that Submit event (timeTaken event) is the final event for a session. Validation is enforced to prevent further events on the same session ID
  • Changed the API URL from / to /api/v1/events to adhere to REST standards. HTML is also edited to use this API
  • Swagger doc is not added as we have only a single endpoint. Also, it requires adding a library
  • No database is used to keep it simple as per the given problem. All the storage is done in a map with concurrency handled.
  • For copyAndPaste event, formId is limited to inputEmail, inputCardNumber, inputCVV by referring to the given HTML. Ideally, these should have been added to a properties file and read in to the application. But for simplicity, these values are hardcoded
  • For screenResize event, only the recent resizeFrom and resizeTo are saved in the struct.
  • Given HTML page has a checkbox for "Agree to Terms". This is not handled anywhere in the code as it is not used in the API requests.
  • Since it is my first Go project, there are high chances for mistakes in concurrency handling and coding standards. Best practices haven't been followed but tried my best to write bug free code

Future Improvements

  • Validations for inputs and struct constructions can be handled by an external library
  • Swagger documentation could be added for APIs
  • Right now, the code coverage is 91%. In the future, it can be improved to 95% or more
  • Containerization of deployment can be done

To Build

Dependencies:

  • Go 1.19

To Run

Server

  • Switch to project directory in a terminal
  • Run the command go run main.go
  • Alternatively, run go build. This will generate an executable binary. Now run ./pravelin

Client

  • Open the HTML or call the API POST /api/v1/events

API

{
  "eventType": "copyAndPaste",
  "websiteUrl": "https://ravelin.com",
  "sessionId": "123123-123123-123123123",
  "pasted": true,
  "formId": "inputCardNumber"
}

{
  "eventType": "screenResize",
  "websiteUrl": "https://ravelin.com",
  "sessionId": "123123-123123-123123123",
  "resizeFrom": {
    "width": "1920",
    "height": "1080"
  },
  "resizeTo": {
    "width": "1280",
    "height": "720"
  }
}

{
  "eventType": "timeTaken",
  "websiteUrl": "https://ravelin.com",
  "sessionId": "123123-123123-123123123",
  "timeTaken": 72,
}

Architecture

Architecture

Quality

  • Well covered test cases with 91% coverage
  • Load tested with ApacheBench to check if multiple concurrent requests from multiple sessions are working

CodeCoverage BenchMark1 BenchMark2

pravelin's People

Contributors

praveen-erramilli avatar

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.