Challenge Overview

Project Overview:

The client would like to build a web application that helps them compare the configs for network devices against a baseline config that can be either on another network path or in Github.

The comparison will be just a diff of the two files and will be displayed in the web app with some additional searching and filtering functionality.

Challenge Overview:

This challenge will build a backend REST service that can accept a file upload of both a source and target file for comparison.  The response will be an object that allows the caller (the frontend UI) to display the diffs properly.

Technology:

We will target the latest version of Node for the REST services.  Note that you are free to use any MIT or BSD licensed npm modules that could help with the requirements here.  There are a number of different "diff" modules that can be evaluated and potentially used, including:

Requirements:

Request

The request to the endpoint of the REST API for diffing two files will be a POST containing:
  • Both files for comparison
  • Optional filter options (detailed below)

Response

The response should include the necessary information for displaying the diff between the two files, including:
  • Each line from each of the two files
    •  An indication if a line is in the source but not the target
    •  An indication if a line is in the target but not the source
    •  An indication of any diffs inside of a given line between the source and target, if they both contain a given line
Filter out

The user will be able to provide a list of strings to filter out of the diff.  When the user selects to exclude a particular string; the displayed values are refreshed and any lines containing that string are no longer visible.  We need to support a list of filter out strings in the request, and any line that does contain a string from the filter out list will be removed from the response.

Filter in

Similar to the list of strings to filter out, the user can also provide a list of strings to filter in, meaning that any line that doesn't contain a string from the filter in list will be removed from the response.

Filtering

Ideally, the frontend wouldn't have to re-upload the files when changing filter options, since that's a lot of unnecessary overhead.  One option would be to save the files on the server and return a comparison "token" that can then be used to reference those files when changing filter options / recomparing.

File format

A sample XML file will be provided in the forum, but please ensure that the solution is generally extensible.  Some of the network configs will be JSON or YAML or other file formats, so we can't target a specific format.  Note that we expect the files could be potentially large, like the sample, so we need the endpoint to respond quickly with the diff results (less than 20 seconds)

Swagger

Please include a Swagger describing the API you implement.  Note that this hasn't been explicitly specified, so you are free to choose how you think the API should work, but please make sure it's easy to use with the sample UI (provided in the forum)

Postman

Please include a Postman export of sample calls to the API.  We'll use this in review and for integrating with the user interface, once that has been defined more formally.

Unit tests

Please provide unit tests for the REST API for further validation, to ensure that the diffs are processed and returned properly.  Please ensure that each file in the solution has at least 90% coverage.

UI

For reference, the UI will include these requirements, so please use this to guide the design of the request and response:
  1. Diff / Compare screen - the two files are shown side by side with the filter applied.
    1. two files will be shown with diffs highlighted similar to GitHub/gitlab do it
    2. in the menu, they will be able to enter a string that the can search the filtered files with. once they enter the value and hit next, it will highlight the next instance of that string from wherever the cursor is and the options to find the "next" or "prev" will be available in the menu (can be done on the frontend)
A sample mockup will be provided in the forum.

Scoring guidelines


Major requirements:
  • REST API is implemented and meets the requirements
  • Swagger file is included and well documented
  • Code passes eslint
Minor requirements:
  • Internal code documentation is clear and complete
  • Unit tests cover the API properly and coverage report are included
Submission must include
  • Backend source code
  • README.md covering the environment requirements, deployment, and how the tests are run
  • Validation.md covering how to validate each of the individual requests and generate the coverage report.
  • Swagger file


 

Final Submission Guidelines

Please see above

ELIGIBLE EVENTS:

2020 Topcoder(R) Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30130982