Coder Social home page Coder Social logo

rails_eng's Introduction

Build Status LinkedIn

schema_rails_eng

Rails Engine API

A Business Intelligence Focused API. Built from scratch.
Explore the docs »

· Report Bug · Request Feature

Table of Contents

About The Project

Customer Built Business Class API using using Rails and Ruby

Built With

  • (Ruby 2.5.1)
  • (Rails 5.1.7)

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

  • FastAPI

Installation

  1. Clone the repo

    git clone https://github.com/jobannon/rails_eng.git
  2. Setup the Database

    bundle exec rails db:drop
    bundle exec rails db:create
    bundle exec rails db:migrate
    bundle exec rails db:seed
  3. Populate our API with data using a custom built rake file

    rake import:all_import 
  4. Test Suite Usage

    bundle exec rspec 

Usage

This API is divided into 6 resource tables. All resources are exposed.
customers
transactions
invoices
merchants
items
invoiceitems

Endpoints

All resource endponts are exposed for an "index" and "show" action

Index

  • Example

    GET /api/v1/merchants
  • Usage

        GET /api/v1/<resource>
  • Output

      {
      "data": [
      {
        "id": "1",
          "type": "merchant",
          "attributes": {
            "name": "Mike's Awesome Store",
          }
      },
      {
        "id": "2",
        "type": "merchant",
        "attributes": {
          "name": "Store of Fate",
        }
      },
      {
        "id": "3",
        "type": "merchant",
        "attributes": {
          "name": "This is the limit of my creativity",
        }
      }
      ]
    }

Show

  • Example

    GET /api/v1/merchants/:id
  • Usage

        GET /api/v1/resource
  • Output

      {
        "data": {
          "id": "1",
          "type": "merchant",
          "attributes": {
            "name": "Store Name"
          }
        }
      }

Single_Finder

  • Usage

      GET /api/v1/merchants/find?parameters
    Param search resource attribute
    id based on id
    name based on name
    created_at based on table.timestamp
    updated_at based on table.timestamp
  • All queries will return the first record

  • Output

      {
        "data": {
          "id": "1",
          "type": "merchant",
          "attributes": {
            "name": "Store Name"
          }
        }
      }

Multi_Finder

  • Very similar to a single finder but will return the complete collection matching the search criteria sh GET /api/v1/merchants/find_all?parameters

Random

  • Returns a random resource within a collection
    api/v1/merchants/random
  • This was built with RANDOM method in SQL

Relationships

  • Following relationships were built into each resource table and are reflected in the schema

    GET request Returns
    >Merchants
    GET /api/v1/merchants/:id/items returns a collection of items associated with that merchant
    GET /api/v1/merchants/:id/items returns a collection of items associated with that merchant
    GET /api/v1/merchants/:id/invoices returns a collection of invoices associated with that merchant from their known orders
    >Invoices
    GET /api/v1/invoices/:id/transactions returns a collection of associated transactions
    GET /api/v1/invoices/:id/invoice_items returns a collection of associated invoice items
    GET /api/v1/invoices/:id/items returns a collection of associated items
    GET /api/v1/invoices/:id/customer returns the associated customer
    GET /api/v1/invoices/:id/merchant returns the associated merchant
    >Invoice Items
    GET /api/v1/invoice_items/:id/invoice returns the associated invoice
    GET /api/v1/invoice_items/:id/item returns the associated item
    >Items
    GET /api/v1/items/:id/invoice_items returns a collection of associated invoice items
    GET /api/v1/items/:id/merchant returns the associated merchant
    >Transactions
    GET /api/v1/transactions/:id/invoice returns the associated invoice
    >Customers
    GET /api/v1/customers/:id/invoices returns a collection of associated invoices
    GET /api/v1/customers/:id/transactions returns a collection of associated transactions

Query

  • Business Intelligence Queries

    GET request Returns
    >All Merchants
    GET /api/v1/merchants/most_revenue?quantity=x returns the top x merchants ranked by total revenue
    GET /api/v1/merchants/revenue?date=x returns the total revenue for date x across all merchants
    >Single Merchant
    GET /api/v1/merchants/:id/favorite_customer returns the customer who has conducted the most total number of successful transactions
    >Items
    GET /api/v1/items/most_revenue?quantity=x returns the top x items ranked by total revenue generated
    GET /api/v1/items/:id/best_day returns the date with the most sales for the given item using the invoice date. If there are multiple days, return the most recent day
    >Customers
    GET /api/v1/customers/:id/favorite_merchant returns a merchant where the customer has conducted the most successful transactions

Roadmap

  • SEE ISSUES

    See the open issues for a list of proposed features (and known issues).

License

Distributed under License. See LICENSE for more information.

Contact

@jtobannon - [email protected]

https://github.com/jobannon/rails_eng

Acknowledgements

rails_eng's People

Contributors

jobannon avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

rails_eng's Issues

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.