Giter Club home page Giter Club logo

eight-sleep-php's Introduction

Goals

  • Implement the coding challenge requirements as defined
  • Extend the requirements making the "Family Mode" feature more complete
    • Invite a user
    • Accept an invitation
    • Reject an invitation
  • Write code that is easily maintainable, readable, testable, understandable
  • Use a time series datastore for metrics
    • Make for minimal code changes when switching to a different datastore
  • Demonstrate some level of devops competence

Prerequisites

It is recommended to install PhpStorm, or similar environment, in order to facilitate easier code review and tracing. It is available as a free 30-day trial. https://www.jetbrains.com/phpstorm/download/

  • Docker
  • PhpStorm (recommended)

Environment Setup

Spin up docker containers and initialize the application

chmod a+x setup-environment.sh
./setup-environment.sh
  • Open <root>/docker/influxdb/config/influx-configs
  • Copy token value from line similar to token = "VB_LSJOw1spqi577hGhZDcngDK0pLPOjcEKrgPphiaF5xonbZX6TOQnupwcKPCYPB3v_DOHH03dzvEnlSXwT6Q==" excluding "
  • Open <root>/.env
  • Add token value to INFLUXDB_TOKEN=

Now we should be ready to populate the datastores

chmod a+x setup-data.sh
./setup-data.sh

Development Site

Available User Accounts

The password for all generated user accounts is password

Architecture

  • Application code is decoupled from the underlying framework
  • API endpoints and corresponding code are versioned
  • Domain operations are reusable functional classes
    • Intended to make forming new logic easy and straight forward without duplicating code
    • Dependencies injected and easily mocked
    • Simplifies unit testing since there is only 1 function per, instead of large service classes
  • Domain actions bring together operations forming application/business logic used as a
    • Controller
    • Command
    • Dependency in another action

Code

The best place to start digging in is in the seeder file. It best demonstrates how the code I wrote works, aside from a presentation, and is the easiest way to trace into the code base.

<root>/database/seeders/DatabaseSeeder.php

Additionally, certain interfaces and classes need to be bound to the framework instance container and those bindings can be found in:

<root>/app/EightSleep/Provider.php

File Structure

Here are the critical file paths to help you focus and review the code I generated instead of framework code

Log Files

<root>/storage/logs

Backend Code

// Integration code specifically for the Laravel framework
<root>/app/EightSleep

// Migrations are timestamped and in time order
// All migrations prior to 2023_08_25_103343_create_linked_user_accounts_table.php were generated by the framework
<root>/database/migrations

// Application code I wrote specifically for this engineering challenge
<root>/eight-sleep/App

// Custom framework code I wrote to decouple application code from an underlying framework
<root>/eight-sleep/Framework

// API Route Definitions
<root>/routes/api.php

Frontend Code

// I used UI starter package to sleep things along
// The following are the files I modified/created that related to challenge
<root>/resources/js/Pages/Dashboard.vue
<root>/resources/js/components/LoadApiToken.vue
<root>/resources/js/components/LoadUserData.vue
<root>/resources/js/components/SleepHeartRate.vue
<root>/resources/js/components/SleepInterval.vue
<root>/resources/js/components/SleepScore.vue
<root>/resources/js/components/SleepStages.vue
<root>/resources/js/components/SleepTemperature.vue
<root>/resources/js/components/SleepTossAndTurn.vue

Plan

  • Setup a development environment using Docker containers define using docker-compose.yml
    • php
    • nginx
    • influxdb
    • sqlserver
    • memsql (now single store)
  • Implement a backend that satisfies the challenge requirements
  • Implement a frontend that satisfies the challenge requirements
  • Do the whole thing again in C# to show how awesome I am
    • NOTE: Because C# is my favorite language and I wanted to dust off the rust

eight-sleep-php's People

Contributors

rmblstrp avatar

Watchers

 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.