Coder Social home page Coder Social logo

cappua-be's Introduction

Cappua BE

logo

Table of Contents

What it does

The Cappua App

One part crowdsourced songwriting, one part rap battle, Cappua is a monthly hip hop music competition app in which users compete to get their verse included in the given month's featured track. Users upload their verse for a month's track and vote on their favorite uploaded verses as they vie for their place on Olympus, the Cappua Hall of Fame.

The Cappua BE Repo

The Cappua BE repo creates both GraphQL queries and a ReSTful endpoint for the FE repo to access data. This repo handles audio file uploads to the Cappua AWS S3 bucket, and stores the S3 bucket file locations for easy FE access via the AWS Cloudfront CDN. Finally, the repo stores vote data and user data in its relational database. Please visit the Cappua FE Repo here.

How to Install

For usage on your local machine follow the instructions listed below:

git clone [email protected]:Cappua/cappua-be.git
cd cappua-be
bundle install
rake db:{create,migrate,seed}
figaro install
rails server
visit localhost:3000 in your web browser

Dependencies

  • This app uses Rails version 5.2.4.4

  • We use the AWS SDK for Ruby Gem to upload audio files to our AWS S3 Bucket.

  • We use the Figaro Gem to keep confidential information like API keys secure.

  • We use the Fast JSON API Gem to serialize data for our ReSTful POST /upload endpoint.

  • The SimpleCov gem was used to ensure that we covered 100% of our code with unit testing.

Learning Goals

  • Explore and integrate AWS services

  • Gain familiarity and confidence in working with full FE & BE teams

  • Incorporate agile processes such as standups and kanban boards

  • Create versatile GraphQL queries

  • Refactor code for better code for improved organization/readability

  • Iterate upon collaborative workflow with small commits, descriptive pull requests, and code reviews

  • Write thorough and understandable documentation

Project Diagram

Cappua Diagram (1)

Schema

Screen Shot 2021-02-25 at 10 13 48 PM

API Contract

Our BE API uses a combination of a ReSTful endpoint and GraphQL queries. Our single ReSTful endpoint, POST /upload, handles audio file uploads into our nested AWS S3 bucket, and creates related entries in our database. Our GraphQL queries handle all the rest of our CRUD functionality.

POST /upload - ReSTful Endpoint

POST /upload allows for the upload of audio files and the creation of both competition and verse rows in our BE database. The required parameter type is used to define which of these two functions will be performed. Parameters must be passed in with a multipart/form-data content type header.

Request Parameters

Name Type Description
type String (required) 'verse' or 'competition' to specify what kind of file is being uploaded
audio mp3 (required) Audio file to be uploaded
user_id Integer (required for verse uploads) - the id of the user that is uploading a verse
competition_id Integer (required for verse uploads) - the id of the competition that a verse is being uploaded for
title String (required for verse uploads) - the name of the verse
Month Integer (required for competition uploads) - Numeric Representation (1 - 12) of the month competition is held in
Year Integer (required for competition uploads) - Numeric Representation of the year competition is held in
Description String (required for competition uploads) - Description of the competition to be shown on the competitions page
Genre String (required for competition uploads) - Genre of the competition to be shown on the competitions page
Rules String (required for competition uploads) - Rules for the competition to be shown on the competitions page
Title String (required for competition uploads) - Title of the competition to be shown in the media player
Image String (optional for competition uploads) - Image of the competition to be shown on the competitions page

Sample Response (type => 'verse')

{
  "data": {
    "id": "210",
    "type": "verse",
    "attributes": {
      "id": "210",
      "audio_path": "verses/es_zone_in.mp3",
      "competition_id": "204",
      "user_id": "283",
      "title": "Just a Friend"
     }
   }
 }

Sample Response Body (type => 'competition')

{
  "data": {
    "id": "207",
    "type": "competition",
    "attributes": {
      "id": "207",
      "track_path": "competitions/es_zone_in.mp3",
      "month": "2",
      "year": "2021",
      "description": "Wu Tang Sword Style",
      "genre": "East Coast Hip Hop",
      "rules": "Submissions due by February 14th. Winners announced on March 1st",
      "title": "Wu Tang Forever",
      "image": "https://i.ytimg.com/vi/5CzsXvAZ6R4/mqdefault.jpg"
    }
  }
}

Competitions Query - GraphQL

Request Query

query {
  competitions {
    id
    trackPath
    month
    year
    description
    genre
    rules
    title
    image
    verses { verseType }
  }
}

Sample Response Body

{
  "data": {
    "competition": {
      "id": "213",
      "trackPath": "http://stiedemann.biz/thurman",
      "month": "7",
      "year": "2021",
      "description": "Pidgeot",
      "genre": "Struggle",
      "rules": "Anistar City",
      "title": "Wu Tang Forever",
      "image: "https://i.ytimg.com/vi/5CzsXvAZ6R4/mqdefault.jpg"
      "verses": [
        {"id": "223"},
        {"id": "224"}
      ]
    }
  }
}

Verses Query - GraphQL

Request Query

query {
  verses {
     id
    competitionId
    userId
    audioPath
    user { userType }
    votes { voteType }
    track { trackType }
  }
}

Sample Response Body

{
  "data": {
    "verses": [
      {
        "id": "231",
        "audioPath": "http://zemlak.co/rickey",
        "competitionId": "217",
        "userId": "304",
        "title": "Yog-Sothoth"
      },
      {
        "id": "232",
        "audioPath": "http://hauck.io/jocelyn",
        "competitionId": "218",
        "userId": "305",
        "title": "Azathoth"
      },
      {
        "id": "233",
        "audioPath": "http://lowe.org/sherry.feeney",
        "competitionId": "219",
        "userId": "306",
        "title": "Tsathoggua"
      },
      {
        "id": "234",
        "audioPath": "http://hackett-welch.co/gricelda_barton",
        "competitionId": "220",
        "userId": "307",
        "title": "Dagon"
      }
    ]
  }
}

createVote mutation - GraphQL

Request Query

mutation {
  createVote( input: { verseId: ID, userId: ID }) {
      id
      userId
      verseId
    }
  }
}

Sample Response

{
  "data": {
    "createVote": {
      "id": "<integer>"
        "verseId": "<integer>",
        "userId": "<integer>"
    }
  }
}

Licenses

  • Ruby 2.5.3
  • Rails 5.2.4.4

BackEnd Team

Brian Liu

Brian Liu

GitHub Profile

Eugene Theriault

Eugene Theriault

GitHub Profile

Nick King

Nick King

GitHub Profile

Sage Freeman-Gonzales

Sage Freeman-Gonzales

GitHub Profile

Contact

Brian Liu: LinkedIn Email, GitHub

Cooper Terrones: LinkedIn Email, GitHub

Demaceo Vincent Howard: LinkedIn Email, GitHub

Eugene Theriault: LinkedIn Email, GitHub

Nick King: LinkedIn Email, GitHub

Sage Freeman-Gonzales: LinkedIn Email, GitHub

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.