Git Product home page Git Product logo

generasi-gigih-final-project's Introduction

Generasi GIGIH Final Project Backend: Social Media API

This repo contains code for generasi GIGIH Final Project in the Backend track. The problem for this project is to make an API for simple social media. Like other social media, users can make a post with hashtags and one attachment, also users can comment and many details for the API you can see in the API documentation.

Prerequisite to run application locally

To run this app you need to install some dependencies below:

  • install Ruby, for developing this app I use ruby 2.7
  • install sinatra
gem install sinatra
  • install mysql2, in some OS mysql2 need build gem native extension and in linux we can install by sudo apt-get install ruby2.7-dev
gem install mysql2
  • import the database that I have provided. file social_media_db.sql
  • setting the environtment variable. please make sure the value of the environment variable matches your database environment.
export DB_HOST=localhost
export DB_USER=root
export DB_PASS=
export DB_NAME=social_media_db
  • clone this repo and run this command to start the app
ruby web.rb

Test

for testing I use rspec and simplecov. Please make sure you already installed it.

gem install rspec
gem install simplecov

to run the test you can run by command below. (actually i prefer to use format document in rspec)

rspec -f d

to test endpoint you can go to API documentation and import the url from there or you can import the collection from exported collection in postman collection folder.

API Documentation

I create API documentation with postman API documentation tool. You can visit the link below to see the detail about API

API Documentation

In postman I use some global variable. Please make sure you provide it in your postman.

Global variables

name initial value type
base_url http://34.131.84.223:4567 (url GCP machine) string
user_id 1 int
tag tag string
post_id 1 int

ERD scheme

For the database I build schema like in the picture. I provide an imported sql with name social_media_db.sql.

Note for erd & database

I write some notes for you easier to understand my erd and database schema.

  • for field created_time I use the type TIMESTAMP. I think this type is easier for me if I want to group data by time.
  • field attachment stores the path where the attachment file is stored. For the name of the file, I use the name of tempfile. Just to make it easier for me, I don't create a function to generate a unique name for the attachment file. For now the extension that can be save for attachment file is .jpg, .png, .gif, .mp4 and other extension outside picture and video format.
  • field tag contains the hashtag in lowercase.

Coverage

strange thing I found when developing this app

generasi-gigih-final-project's People

Contributors

nardiyansah avatar

Watchers

 avatar

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.