Giter Club home page Giter Club logo

hiring_challenge's Introduction

Workana Hiring challenge

Hi!

We are looking for great PHP developers to join our team. Instead of going through a boring long interview process, we decided that code often speaks for itself. If you're up to the challenge, please take a couple of hours play with this problem and submit your solution.

The problem

Workana is built around a PHP framework and given it's a fairly large application, we have a baseline of around ~125ms. When we launched our chat, we needed a way to retrieve the current user's friends list. This endpoint (/chat/friends) needed to be blazing fast, as it would be called thousands of times per hour. So we removed this endpoint from our application á la microservice. We wrote this code (yes, this was code used in production), but it was far from perfect, and far from being testable. Our index.php contains a single routine with lots of dependencies and too much knowledge.

Get up and running

To run this code you need:

Then:

  • Clone this repo: git clone [email protected]:Workana/hiring_challenge.git.
  • Run composer install.
  • Copy the .env.example file to .env and fill in your configuration.
  • Start a local PHP Server with: php -S localhost:8080 -t webroot
  • Create some keys on Redis. You can see the commands with the content here. A faster alternative is to run php create_redis_keys.php.
  • Make your first successful request with: curl -XGET --cookie 'app=hash' localhost:8080.

How it works

Request/Response cycle

It receives a request with a cookie from a logged in user. With that cookie we retrieve the current user's session which contains the user ID. That user ID is used to retrieve the user's current friends list stored in Redis. This key contains a serialized instance of app\domain\chat\FriendsList. That instance is then filled with presence status of the relevant users (also stored in Redis).

Possible outcomes

Required domain knowledge

You shouldn't pay much attention to what app\domain\chat\FriendsList class does. It's just a data transport object. Those cache keys are generated by other processes.

What we would like you to do?

Download this repo. Code it your way. Think how would you solve this problem using modern PHP components without a lot of overhead.

  • Microframeworks could be used, but we don't believe are a must given the simplicity of the task at hand.
  • Some Request/Response interfaces for standardization would be nice :-)
  • Unit testing is mandatory.
  • Although we love other languages too, we prefer if you stick to PHP, as it is Workana main language.

challenge

Submission

Please don't submit Pull Requests. After you're done, please send an email to [email protected] with the link to your fork so we can start talking =)

Thanks a lot and happy coding!

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.