Skip to content

rmblstrp/eight-sleep-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published