Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions COMMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Decisão da Arquitetura Utilizada

O projeto foi organizado em duas partes principais:

- **api/**: Contém o backend, responsável por fornecer os endpoints da aplicação. Utilizando a arquitetura e estrutura de pastas padrão do framework Nestjs.
- **web/**: Contém o frontend, responsável pela interface do usuário.

Essa separação permite um desenvolvimento desacoplado, facilitando a manutenção e escalabilidade da aplicação.

## Lista de Bibliotecas de Terceiros Utilizadas

### Backend (`api/`)

- **NestJS**: Framework backend.
- **TypeORM**: ORM para banco de dados.
- **JWT**: Autenticação.
- **Docker**: Containerização.
- **Jest**: Testes unitários.
- **Swagger**: Documentação.

### Frontend (`web/`)

- **Vue.js**: Framework frontend.
- **Vuetify**: Biblioteca de componentes UI.

## O que eu faria se tivesse mais tempo

- Com certeza trabalharia na separação de responsabilidades do frontend, em uma melhor estrutura de pastas (services, pages, components, modals etc)
- Melhorar a estilização ta tabela e o sidebar
- Faria o processo de lougout tanto back quanto frontend
- Teste de integração subindo uma imagem docker do node, banco, seeders para inicializar os dados principais

## Quais requisitos obrigatórios não foram entregues

- Não realizei o processo de commits por parte do front, pois eu precisei alterar o projeto algumas vezes, visto que nunca trabalhei com vue e nem vuetify
- Se tratavam de telas para cadastro/edição e não apenas modais, foi um equivoco meu
11 changes: 11 additions & 0 deletions api/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NODE_ENV=development

HTTP_PORT=3000

JWT_SECRET=secret

DB_HOST=localhost
DB_PORT=5432
DB_USER=root
DB_PASSWORD=root
DB_NAME=postgres
25 changes: 25 additions & 0 deletions api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
56 changes: 56 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# temp directory
.temp
.tmp

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

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1 change: 1 addition & 0 deletions api/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v23.6.0
4 changes: 4 additions & 0 deletions api/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
77 changes: 77 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<h1>Api para o desafio fullstack</h1>

<h2>Como executar o projeto</h2>
<h3>Requisitos</h3>
Será necessário possuir instalado na máquina os seguintes componentes:

- Node : 23.x.x
- Yarn/Npm
- Docker
- Docker-Compose

<h3>Instalando dependências do projeto</h3>

Via terminal, navegue até a pasta criada, onde foi depositado o clone do projeto, e execute o comando `yarn`. Todas as dependências do projeto serão instaladas.

<h3>Preparando o banco de dados</h3>

Ainda no terminal execute o comando `docker-compose up -d` para instanciar o banco de dados Postgres.

Uma vez que os container tenham sido criados, execute o comando `yarn start:dev` no seu terminal. Isto irá criar todos os objetos de banco de dados necessários para o funcionamento da API. Isso inclui o primeiro usuário administrativo do sistema:

<h3>Executando o projeto</h3>

Com todas as dependências resolvidas, ao executar o comando de inicialização você poderá acessá-la através da url http://localhost:3000

<h3>Executando os testes</h3>

Para executar os testes e os testes de cobertura execute `yarn test` ou `yarn test:cov`, a cobertura de testes foi feita apenas com as services.

<h3>Utilizando a API</h3>

O primeiro passo é acessar o usuário com as credenciais:

User: admin@admin.com
Pass: admin123

Caso acessado via postman ou outra ferramenta será necessário colocar o método de autenticação `Bearar` e adicionar o token passado pela api.

<h3>Rotas da API</h3>

Para acessar a documentação basta inicializar o sistema e acessar o caminho `http://localhost:3000/docs`

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Project setup

```bash
$ yarn install
```

## Compile and run the project

```bash
# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod
```

## Run tests

```bash
# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov
```
25 changes: 25 additions & 0 deletions api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.7'

services:
database:
image: postgres
container_name: database_students
restart: always
ports:
- '5432:5432'
environment:
- POSTGRES_USER=root
- POSTGRES_PASSWORD=root
- POSTGRES_DB=postgres
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- backend

volumes:
pgdata:
driver: local

networks:
backend:
driver: 'bridge'
66 changes: 66 additions & 0 deletions api/migrations/1738786824962-create-table-users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';
import * as bcrypt from 'bcrypt';

export class CreateTableUsers1738786824962 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'users',
columns: [
{
name: 'id',
type: 'uuid',
isPrimary: true,
generationStrategy: 'uuid',
default: 'uuid_generate_v4()',
},
{
name: 'name',
type: 'varchar',
length: '255',
},
{
name: 'email',
type: 'varchar',
length: '255',
isUnique: true,
},
{
name: 'password',
type: 'varchar',
length: '255',
},
{
name: 'created_at',
type: 'timestamp',
default: 'CURRENT_TIMESTAMP',
},
{
name: 'updated_at',
type: 'timestamp',
default: 'CURRENT_TIMESTAMP',
onUpdate: 'CURRENT_TIMESTAMP',
},
],
}),
);

const password = 'admin123';
const hashedPassword = await bcrypt.hash(password, 10);

await queryRunner.manager
.createQueryBuilder()
.insert()
.into('users')
.values({
name: 'Administrador',
email: 'admin@admin.com',
password: hashedPassword,
})
.execute();
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('users');
}
}
58 changes: 58 additions & 0 deletions api/migrations/1738786827294-create-table-students.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class CreateTableStudents1738786827294 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'students',
columns: [
{
name: 'id',
type: 'uuid',
isPrimary: true,
generationStrategy: 'uuid',
default: 'uuid_generate_v4()',
},
{
name: 'name',
type: 'varchar',
length: '255',
},
{
name: 'email',
type: 'varchar',
length: '255',
isUnique: true,
},
{
name: 'ra',
type: 'varchar',
length: '20',
isUnique: true,
},
{
name: 'cpf',
type: 'varchar',
length: '11',
isUnique: true,
},
{
name: 'created_at',
type: 'timestamp',
default: 'CURRENT_TIMESTAMP',
},
{
name: 'updated_at',
type: 'timestamp',
default: 'CURRENT_TIMESTAMP',
onUpdate: 'CURRENT_TIMESTAMP',
},
],
}),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('students');
}
}
8 changes: 8 additions & 0 deletions api/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading