anamecheverri / stat-tracker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stat Tracker

Description

Build an application people can use to track any stats they want about themselves.

Objectives

Learning Objectives

After completing this assignment, you should understand:

  • ...

Performance Objectives

After completing this assignment, you should be able to:

  • ...

Details

Deliverables

  • A Git repo called stat-tracker containing at least:
    • README.md file explaining how to run your project
    • a requirements.txt file
    • a way to seed your application with data
  • An instance of your app running on Heroku

Requirements

  • No PEP8 or Pyflakes warnings or errors
  • Meets API specifications

Normal Mode

You are going to build an application to track personal statistics. A personal statistic is a numerical record for a person in a time series by day. For example, let's say I wanted to track how many flights of stairs I walked up in a day. My last week might look like:

Date Flights
02/19/2015 8
02/20/2015 6
02/21/2015 7
02/22/2015 6
02/23/2015 8
02/24/2015 4
02/25/2015 6

Users of your application can create as many different things to track as they want. They should have an easy-to-use interface to track their stats, allowing them to enter the number for the current day or any previous day.

You should allow for:

  • User registration
  • User login
  • Creating a new stat to track
  • Recording a stat for a day
  • Editing a stat for a day
  • Showing a chart for a stat for any series of dates, defined by a start and stop date. The default should be the last 30 days.

For the chart, you can use whatever you like. Matplotlib is our old friend, but can be unwieldy. Bokeh and Plotly are other good choices to use with HTML.

You should also have an API. One of the ways people expect to use this application is via their phone, so you'll need a REST API.

API Specification

For your API, I'm specifying the endpoints you'll need and what they should do. The URLs I'm using are not prefixed: yours should be. All the endpoints require authentication using HTTP Basic Auth.

Verb URL Action
GET /stats Show a list of all stats I am tracking, and links to their individual pages
POST /stats Create a new stat for me to track.
GET /stats/{id} Show information about one stat I am tracking, and give me the data I have recorded for that stat.
PUT /stats/{id} Update one stat I am tracking, changing attributes such as name or type. Does not allow for changing tracked data.
DELETE /stats/{id} Delete a stat I am tracking. This should remove tracked data for that stat as well.
POST or PUT /stats/{id}/data Add tracked data for a day. The JSON sent with this should include the day tracked. You can also override the data for a day already recorded.
DELETE /stats/{id}/data Remove tracked data for a day. You should send JSON that includes the date to be removed.

I am not specifying what the JSON these return should look like, but you should feel free to follow one of the many competing standards. JSON API is very comprehensive.

Hard Mode

In addition to the requirements from Normal Mode:

  • Users should be able to record different types of stats. You can choose the types, but here are some suggestions:

    • Clicker-style stats. The UI on these should change so you have a way to increase them by one via a button click. Good for tracking things as you're doing them.
    • Time-goal stats. The stat has a beginning value, ending value, and ending date. Track as normal, but you should be able to see if you're on track to meet your goal. Examples: weight loss, building up for a long run.
    • Yes-no stats. Did I do this today? This is often called the "Seinfeld calendar" or chain calendar.
    • Stats on a scale instead of unbounded. Example: On a scale of 1 to 5, what's my happiness level today?
  • Make sure your interface is responsive and works well via mobile.

Nightmare Mode

  • Give users a way to invite other users to collaborate/compete on a stat with them. Users can only add/edit their own data, but the stat charts will show everyone competing.

Additional Resources

  • JSON API
  • Bokeh
  • Plotly
  • Flask-RESTful. A Flask plugin that could help or make this much worse.
  • RESTless. Another Python library that could help or harm.
  • Kube. A simpler CSS framework I've been using.
  • Peewee. A less-featureful, but perhaps easier to use ORM.

Credit

...

About


Languages

Language:CSS 84.6%Language:Python 11.1%Language:HTML 4.0%Language:JavaScript 0.3%