Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a0f89c0
Finalizando teste
pedrohmarques Apr 3, 2022
ba094be
finalizando frontend
pedrohmarques Apr 3, 2022
717f6a3
add heroku,yml
pedrohmarques Apr 3, 2022
5d679bf
add heroku.yml
pedrohmarques Apr 3, 2022
0208e69
add heroku.yml
pedrohmarques Apr 3, 2022
4f03e4c
add heroku.yml
pedrohmarques Apr 3, 2022
e35605d
add heroku.yml
pedrohmarques Apr 3, 2022
811c97a
add heroku.yml
pedrohmarques Apr 3, 2022
fb150ec
add heroku.yml
pedrohmarques Apr 3, 2022
fae432b
add heroku.yml
pedrohmarques Apr 3, 2022
8118cdf
add heroku.yml
pedrohmarques Apr 3, 2022
8c6ebe1
mudanças back
pedrohmarques Apr 3, 2022
5ec5416
docker-compose
pedrohmarques Apr 3, 2022
d7675aa
add heroku.yml
pedrohmarques Apr 3, 2022
14eef0f
add heroku.yml
pedrohmarques Apr 3, 2022
9dcc365
add heroku.yml
pedrohmarques Apr 3, 2022
ac1184b
add heroku.yml
pedrohmarques Apr 3, 2022
81ebb60
add heroku.yml
pedrohmarques Apr 3, 2022
edd76ca
add heroku.yml
pedrohmarques Apr 3, 2022
e3446f7
add heroku.yml
pedrohmarques Apr 3, 2022
dbc6c53
add heroku.yml
pedrohmarques Apr 3, 2022
aa8fe7c
add heroku.yml
pedrohmarques Apr 3, 2022
0416c81
add heroku.yml
pedrohmarques Apr 3, 2022
c4669e2
add heroku.yml front
pedrohmarques Apr 3, 2022
c8d1033
add heroku.yml
pedrohmarques Apr 3, 2022
8e542ed
add heroku.yml
pedrohmarques Apr 3, 2022
2e29260
add heroku.yml
pedrohmarques Apr 4, 2022
b62fbe4
add heroku.yml
pedrohmarques Apr 4, 2022
6c8bbe0
add heroku.yml
pedrohmarques Apr 4, 2022
8dc88e2
Finalização app
pedrohmarques Apr 4, 2022
e05e324
baseUrl
pedrohmarques Apr 4, 2022
a950ac7
Update README.md
pedrohmarques Apr 4, 2022
36fc86b
Update README.md
pedrohmarques Apr 4, 2022
5cb3da9
Update README.md
pedrohmarques Apr 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nuxt.isNuxtApp": false
}
54 changes: 38 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
# Desafio técnico para desenvolvedores
# Frontend (Vue 3)

Construa uma nova aplicação, utilizando o framework de sua preferência (Ruby on Rails, Elixir Phoenix, Python Django ou Flask, NodeJS Sails, Java Spring, ASP.NET ou outro), a qual deverá conectar na API do GitHub e disponibilizar as seguintes funcionalidades:
Aplicação Web desenvolvida em Vue 3 composition api e spectre-css, com a finalidade de demonstrar visualmente os repositorios minerados pela API do GitHub.

- Botão para buscar e armazenar os repositórios destaques de 5 linguagens à sua escolha;
- Listar os repositórios encontrados;
- Visualizar os detalhes de cada repositório.
# Backend (Flask)

Alguns requisitos:
API desenvolvida utilizando o framework Flask, para a realização da mineiração dos repositorios e conexão no banco de dados MYSQL para armanezar os dados encontrados, disponibilizando-a para aplicação web.

- Deve ser uma aplicação totalmente nova;
- A solução deve estar em um repositório público do GitHub;
- A aplicação deve armazenar as informações encontradas;
- Utilizar PostgreSQL, MySQL ou SQL Server;
- O deploy deve ser realizado, preferencialmente, no Heroku, AWS ou no Azure;
- A aplicação precisa ter testes automatizados;
- Preferenciamente dockerizar a aplicação;
- Por favor atualizar o readme da aplicação com passo a passo com instrução para subir o ambiente.
- Atualmente na base de dados implantada na AWS RDS, possui 5 linguagens, sendo eles Java, Vue, Python, C#, JavaScript. Caso queira adicionar uma nova, é necessario apenas realizar a pesquisa pela aplicação web, que será buscado os 100 primeiros repositorios mais populares da linguagem pesquisada e salva no banco de dados.

Quando terminar, faça um Pull Request neste repo e avise-nos por email.
# Local

**IMPORTANTE:** se você não conseguir finalizar o teste, por favor nos diga o motivo e descreva quais foram as suas dificuldades. Você pode também sugerir uma outra abordagem para avaliarmos seus skills técnicos, vender seu peixe, mostrar-nos do que é capaz.
## Frontend (Porta 8080)

``` bash
cd frontend
npm install
npm run serve
```
# Jest

``` bash
npm run test:watch
```
- Open localhost:8080 on browser

## API (Porta 5000)

``` bash
cd backend
pip install -r requirements.txt
python app.py
```

# Docker

Na raiz do projeto rodar o seguinte comando:
``` bash
docker-compose up -d --build
```

# Heroku

https://ateliwarehiring.herokuapp.com/
9 changes: 9 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
__pycache__/

.gitignore

Pipfile

Pipfile.lock

README.MD
11 changes: 11 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.8-slim-buster

WORKDIR /app

COPY requirements.txt requirements.txt

RUN pip3 install -r requirements.txt

COPY . .

CMD [ "python", "app.py"]
Binary file added backend/__pycache__/bd.cpython-310.pyc
Binary file not shown.
Binary file added backend/__pycache__/repositories.cpython-310.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions backend/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from flask import Flask, request
from flask_cors import CORS
import os
from repositories import Repository
from bd import MySql
import json


app = Flask(__name__)
port = int(os.environ.get("PORT", 5000))
CORS(app)

@app.route('/')
def home():
repositories_bd = MySql().select_language('Java')
return repositories_bd

@app.route('/repo', methods =['POST'])
def get_Repo():
repositories_bd = MySql().select_language(request.json['language'])

if(len(json.loads(repositories_bd)) < 1):
repositories = Repository().get_repositories(request.json['language'])
MySql().insert_new_language(repositories)
repositories_bd = MySql().select_language(request.json['language'])

return repositories_bd

if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=port)
57 changes: 57 additions & 0 deletions backend/bd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import mysql.connector
import json

class MySql:
def __init__(self):
self.teste = 'oi'

def connect_with_db(self):
config = {
'user': 'pedro_werik',
'password': 'tcc2022puc',
'host': 'tccbase.cuotubehzepx.us-east-1.rds.amazonaws.com',
'database': 'tccbase',
'auth_plugin':'mysql_native_password',
'raise_on_warnings': True
}

cnx = mysql.connector.connect(**config)
return cnx

def insert_new_language(self, repositories):
cnx = self.connect_with_db()
cursor = cnx.cursor()
query = """INSERT INTO REPOSITORIE_ATELIWARE (OWNER, URL, LANGUAGE, CREATED_AT, UPDATED_AT, STARGAZER, RELEASES) VALUES (%s, %s, %s, %s, %s, %s, %s)"""
for repo in repositories:
cursor.execute(
query,
(repo['nameWithOwner'],
repo['sshUrl'],
repo['primaryLanguage']['name'],
repo['createdAt'][0:10],
repo['updatedAt'][0:10],
repo['stargazers']['totalCount'],
repo['releases']['totalCount'],
)
)
cnx.commit()

cursor.close()
cnx.close()

def select_language(self, language):
cnx = self.connect_with_db()
cursor = cnx.cursor()
query = ("""SELECT * FROM REPOSITORIE_ATELIWARE WHERE LANGUAGE = %s""")
cursor.execute(query, (language, ))
row_headers=[x[0] for x in cursor.description]
result = cursor.fetchall()
json_data=[]

for res in result:
json_data.append(dict(zip(row_headers, res)))

cursor.close()
cnx.close()
return json.dumps(json_data, indent=4, sort_keys=True, default=str)

51 changes: 51 additions & 0 deletions backend/repositories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import requests

class Repository:
def __init__(self):
self.token = "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"
self.path = "https://api.github.com/graphql"

def __get_query(self, language, after):
query = f"""
{{
search(first:100, {after}, query:"stars:>100 language:{language} ", type:REPOSITORY){{
pageInfo{{
startCursor
hasNextPage
endCursor
}}
nodes{{
... on Repository {{
nameWithOwner
sshUrl
createdAt
updatedAt
primaryLanguage {{
name
}}
stargazers {{
totalCount
}}
releases {{
totalCount
}}
}}
}}
}}
}}
"""
return query

def get_repositories(self, language):
headers = headers = {'Authorization': f'Bearer {self.token}'}
after = 'after: null'
res = []
for i in range(1):
query = self.__get_query(language, after)
result = requests.post(self.path, json={'query': query}, headers=headers)
if result.status_code == 200:
data = result.json()['data']['search']
after = f"""after: "{ data['pageInfo']['endCursor'] }" """
repositories = list(map(lambda x: x, data['nodes']))
res = res + repositories
return res
7 changes: 7 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Flask==2.1.1
Flask-Cors==3.0.10
MarkupSafe==2.1.1
mysql-connector==2.2.9
mysql-connector-python==8.0.28
mysql-connector-python-rf==2.2.2
requests==2.27.1
14 changes: 14 additions & 0 deletions db/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE DATABASE ateliware;
use ateliware;

CREATE TABLE REPOSITORIE (
ID int NOT NULL AUTO_INCREMENT,
OWNER varchar(255),
URL varchar(255),
LANGUAGE varchar(255),
CREATED_AT DATE,
UPDATED_AT DATE,
STARGAZER int,
RELEASES int,
PRIMARY KEY (ID)
);
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'

services:
flask-ateliware:
build: ./backend
ports:
- 5000:5000

vue-ateliware:
build: ./frontend
ports:
- 8080:8080
command: 'npm run serve'
23 changes: 23 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
26 changes: 26 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#Base image
FROM node:lts-alpine

#Install serve package
RUN npm i -g serve

# Set the working directory
WORKDIR /app

# Copy the package.json and package-lock.json
COPY package*.json ./

# install project dependencies
RUN npm install

# Copy the project files
COPY . .

# Build the project
RUN npm run build

# Expose a port
EXPOSE 8080

# Executables
CMD [ "serve", "-s", "dist" ]
24 changes: 24 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frontend

## Project setup
```
yarn install
```

### Compiles and hot-reloads for development
```
yarn serve
```

### Compiles and minifies for production
```
yarn build
```

### Lints and fixes files
```
yarn lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 5 additions & 0 deletions frontend/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
3 changes: 3 additions & 0 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
preset: '@vue/cli-plugin-unit-jest'
}
19 changes: 19 additions & 0 deletions frontend/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}
Loading