Giter Site home page Giter Site logo

bancodobrasil / stop-analyzing-api Goto Github PK

View Code? Open in Web Editor NEW
22.0 9.0 17.0 174 KB

Stop Analyzing API is the core module of Tinder like tool to help your customers make up their mind with no pain

License: MIT License

Dockerfile 2.70% Go 91.13% Shell 6.17%
poppins docker golang prisma hacktoberfest

stop-analyzing-api's Introduction

Stop Analyzing API

This is a Poppins project first-timers-only

Stop Analyzing is a tool that uses Tinder like interaction to help your customers make up their mind when choosing something that has lot of options, like a product of an e-commerce. Check this repo for more details and this issue explains how this idea was born. Stop Analyzing API has the core functions to make it happen.

This project was made for first-time contributors and open source beginners

This project follows the Poppins manifesto guidelines as part of it's community principles and policies, focusing all the decisions and interactions on providing open source beginners mentorship with real and relevant experiences, respecting each learning pace, background experience, academic formation, questions, suggestions, doubts and opinion.

Contribute now!

So, let's start contributing! Open an issue asking for a task to be done by you. A mentor/maintainer will come and provide a technical overview of the project and what are the possibles ways of contributing to the project. You will discuss the options and a suitable issue will be assigned or created to you.

That's it. Just make yourself at home and good luck!

Getting Started

Configure pre-commit code validations

This project includes pre-commit git hooks that make sure the code you commit is valid. In order to use them, you should rewire the default git hooks folder in your local repository by running (only once)

git config core.hooksPath githooks

Generate database using the Prisma migration tool

To generate the database and the go class to handle the connection run the migration tool:

  1. Start database and pgadmin using the command
docker-compose up -d postgres pgadmin
  1. At the scripts/prisma folder run the generate.sh file using the command
sh generate.sh
  1. Your database is started and the tables are generated

Build API using Docker

To build stop-analyzing-api run the below code at the project root folder to run with Docker (suggested):

docker-compose build

Run API using Docker

To run stop-analyzing-api run the below code at the project root folder:

$ docker-compose up stop-analyzing-api

Build API environment using Docker

To build stop-analyzing-api environment execute the bash script below at the project root folder:

$ local_build.sh

Run API using local Go installation

Execute the Go command bellow at the project root folder:

$ DATABASE_URL=postgresql://user2020:pass2020@localhost:5432/stop-analyzing-api go run main.go

Awesome list of other Poppins projects for you to go

Awesome

stop-analyzing-api's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stop-analyzing-api's Issues

Create an integration test to validated the json migration flow

stop-analyzing-api has (currently) two possible migration scenarios: URL and Json file import.

We believe that it would be good to have an integration test using golden files to check :

  1. Scenario with valid json
  2. Scenario with invalid json
    2.1) Format
    2.2) Content
    2.3) Enconding

Here is an article with details of how to create golden-files: https://ieftimov.com/post/testing-in-go-golden-files/

Here's the simplest example of a golden file test: https://github.com/zamariola/time-tracker-golang/blob/master/filesystem/filesystemsaver_integration_test.go

I can contribute with Go :)

Hello Guys!
First of all, awesome idea encouraging the open-source community.
I can help with golang and APIs. Just let me know if you guys foresee anything.
Thanks!

I want to contribute to this project

Cheers,
I have experience in go,

Was looking for smth to contribute to in my spare time,

If there is anything you are willing to let me take, would be lovely

Thanks :D

I'd like to contribute

Hello,

I have about 15 years of experience with software development but only a few coding in GO.
I think that I can contribute in any task that is needed.

Regards,
Douglas

Create an endpoint to get next choice option

Implement only the Route, you don't have to implement yet the algorithm of sorting items and actually retrieve them, just the endpoint retrieving a fixed array of items. We will create another issue for that algorithm.

Spec:

Wedding dress Stop Analyzing Database

Using th API

...

Get Choice Option

To get the next choices to be presented to the user, the client will invoke an endpoint passing and array with the previous choices and how many items it wants to be retrieved and the algorithm will compute an ordered list of items based on the features (tags) of those previously chosen items returning the n items requested and the completion ratio of the choice session (we will discuss this in another issue).
This approach will have scale issues on large databases, but we won't address this issues now as we don't have any large database scenario on sight.

GET /choice

query params:

?previous=ccbd7e00301aaa903a2dd30093&previous=...
  • previous: an array of previously selected choices used to filter the next choices. Default: empty
?count=2
  • count: a number of how many items to return. Default: 2

