Git Product home page Git Product logo

api_picinguaba's Introduction

Projeto_Picinguaba

Objective

Create the necessary infrastructure for the storage and collection of data of a website. This includes:

  • the configuration of the database with the necessary tables and relationships between them;
  • the creation of an API capable of sending, collecting, and updating data;
  • the creation of a webpage to showcase the API's capabilities.

Tecnologies implemented

In this project the following technologies, languages, and libraries were used:

  • Node
  • Yarn - package managemen system
  • Typescript - for being strictly typed
  • Express - for the API REST communication
  • Knex - query builder for the communication
  • MySQL - database management system
  • Swagger - for describing the REST API

Database

The database structure was conceived after talking with the UX team about what would be displayed on the website. After some iterations, the final design is as follows.

Database structure containing three tables with connections through foreign keys

Using Knex

The tables were created through the node module "knex" using migrations to implement the necessary columns, constraints, and relations.

The "knexfile.ts" file holds the information to tell knex where to find the desired database and its type.

The folder /src/database holds the migration files, responsible for the creation and configuration of the tables, as well as the connection.ts, responsible for calling the knexfile.ts.

MySQL print to show created tables in the required database

Writing the initial information

To make the datadump for the initial set of information, JSON files were created with the categories and products followed by the coding of the necessary controllers and function calls.

Now we are able to input all the initial data through a single terminal command instead of needing to insert them one-by-one using the API or the MySQL Workbench.

API REST

For the creation of the API we used the node module "Express". With it we are able to communicate with the HTTP protocol requisitions. We separated the steps in:

  • controllers - containing the functions responsible for interacting with the database by writting or reading it
  • routes - to direct the specific requisition of GET, POST, DELETE or PUT to the desired controller
  • server - to get everything together, determine the port, and listen for requests.

SWAGGER

We used "Swagger" to create a page to showcase what is possible to do with the API. In it it is shown which requests are possible as well as JSON templates.

Possible requests to interact with each table JSON Templates

api_picinguaba's People

Contributors

micheldslive avatar guilhermegilcampbell avatar

Stargazers

Gustavo Alberto avatar

Forkers

gusalberto

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.