Muljayan / dotnet-flexible-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dotnet Flexible API Challenge

The purpose of this challenge is to take a quick dive into the following:

  1. Your understanding and knowledge of SOLID principles, naming conventions, and design patterns
  2. Your thoughts and views on extensibility and maintainability of a solution
  3. Your knowledge on providing end-to-end solutions

The Challenge

The challenge is to create a simple web service as an API. The application should be written in ASP.NET Core 7 (C#) and using a SQL Server database as the datastore.

1. Creating API Endpoints

  1. Create an endpoint in the first API, that accepts a payload of a JSON object with the following structure:

     {
         "Data": "dictionary of key-value pairs"
     }
    
    • The keys and the values both should be strings

    • The endpoint should be in the following format:

        POST /flexibledata/create
      
    • The endpoint should store the data in a SQL Server database. The database should have "FlexibleData" table that has the following structure:

        ID (unique identifier)
        Data (string) - Serialized JSON object
      
    • The ID should be generated by the API. The endpoint should return the created data object with a 200 OK response, if the data was successfully stored in the database.

  2. Create an endpoint to retrieve one or more data objects from the database. The endpoint should be in the following format:

     GET /flexibledata/get/{?id}
    
    • The endpoint should return the data object with a 200 OK response, if the data was successfully retrieved from the database. If the data object is not found, the endpoint should return a 404 Not Found response.
    • If the ID is not provided, the endpoint should return all data objects in the database with a 200 OK response.
  3. Create an asynchronous post-processing system that will process the data objects in the database. The system should be triggered by a successful data object creation.

    • The system should count the number of flexible data objects that has a value for a given key. The system should store the count in a separate table called "Statistics in the database. The table should have the following structure:

        Key (string)
        Count (int)
      
  4. Create an endpoint to retrieve the count of a given key. The endpoint should be in the following format:

     GET /flexibledata/count/{?key}
    
    • The endpoint should return the count of the given key with a 200 OK response, if the count was successfully retrieved from the database. If no data is found, the endpoint should return a 404 Not Found response.
    • If the key is not provided, the endpoint should return all data in the table.
  5. Add a column to the "Statistics" table to store the list of unique values for a given key. You can choose the format you want to store it in.

         UniqueCount (string)
    
  6. In case of an error, all end-points should return a 400 Bad Request response, with a JSON object with the following structure:

     {
         "Error": "error message"
     }
    

2. Testing

Upon completion of the development, lets move on to testing the application.

  1. Dockerize the application
    • Create required Docker configurations to build and run the ASP.NET Core application
  2. Develop a very basic endpoint testing mechanism that tests and confirms the happy path of the system
    • Choose your preffered scripting language (E.g.: Bash, Powershell, Python) or choose a tool (E.g. Chrome, Postman) of your choice
    • With your preferred choice, create a way to simulate requests to different endpoints and validate the responses received

3. Completion

  1. Create a Github repository and push all the code and resources required for this coding challenge
    • Please, do NOT complete development and commit everything at once in one commit.
    • I would like to see your progress in the git history. The messages, and commits doesn't have to be proper. This would help me understand the path you took while doing this.
  2. Write instructions on how to compile/run the application and to run the tests.
  3. Send an e-mail to inditicating completion of the assignment. The e-mail should contain the following information
    • Repository URL
    • A short description of what percentage of the requirements were implemented, anything you couldn't do (if any), and your confiden

NOTES

  1. The SQL database should be created using EF Core code-first migrations. Feel free to seed the application with some intial data.
  2. It is important that the application compiling and testing can be done in a portable manner.
  3. The post-processing system should not block the API endpoint from returning a response to the client. It should also process events in the exact order that they occurred.
  4. Use the following features/libraries for development
  5. Cleaner code with industry standards is a must. Create layers for the application as preferred.

Final Notes

Feel free to use any resources you need to complete the challenge. If you have any questions, please feel free to reach out to me. I look forward to seeing your solution!

Good luck!

docker build -t dotnet-flexible-api . docker create --name core-api dotnet-flexible-api docker start core-api

docker run -d -p 8080:80 dotnet-flexible-api

About


Languages

Language:C# 96.9%Language:Dockerfile 3.1%