Skip to content

Instantly share code, notes, and snippets.

@simplyluke
Last active January 1, 2016 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simplyluke/8191381 to your computer and use it in GitHub Desktop.
Save simplyluke/8191381 to your computer and use it in GitHub Desktop.
RP Application API Design

Outline: RESTful API to manage the infrastructure of the application. Create users/goals/points via API and build mobile applications on top of it. I'm not too familiar with developing apps in this way, but it does not seem overly complicated. Pleae correct anything obviously wrong with this plan, still a noob

Users

Endpoints:

Users:

  • get /users, returns all users
  • get /users/:id, returns user
  • patch /users/:id, updates user (which should include users points)
  • post /users, create user
  • patch /users/:id, update user
  • destroy /users/:id, destroy user (and associated points)

Sessions:

  • post /sessions, create a new user session (log in)
  • delete /sessions/:id, destroy a user session (log out)

Model

Necessary:

  • id
  • has many points (awarded for completing various actions we define)
  • user's name
  • encrypted_password (or not, unsure how this works with oauth)

Feature Ideas:

  • has many relationshionships (follow other user's progress)

Points

endpoints

  • post /points, create points for a user
  • delete /points/id, destroy a point post

model

  • id
  • belong to user
  • value of point, arbitrary integer of worth we give to activity
  • description, string that describes that point so we can organize them (so "walked to work" could be a category)

Suggested technology to build it with:

  • Python/Flask - very minimalistic, not as familiar with designing an entire application on top of it but want to learn. Would probably need a bit of mentoring in the best way to organize and implement that code.
  • Ruby/Rails - black box, that said I've developed a very similar application with views in rails and it's a breeze. The rails-api project looks like a really good option, strips out all the views/templates/assets of rails and makes it lighter weight and better suited for a JSON API. https://github.com/rails-api/rails-api
@tgrochowicz
Copy link

What if we changed "Points" a bit? Maybe something like:

The app has a collection of "Activities", each of which has certain "Achievements", each of which has a certain number of points associated with it.
So, for example -
"Walk to Work" is an activity/category. Each day you walk to work, you mark it in the app, and you get X points. Mark more than Y days in a week, get Z additional points.

So we'd have an internal API for creating/managing Activities and Achievements (externally read-only), and then a many-to-many user achievement xref (illustrated in the structure below). The app would post to UserAchievements when the user marks some task as being completed.

Activity
-id
-name
-description

Achievement
-id
-name
-description
-activity_id
-points
-one-time/repeatable
-

UserAchievements
-user_id
-achievement_id
-datetime

This way, each achievement is only in the DB once - DRY applies to databases, too : )
Let me know if this doesn't make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment