Skip to content

Commit

Permalink
adicionando novo trabalho; falta explicar como rodar os bancos
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermedelyra committed Aug 20, 2021
1 parent 71de556 commit 1256fdd
Show file tree
Hide file tree
Showing 287 changed files with 12,062 additions and 11 deletions.
78 changes: 67 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,76 @@ A Gestão de Configuração de Software é parte fundamental no curso de GCES, e

Para exercitar estes conhecimentos, você deverá aplicar os conceitos estudados ao longo da disciplina no produto de software contido neste repositório.

O sistema se trata de uma aplicação Web que é composta de:
O sistema se trata de uma aplicação Web em Typescript, que é composta de:

- Front-end escrito em Javascript, utilizando os frameworks Next.js + SWR;
- Back-end escrito em Python, utilizando o framework FastAPI;
- Banco de Dados PostgreSQL;
- Front-end escrito em React (`chat-app`);
- Back-end dividido em três microsserviços:
- `users-service`: express + ORM
- `chat-service`: não implementado
- `api-gateway`: graphql
- 2 Bancos de Dados MySQL 5.7.20 para users-service e chat-service (mesmo este não tendo sido implementado ainda)
- `phpmyadmin`, como interface para gerenciamento dos bancos de dados

Para executar a aplicação em sua máquina, basta seguir o passo-a-passo descrito no arquivos s README das pastas [backend](./backend/README.md) e [frontend](./frontend/README.md).
Para executar a aplicação em sua máquina, basta seguir o passo-a-passo descrito no arquivos README das pastas.

- [users-service](./trabalho_individual/users-service/README.md)
- [chat-service](./trabalho_individual/chat-service/README.md).
- [api-gateway](./trabalho_individual/api-gateway/README.md).
- [chat-app](./trabalho_individual/chat-app/README.md).
- [phpmyadmin](./trabalho_individual/phpmyadmin/README.md).

## Resumo da aplicação