Examples:

$ curl -X GET http://localhost:8008/api/v1/choice?previous=16913&previous=17901

$ curl -X GET http://localhost:8008/api/v1/choice?previous=ccbd7e00301a60703aedbadba&previous=ccbh7e00301aaa903a2dd3dba&count=3

Return:

{
   "id": "5bdae898eaba99",
  "completionRate": 0.3,
  "choices": [{
    "title": "stringt1",
    "subtitle": "strings1",
    "contentURL": "stringc1",
    "tags": ["tag11", "tag12", "tag13"]
  },
  {
   "id": "5bdae89eeae8a99",
    "title": "stringt2",
    "subtitle": "strings2",
    "contentURL": "stringc2",
    "tags": ["tag21", "tag12", "tag13"]
  },
  {
   "id": "5bdae890aa0a0993e",
    "title": "stringt3",
    "subtitle": "strings3",
    "contentURL": "stringc3",
    "tags": ["tag21", "tag12", "tag31"]
  }]
}

Implement a crawler to build a migration database

I was wondering if we should implement a mock data generator or build a database from a real data and I think the latter is a better approach because real data guides better the design decisions, here and at the UI.

So, it would be nice to crawl data from the customer website that inspired this project and will be the first one to use: https://www.lafiancee.com.br/vestidos-de-noiva

I know that crawling in Golang is not the best approach, so you can build the crawler on your own user on GitHub using your prefered stack and we will work on the issues there.

The constraints:

  • it should run on docker container and expose a volume that will store the data as a JSON
  • it should expose a HTTP endpoint to download this data as a zip file

The ideia is that this service will be composed with this service here to be used as a migration to the database

What do you think?

I want to contribute

Hey, I am quite a newbie to programming and this is the first time I am trying to contribute to an open-source project. I have experience with working on operational tasks for 6 months in a cloud telephony company.

I want to contribute to the project

Hi, First of all, thank you for what you are doing, helping beginners to start to contribute to open source.

I have some proficiency with JavaScript and I am really interested in the Go programming language.

I would like to contribute to this project, if possible.

Contribution to the repo

I just graduated from computer engineering at Bogazici University. I have experience with express.js, Asp.NET, Django, and FastAPI for the backend. I learned Golang, but I want to contribute to open source to gain more experience. This will be my first contribution to open source, too.

Complement crawled data

The result of the crawler made by @douglasferlini in #5 is a JSON array with the overall information of the dresses os La Fiancee. Now, we need now to get the details of the dresses and generate a more detailed JSON array.

To do so, you will read the attached JSON and will make a request for the product API providing the urlPartin the following format:

const productID = <urlPart_from_json_array>
await fetch("https://www.lafiancee.com.br/_api/wix-ecommerce-storefront-web/api", {
    "credentials": "include",
    "headers": {
        "Accept": "*/*",
        "Authorization": "brUTfgwc9eaqQ4m_KjbIkjnR-MRt9rGfCLGikGEPiRU.eyJpbnN0YW5jZUlkIjoiMWI0OTQ1ODItZDg5Zi00MmY2LTg0YzAtNTAxOGE3NzI1Y2MyIiwiYXBwRGVmSWQiOiIxMzgwYjcwMy1jZTgxLWZmMDUtZjExNS0zOTU3MWQ5NGRmY2QiLCJtZXRhU2l0ZUlkIjoiN2RlM2ExNjgtNDEyNC00NDljLTg4ZDYtZmViNjkzYWY3NzRjIiwic2lnbkRhdGUiOiIyMDIwLTA5LTIzVDEyOjI3OjE4LjUyOVoiLCJ2ZW5kb3JQcm9kdWN0SWQiOiJQcmVtaXVtMSIsImRlbW9Nb2RlIjpmYWxzZSwiYWlkIjoiOWE0ZjJjNDAtMTIzNC00ZGM3LTg3OWEtMjIzZDMxMzI0N2E1IiwiYmlUb2tlbiI6IjY2YWFlNGVhLTk5YmItMDY2YS0wYzE2LWFlYWUzNGRkMmI4ZSIsInNpdGVPd25lcklkIjoiZmI0Y2Y2ODQtODZkZS00N2E0LWE2NjUtZjE4ZDcxYzA3YzUxIn0",
        "Content-Type": "application/json; charset=utf-8",
    },
    "body": `{"query":"query getProductBySlug($externalId: String!, $slug: String!, $withPricePerUnit: Boolean!, $withCountryCodes: Boolean!) {
          appSettings(externalId: $externalId) {
            widgetSettings
      }
      catalog {
            product(slug: $slug, onlyVisible: true) {
                id
                description
                isVisible
                sku
                ribbon
                price
                comparePrice
                discountedPrice
                formattedPrice
                formattedComparePrice
                formattedDiscountedPrice
                pricePerUnit @include(if: $withPricePerUnit)
                formattedPricePerUnit @include(if: $withPricePerUnit)
                pricePerUnitData @include(if: $withPricePerUnit) {
                baseQuantity
                baseMeasurementUnit
          }
          seoTitle
          seoDescription
          createVersion
          digitalProductFileItems {
                fileId
                fileType
                fileName
          }
          productItems {
                price
                comparePrice
                formattedPrice
                formattedComparePrice
                pricePerUnit @include(if: $withPricePerUnit)
                formattedPricePerUnit @include(if: $withPricePerUnit)
                optionsSelections
                isVisible
                inventory {
                status
                quantity
            }
            sku
            weight
            surcharge
            subscriptionPlans {
                list {
                id
                price
                formattedPrice
                pricePerUnit @include(if: $withPricePerUnit)
                formattedPricePerUnit @include(if: $withPricePerUnit)
              }
            }
          }
          name
          isTrackingInventory
          inventory {
            status
            quantity
          }
          isVisible
          isManageProductItems
          isInStock
          media {
            id
            url
            fullUrl
            altText
            thumbnailFullUrl: fullUrl(width: 50, height: 50)
            mediaType
            videoType
            videoFiles {
                url
                width
                height
                format
                quality
            }
            width
            height
            index
            title
          }
          customTextFields {
            title
            isMandatory
            inputLimit
          }
          nextOptionsSelectionId
          options {
            title
            optionType
            selections {
                id
                value
                description
                linkedMediaItems {
                    altText
                    url
                    fullUrl
                    thumbnailFullUrl: fullUrl(width: 50, height: 50)
                    mediaType
                    width
                    height
                    index
                    title
                    videoFiles {
                        url
                        width
                        height
                        format
                        quality
                    }
                }
            }
          }
          productType
          urlPart
          additionalInfo {
                id
            title
            description
            index
          }
          subscriptionPlans {
                list(onlyVisible: true) {
                  id
              name
              tagline
              frequency
              duration
              price
              formattedPrice
              pricePerUnit @include(if: $withPricePerUnit)
              formattedPricePerUnit @include(if: $withPricePerUnit)
            }
            oneTimePurchase {
                  index
            }
          }
          discount {
                mode
            value
          }
          currency
          weight
          seoJson
        }
      }
      localeData(language: "en") @include(if: $withCountryCodes) {
            countries {
              key
          shortKey
        }
      }
    }","variables":{"slug":productID,"externalId":"","withPricePerUnit":true,"withCountryCodes":false},"source":"WixStoresWebClient","operationName":"getProductBySlug"}`,
    "method": "POST",
});

This request will return a JSON that has the product options with title and selections which will be the features.

With this enhanced JSON Array we can build the database to serve this data.

Developer wanting to get involved in the OSS community

Hello
I am a Developer with solid background in the Telecom industry, specializing in C ++. I am interested in starting to collaborate on Open Source projects in order to improve my Go development skills. I found your project to be a good gateway for this community. I would like more information on how to collaborate.

I would like to contribute

Hello guys,

I have basic experience in Golang, and would like to improve it. Could I help the project with some issue?

Thank you!

Follow a Go project pattern/guidelines

Hi there!
Anyone has any suggestion on a project structure, best practies, linting, pattern, etc for us to follow?

As we are in the beginning of the project, I think that's a good opportunity for us to choose one and make the refactor.

Suggestions?

Python code for calculator

import tkinter as tk

root= tk.Tk()

canvas1 = tk.Canvas(root, width = 300, height = 300)
canvas1.pack()

entry1 = tk.Entry (root)
canvas1.create_window(210, 100, window=entry1)

entry2 = tk.Entry (root)
canvas1.create_window(210, 140, window=entry2)

entry3 = tk.Entry (root)
canvas1.create_window(210, 240, window=entry3)

label0 = tk.Label(root, text='Calculator')
label0.config(font=('helvetica', 14))
canvas1.create_window(150, 40, window=label0)

label1 = tk.Label(root, text='Type Value 1:')
label1.config(font=('helvetica', 10))
canvas1.create_window(100, 100, window=label1)

label2 = tk.Label(root, text='Type Value 2:')
label2.config(font=('helvetica', 10))
canvas1.create_window(100, 140, window=label2)

