Skip to content

RamonFolguera/Backend-ArtHive-Social-Platform-Node-Express-Sequelize-mySQL

Repository files navigation

Final Project - Backend - ArtHive - My Art Social Platform 🧑‍🎨💻👩

Summary 📝
  1. Goal
  2. About
  3. Stack
  4. Diagram
  5. Installation
  6. Work-flow
  7. Endpoints
  8. Future funtionalities
  9. Licence
  10. webography
  11. Development
  12. Contact

Goal

In this project from our Full Stack Bootcamp with Geekshubs we are faced with the final challenge for which we are asked to show our knowledge adquired during this 12 weeks.

We have to create a complete Web Application from scratch using the technology learnt during the bootcamp of our choice, and also, we are given the opportunity to choose the product we want to build.

Once I decided to work with node.js + Express and mySQL + Sequelize, I started to develop my API to meet the requirements that follow:

  • Users registration.
  • Login + token + middleware.
  • User roles middleware.
  • CRUD for the different models.
  • At least one Many to many and One to many relation.
  • Migrations and seeders.

About

After thinking about a few different ideas, I decided to create a Social Platform focus on ART.

The idea of this project is to allow users (art lovers) to discover and explore artistic creations from emerging artists or more consolidated ones all around the world.

This concept could seem similar to other popular webapps like Pinterest, but the idea wants to move far from just a place to share images. It aims to be a community where people can connect through Art.

Stack

Used technologies:

DDBB diagram

'ddbb'

Local installation

  1. Clone the repository in a terminal in your computer: $ git clone https://github.com/RamonFolguera/rfc-geekshubs-fsd-val-finalproject-backend-070523.git
  2. $ npm install To install all dependencies needed.
  3. Connect my repo with the database with .env file. You just have to rename the file .env.example to .env and change the configuration to match your Docker one.
  4. $ npx sequelize-cli db:create To create db.
  5. $ npx sequelize-cli db:migrate To execute migrations.
  6. $ npx sequelize-cli db:seed:all To execute seeders.
  7. $ npx sequelize-cli db:drop In case you need to drop data base. Create, excute migrations and seeders again following steps from number 4.
  8. $ npm run dev To start the server.
  9. Ready to test the endpoints in Postman. Here you have my Collection in JSON format:

Copy that JSON and paste it in here to create a new Collection with all my endpoints: 'importJSONpostman'

Endpoints