Essa aplicação é um blog + rede social (clone do Medium.com) chamado de "Conduit". Para ver uma demo funcionando, clique aqui: [https://next-realworld.now.sh/](https://next-realworld.now.sh/)
É uma aplicação extremamente simples, não possui muitas features, então o foco é justamente na containerização (e orquestração) dessa aplicação. Por ora, só é possivel fazer login (alem de interagir com o banco etc)

Aqui um esquema simples de como a aplicação se comunica:

![diagrama](https://imgur.com/RKfPSxI.png)

### Prints de telas da aplicação

#### Frontend - chat-app

<figure>
<img
src="https://imgur.com/qA6nPGF.png"
alt="tela de carregamento">
<figcaption>tela de carregamento</figcaption>
</figure>

<figure>
<img
src="https://imgur.com/rKmSwkF.png"
alt="tela de login">
<figcaption>tela de login</figcaption>
</figure>

## Exemplos Anteriores
<figure>
<img
src="https://imgur.com/npIvJhU.png"
alt="tela pós-login">
<figcaption>tela pós-login</figcaption>
</figure>

### phpmyadmin

<figure>
<img
src="https://imgur.com/2zUF6QB.png"
alt="tela de gerenciamento do banco">
<figcaption>tela de gerenciamento do banco</figcaption>
</figure>

### api-gateway

<figure>
<img
src="https://imgur.com/lWo6F2S.png"
alt="tela de queries em graphql">
<figcaption>tela de queries em graphql</figcaption>
</figure>

## Trabalhos Anteriores

Alguns trabalhos de exemplo do [semestre passado](https://github.com/FGA-GCES/Trabalho-Individual-2020-2):

Expand All @@ -42,7 +99,6 @@ Para realizar esta parte do trabalho, recomenda-se a utilização das ferramenta
- Docker versão 17.04.0+
- Docker Compose com sintaxe na versão 3.2+


## Nota

A nota de cada aluno será a soma dos itens abaixo que serão avaliados tanto de forma quantitativa (se foi realizado a implementação + documentação), quanto qualitativamente (como foi implementado, entendimento dos conceitos na prática, complexidade da solução). Faça os commits atômicos, bem documentados, completos a fim de facilitar o entendimento e avaliação do seu trabalho. Lembrando que esse trabalho é individual.
Expand All @@ -51,8 +107,8 @@ Os Itens de avaliação são (cada item tem peso 2.5 na nota final de 0 - 10):

**1. Containerização**

- Container do Back-end
- Containers do Back-end
- Container do Front-end
- Container do Banco de Dados
- Containers dos Banco de Dados
- Container para o phpmyadmin
- Automação entre os containers (Docker-compose)

File renamed without changes.
45 changes: 45 additions & 0 deletions sample_project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Trabalho Individual 01 2021.1

A Gestão de Configuração de Software é parte fundamental no curso de GCES, e dominar os conhecimentos de configuração de ambiente, containerização, virtualização, integração e deploy contínuo tem se tornado cada vez mais necessário para ingressar no mercado de trabalho.

Para exercitar estes conhecimentos, você deverá aplicar os conceitos estudados ao longo da disciplina no produto de software contido neste repositório.

O sistema se trata de uma aplicação Web que é composta de:

- Front-end escrito em Javascript, utilizando os frameworks Next.js + SWR;
- Back-end escrito em Python, utilizando o framework FastAPI;
- Banco de Dados PostgreSQL;

Para executar a aplicação em sua máquina, basta seguir o passo-a-passo descrito no arquivos s README das pastas [backend](./backend/README.md) e [frontend](./frontend/README.md).

## Resumo da aplicação

Essa aplicação é um blog + rede social (clone do Medium.com) chamado de "Conduit". Para ver uma demo funcionando, clique aqui: [https://next-realworld.now.sh/](https://next-realworld.now.sh/)

## Critérios de avaliação

### 1. Containerização

A aplicação deverá ter seu ambiente completamente containerizado. Desta forma, cada subsistema (Front-end, Back-end e Banco de Dados) deverá ser isolado em um container individual.

Deverá ser utilizado um orquestrador para gerenciar comunicação entre os containers, o uso de credenciais, networks, volumes, entre outras configurações necessárias para a correta execução da aplicação.

Para realizar esta parte do trabalho, recomenda-se a utilização das ferramentas:

- Docker versão 17.04.0+
- Docker Compose com sintaxe na versão 3.2+


## Nota

A nota de cada aluno será a soma dos itens abaixo que serão avaliados tanto de forma quantitativa (se foi realizado a implementação + documentação), quanto qualitativamente (como foi implementado, entendimento dos conceitos na prática, complexidade da solução). Faça os commits atômicos, bem documentados, completos a fim de facilitar o entendimento e avaliação do seu trabalho. Lembrando que esse trabalho é individual.

Os Itens de avaliação são (cada item tem peso 2.5 na nota final de 0 - 10):

**1. Containerização**

- Container do Back-end
- Container do Front-end
- Container do Banco de Dados
- Automação entre os containers (Docker-compose)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
116 changes: 116 additions & 0 deletions trabalho_individual/api-gateway/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
31 changes: 31 additions & 0 deletions trabalho_individual/api-gateway/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Express.js & ORM

## Pré-requisitos

- yarn ou npm

> aqui no tutorial usaremos yarn
## Passo a passo

Primeiro, clone o repositorio

```console
git clone https://github.com/FGA-GCES/Workshop-Docker-Entrega-01

cd Workshop-Docker-Entrega-01/trabalho_individual/api-gateway
```

Instale as dependencias:

```console
yarn
```

Rode a aplicação:

```console
yarn watch
```

Acesse o app em [http://localhost:7000](http://localhost:7000).
2 changes: 2 additions & 0 deletions trabalho_individual/api-gateway/config/default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const PORT = 7000;
export const USERS_SERVICE_URI = "http://users-service:7101";
5 changes: 5 additions & 0 deletions trabalho_individual/api-gateway/index.dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// for development purposes only, we include module-alias

import "module-alias/register";

import "./src/index";
28 changes: 28 additions & 0 deletions trabalho_individual/api-gateway/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "api-gateway",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"watch": "ts-node-dev --respawn index.dev.ts"
},
"devDependencies": {
"@types/config": "~0.0.38",
"@types/cookie-parser": "~1.4.2",
"module-alias": "~2.2.2",
"ts-node-dev": "~1.1.1",
"typescript": "~4.1.3"
},
"dependencies": {
"apollo-server": "~2.19.2",
"apollo-server-express": "~2.19.2",
"config": "~3.3.3",
"cookie-parser": "~1.4.5",
"cors": "~2.8.5",
"express": "~4.17.1",
"got": "~11.8.1",
"graphql": "~15.5.0"
},
"_moduleAliases": {
"#root": "./src"
}
}
52 changes: 52 additions & 0 deletions trabalho_individual/api-gateway/src/adapters/UsersService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import config from "config";
import got from "got";

const USERS_SERVICE_URI = <string>config.get("USERS_SERVICE_URI");

export interface User {
createdAt: string;
id: string;
username: string;
}

export interface UserSession {
createdAt: string;
expiresAt: string;
id: string;
userId: string;
}

export default class UsersService {
static async createUser({ password, username }: { password: string; username: string }) {
const body = await got.post(`${USERS_SERVICE_URI}/users`, { json: { password, username } }).json();
return body;
}

static async createUserSession({ password, username }: { password: string; username: string }) {
const body = <UserSession>await got.post(`${USERS_SERVICE_URI}/sessions`, { json: { password, username } }).json();
return body;
}

static async deleteUserSession({ sessionId }: { sessionId: string }) {
const body = await got.delete(`${USERS_SERVICE_URI}/sessions/${sessionId}`).json();
return body;
}

static async fetchUser({ userId }: { userId: string }): Promise<User | null> {
const body = await got.get(`${USERS_SERVICE_URI}/users/${userId}`).json();
if (!body) return null;
return <User>body;
}

static async fetchUserSession({ sessionId }: { sessionId: string }): Promise<UserSession | null> {
const body = await got
.get(`${USERS_SERVICE_URI}/sessions/${sessionId}`)
.json()
.catch((err) => {
if (err.response.statusCode === 404) return null;
throw err;
});
if (!body) return null;
return <UserSession>body;
}
}
Loading

0 comments on commit 1256fdd

Please sign in to comment.