label3 = tk.Label(root, text='Result:')
label3.config(font=('helvetica', 10))
canvas1.create_window(100, 240, window=label3)

def add():
v1 = entry1.get()
v2 = entry2.get()

label4 = tk.Label(root, text= float(v1)+float(v2),font=('helvetica', 10, 'bold'),bg='white')
canvas1.create_window(210, 240, window=label4)

buttonAdd = tk.Button(text='+', command=add, bg='green', fg='white', font=('helvetica', 9, 'bold'), width = 5)
canvas1.create_window(90, 190, window=buttonAdd)

def sub():
v1 = entry1.get()
v2 = entry2.get()

label5 = tk.Label(root, text= float(v1)-float(v2),font=('helvetica', 10, 'bold'),bg='white')
canvas1.create_window(210, 240, window=label5)

buttonSub = tk.Button(text='โ€“', command=sub, bg='green', fg='white', font=('helvetica', 9, 'bold'), width = 5)
canvas1.create_window(140, 190, window=buttonSub)

def mul():
v1 = entry1.get()
v2 = entry2.get()

label6 = tk.Label(root, text= float(v1)*float(v2),font=('helvetica', 10, 'bold'),bg='white')
canvas1.create_window(210, 240, window=label6)

buttonMul = tk.Button(text='x', command=mul, bg='green', fg='white', font=('helvetica', 9, 'bold'), width = 5)
canvas1.create_window(190, 190, window=buttonMul)

def div():
v1 = entry1.get()
v2 = entry2.get()

label7 = tk.Label(root, text= float(v1)/float(v2),font=('helvetica', 10, 'bold'),bg='white')
canvas1.create_window(210, 240, window=label7)

buttonDiv = tk.Button(text='/', command=div, bg='green', fg='white', font=('helvetica', 9, 'bold'), width = 5)
canvas1.create_window(240, 190, window=buttonDiv)

root.mainloop()

Implement migration and database creation startup flags

Implement a command line flag --with-migration <url> that will instruct the main program to download data from a URL and insert in the database before bringing the server up.

If the database already has data, throw an error. We could create another flag --recreate-database that will drop and create a database from scratch. So, if the user executes:

$ stop-analyzing-api --recreate-database --with-migration https://endpoint-with-migration-data

The service will perform a clean start loading this data. This will be very useful for development porpuses.

How about that?

@jairsjunior or @flaviostutz, any thoughts?

docker-compose command failing

Hello! I'm facing this issue while running docker-compose build command:

Screen Shot 2021-01-08 at 07 45 07

Step 7/13 : RUN go run github.com/prisma/prisma-client-go generate --schema=/app/scripts/prisma/schema.prisma
 ---> Running in 6ea99da5dd8b
# github.com/prisma/prisma-client-go
/go/pkg/mod/github.com/prisma/[email protected]/generator.go:43:6: undefined: errors.Is
note: module requires Go 1.13

Probably, the Go version from the Dockerfile is not compatible with the Prisma version.

Welcome to Stop Analyzing API. Let's start?

If you want to contribute to this project, please create an issue asking for a task and provide a bit of information of how you can and would like to contribute. A maintainer will come to you and assign a suitable issue, giving all the needed details and guiding you through all the process.

This project follows the Poppins MANIFESTO guidelines and is managed to help open source beginners to level up their skills and increase their experience in a mentorship community atmosphere.

Migrate from DATABASE_URL environment variable to flag

Currently the database connection information is get from an environment variable DATABASE_URL. To be more a "go thing", we could change it to be a flag --databaseURL instead of the environment var. In some scenarios, the env would be used as the value of the flag, like --databaseURL=DATABASE_URL, but that would not be mandatory

Implement the migrationFromFile service

The service will receive a JSON filePath, validate if the schema is ok and insert the data from this file in the local database.

Just as a starting point, I created the package migration with the function migrateFromURL and migrateFromFile. The ideia is that when this issue is ready, the migrateFromURL with be as easy as downloading the file and invoking this function. But that's not on the scope here. We will tie all of this when the #6 is ready too.

How about this?

I want to contribute to the project

Hi, thanks for welcoming to start contributing to open source!
I have experience in Go for 9 months and few years for other languages.
I think it's time to start contributing to open source.
I would appreciate if you could give me some issue.

Dockerfile uses ubuntu

The current dockerfile uses Ubuntu as the base image ~180Mb.

Maybe alphine (~5Mb) would be a better fit? Or is there something we need from ubuntu?

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.