Giter Club home page Giter Club logo

tagger's Introduction

Tagger

A little API for tagging things.

Starting The App

Starting the app should be simple. So keep things simple it's using sqlite, so you shouldn't have to do too much to get things going:

bundle
bundle exec rails server

Running The Tests

This app has cucumber tests for acceptance testing and rspec unit tests. You can run everything in one go with this handy script:

script/run_tests

Swagger Documentation

This API includes a swagger specification which has been used to autogenerate the interactive html documentation here:

http://localhost:3000

A Tour Of The Code

Most of this is pretty straight forward, but let me hilight a few parts of the codebase.

/features

You'll find cucumber tests in the /features directory, which also serve as decent documentation for how the API is intenmded to work. These are integration tests that interact with the app through rack.

/spec

Unit tests can be found in the /spec directory.

/actions

I prefer not to have much of any business logic in ActiveRecord models (which I think should only really be responsible for persistence) or controllers (which I see as responsible for http-specific things like response codes and pulling params out of the request). To that end I often end up writing "action" objects to encapsulate business logic when a controller action would otherwise have to make multiple calls to ActiveRecord object methods.

A few naming decisions

/tags -> /entities

Once I got into this a little it seemed to me that the endpoints I was writing were realling modifying and returning entities, not tags, so I changes the route name.

entity_id and external_id

While it makes sense for clients of this API to refer to the entity identifier as entity_id that ends up being a terrible name for out Entity model as it's too easily confused with the primary key (entity.id vs entity.entity_id). I've seen this kind of thing cause a lot of confusion in the past. To avoid that confusion I called that id the external_id in the database. This means there are a few places where business logic has to map the public name of that attribute to our internal name, but I think that's preferable in the long run.

tagger's People

Contributors

bundacia avatar

Watchers

 avatar James Cloos avatar

Forkers

courtsimas

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.