Endpoints
  • AUTH

    • USERS REGISTER

        POST http://localhost:3000/auth/register
      

      body:

          
         {
              "name": "Peter",
              "last_name": "Smith",
              "email": "peter@peter.com",
              "password": "123456",
              "role_id": "role_id",
              "phone": "666555444",
              "city": "Valencia",
              "country":"Spain"
          }
    • USERS LOGIN

        POST http://localhost:3000/auth/login 
      

      body:

       {
          "email": "ramon@ramon.com",
          "password": "Ramon_123"
      }
  • USER

    • USER PROFILE

      Copy the generated TOKEN generado with authenticate from LOGIN:

          "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiUmFtw7NuIiwiZW1haWwiOiJyYW1vbkByYW1vbi5jb20iLCJ1c2VySWQiOjEsInJvbGVJZCI6MSwiaWF0IjoxNjgzMjgzMTI0LCJleHAiOjE2ODMyOTAzMjR9.YAKRv9TyrdK1rFctOiU-0MK3WTCd5Q4gaX_1Fl0lu-U"
      
      

      In AUTHORIZATION. Type BEARER TOKEN. Paste the generated TOKEN.

        GET http://localhost:3000/users/me/
      
    • USER PROFILE DETAILS UPDATE

      Copy the generated TOKEN generado with authenticate from LOGIN:

          "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiUmFtw7NuIiwiZW1haWwiOiJyYW1vbkByYW1vbi5jb20iLCJ1c2VySWQiOjEsInJvbGVJZCI6MSwiaWF0IjoxNjgzMjgzMTI0LCJleHAiOjE2ODMyOTAzMjR9.YAKRv9TyrdK1rFctOiU-0MK3WTCd5Q4gaX_1Fl0lu-U"
      

      In AUTHORIZATION. Type BEARER TOKEN. Paste the generated TOKEN.

        PUT http://localhost:3000/users/update-me/
      

      body:

      {
          "name": "Peter",
          "last_name": "Smith",
          "email": "peter@peter.com",
          "password": "123456",
          "phone": "666555444",
          "city": "Rome",
          "country": "Italy"
      }
    • AS SUPERADMIN AND ADMIN ENDPOINTS

    LOGIN as USER with SUPERADMIN AND ADMIN role:

      LOGIN as USER with ADMIN or SUPERADMIN role:
    
      body:
      ``` js
          {
              "email": "ramon@ramon.com",
              "password": "Ramon_123"
          }
      ```
    
      Copy the generated TOKEN generado with authenticate from LOGIN:
    
    
      ```
          "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiUmFtw7NuIiwiZW1haWwiOiJyYW1vbkByYW1vbi5jb20iLCJ1c2VySWQiOjEsInJvbGVJZCI6MSwiaWF0IjoxNjgzMjgzMTI0LCJleHAiOjE2ODMyOTAzMjR9.YAKRv9TyrdK1rFctOiU-0MK3WTCd5Q4gaX_1Fl0lu-U"
      ```
    
      In AUTHORIZATION. Type BEARER TOKEN. Paste the generated TOKEN.
    
  • ARTWORK

    • GET ALL ARTWORKS

        GET http://localhost:3000/artworks/
      
    • UPLOAD A FILE

        POST http://localhost:3000/file
      
    • AS USER ENDPOINTS

    LOGIN as USER with ANY role:

      body:
       ``` js
          {
              "email": "laura@laura.com",
              "password": "Laura_123"
          }
      ```
    
          Copy the generated TOKEN generado with authenticate from LOGIN:
    
    
           ```
              "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiUmFtw7NuIiwiZW1haWwiOiJyYW1vbkByYW1vbi5jb20iLCJ1c2VySWQiOjEsInJvbGVJZCI6MSwiaWF0IjoxNjgzMjgzMTI0LCJleHAiOjE2ODMyOTAzMjR9.YAKRv9TyrdK1rFctOiU-0MK3WTCd5Q4gaX_1Fl0lu-U"
          ```
    
          In AUTHORIZATION. Type BEARER TOKEN. Paste the generated TOKEN.
    
    • GET ALL ARTWORKS AS USER

        GET http://localhost:3000/artworks/user  
      

    AS ARTIST ENDPOINTS

      LOGIN as USER with ARTIST role:
    
      body:
       ``` js
          {
              "email": "alex@alex.com",
              "password": "Alex_123"
          }
      ```
    
          Copy the generated TOKEN generado with authenticate from LOGIN:
    
    
           ```
              "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiUmFtw7NuIiwiZW1haWwiOiJyYW1vbkByYW1vbi5jb20iLCJ1c2VySWQiOjEsInJvbGVJZCI6MSwiaWF0IjoxNjgzMjgzMTI0LCJleHAiOjE2ODMyOTAzMjR9.YAKRv9TyrdK1rFctOiU-0MK3WTCd5Q4gaX_1Fl0lu-U"
          ```
    
          In AUTHORIZATION. Type BEARER TOKEN. Paste the generated TOKEN.
    
    • CREATE ARTWORK REGISTERS

        POST http://localhost:3000/artworks/new
      

      body:

          {
              "artist_id" : "1",
              "title" : "test painting",
              "category" : "Abstract Painting",
              "description" : "Out of imagination",
              "technique" : "Acrylics",
              "dimensions" : "450x350mm",
              "status" : 1,
              "image_url" : "image.jpg",
              "price" : "60"
          }
    • GET MY ARTWORK REGISTERS

        GET http://localhost:3000/artworks/mine
      
    • UPDATE MY SELECTED ARTWORK REGISTER

        PUT http://localhost:3000/artworks/update/2
      

      body:

          {
              "artist_id" : "1",
              "title" : "test painting",
              "category" : "Abstract Painting",
              "description" : "Out of imagination",
              "technique" : "Acrylics",
              "dimensions" : "450x350mm",
              "status" : 1,
              "image_url" : "image.jpg",
              "price" : "60"
          }
    • DELETE MY SELECTED ARTWORK REGISTER

        DELETE http://localhost:3000/artworks/delete/1
      
  • USER_ARTWORK

    • AS USER ENDPOINTS

    LOGIN as USER with ANY role:

      body:
       ``` js
          {
              "email": "laura@laura.com",
              "password": "Laura_123"
          }
      ```
    
          Copy the generated TOKEN generado with authenticate from LOGIN:
    
    
           ```
              "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiUmFtw7NuIiwiZW1haWwiOiJyYW1vbkByYW1vbi5jb20iLCJ1c2VySWQiOjEsInJvbGVJZCI6MSwiaWF0IjoxNjgzMjgzMTI0LCJleHAiOjE2ODMyOTAzMjR9.YAKRv9TyrdK1rFctOiU-0MK3WTCd5Q4gaX_1Fl0lu-U"
          ```
    
          In AUTHORIZATION. Type BEARER TOKEN. Paste the generated TOKEN.
    
    • GET ALL USER_ARTWORKS AS USER

        GET http://localhost:3000/user-artwork/
      
    • AS ARTIST, ADMIN OR SUPERADMIN ENDPOINTS

    LOGIN as USER with ART LOVER role:

      body:
       ``` js
          {
              "email": "laura@laura.com",
              "password": "Laura_123"
          }
      ```
    
          Copy the generated TOKEN generado with authenticate from LOGIN:
    
    
           ```
              "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiUmFtw7NuIiwiZW1haWwiOiJyYW1vbkByYW1vbi5jb20iLCJ1c2VySWQiOjEsInJvbGVJZCI6MSwiaWF0IjoxNjgzMjgzMTI0LCJleHAiOjE2ODMyOTAzMjR9.YAKRv9TyrdK1rFctOiU-0MK3WTCd5Q4gaX_1Fl0lu-U"
          ```
    
          In AUTHORIZATION. Type BEARER TOKEN. Paste the generated TOKEN.
    
    • GET MY USER_ARTWORKS

        GET http://localhost:3000/user-artwork/mine
      
    • ADD FAVORITES

        POST http://localhost:3000/user-artwork/favorite
      

      body:

          {
              "favorite": true,
              "artwork_id": 8
          }
    • UPDATE FAVORITES

        PUT http://localhost:3000/user-artwork/favorite/1
      

      body:

          {
              "favorite": true,
          }
    • ADD COMMENTS

        POST http://localhost:3000/user-artwork/comment
      

      body:

          {
              "comment": "I love the contrast between lights and darks",
              "artwork_id": 3
          }
    • UPDATE COMMENTS

        PUT http://localhost:3000/user-artwork/comment/1
      

      body:

          {
               "comment": "I love the contrast between lights and darks of the environment" 
          }
    • DELETE COMMENT

        DELETE http://localhost:3000/user-artwork/comment/9
      
    • ADD RATING

        POST http://localhost:3000/user-artwork/rating
      

      body:

          {
              "rating": 50,
              "artwork_id": 3
          }
    • UPDATE RATING

        PUT http://localhost:3000/user-artwork/rating/9
      

      body:

          {
              "rating": 100
          }
    • DELETE RATING

        DELETE http://localhost:3000/user-artwork/10
      

License

This project is under the following license MIT License.

Webography:

To finish this project I have used the following documentation:

Development:

  console.log("Developed by: " + Ramón Folguera Carbonell);

Project made by:

  • Ramón

Thanks:

I want to thank my GeekHub mentors for all the support they have given us everyday:

  • Dani

  • Jose

  • David

  • Mara

Contact

Feel free to contact me anytime, I will be happy to help you with your project or to get me some feedback from you.

About

Final Project - Backend - ArtHive: Social Art Platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published