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
17 changes: 17 additions & 0 deletions test-api/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{compose.yaml,compose.*.yaml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
12 changes: 12 additions & 0 deletions test-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

###> symfony/framework-bundle ###
/.env
/.env.dev
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
89 changes: 89 additions & 0 deletions test-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# API de Investimentos

API REST em **Symfony 7** para gerenciamento de investidores, investimentos e resgates.
Utiliza **Doctrine ORM** para persistência de dados e **NelmioApiDocBundle** para documentação interativa no formato OpenAPI/Swagger.

## Tecnologias principais

- **PHP 8.3+**
- **Symfony 7**
- **Doctrine ORM**
- **MySQL**
- **Swagger/OpenAPI**

---

## Bibliotecas de terceiros adicionadas

| Biblioteca | Versão | Descrição no Projeto |
|-----------------------------------------|--------|--------------------------------------------------------------------------------------------------|
| **doctrine/dbal** | 3.10.1 | Camada de abstração de banco usada pelo Doctrine ORM para consultas SQL e manipulação do schema. |
| **doctrine/doctrine-bundle** | 2.15.1 | Integra o Doctrine ORM ao Symfony, lendo configs do `doctrine.yaml`. |
| **doctrine/doctrine-migrations-bundle** | 3.4.2 | Permite criar e rodar migrations para atualizar o schema do banco. |
| **doctrine/orm** | 3.5.2 | Mapeia entidades PHP para tabelas no banco de dados. |
| **nelmio/api-doc-bundle** | 5.5.0 | Gera documentação interativa dos endpoints usando Swagger UI. |
| **symfony/mailer** | 7.3.x | Envio de emails a partir da aplicação, usado no serviço de notificação. |
---

## Configuração e Compilação

**Pré-requisitos :**
- PHP 8.3+
- Composer 2.x
- MySQL ou outro banco suportado
- Extensões PHP: `pdo_mysql`, `mbstring`, `xml`, `intl`, `ctype`, `tokenizer`

### Clonar o projeto

> git clone https://github.com/lucianoarm/backend-test.git
> cd backend-test/test-api

### Instalar dependências

> composer install

### Configurar variáveis de ambiente

> **Copie o arquivo .env para .env.local e ajuste :**
> DATABASE_URL="mysql://usuario:[email protected]:3306/investimentos"
> APP_ENV=dev
> APP_SECRET=algumasecret

> **symfony/mailer**
> MAILER_DSN=smtp://seu_usuario:[email protected]:587
> [email protected]

### Criar banco de dados e aplicar migrations

> php bin/console doctrine:database:create
> php bin/console doctrine:migrations:migrate

### Rodar servidor local

> symfony server:start

API em: http://127.0.0.1:8000 <- esta url será usada para acessar a documnetação interativa
---

## Documentação da API

> **A documentação interativa gerada pelo Swagger está disponível em :**

> - http://127.0.0.1:8000/api/doc

> A url e porta neste exemplo é a mesma retornada no passo anterior.
> Neste documentação será possível testar os endpoints diretamente pelo navegador.

## Estrutura do Projeto

src/
├── Controller/
| └── Api/ → Endpoints da API
├── Entity/ → Entidades Doctrine
├── Repository/ → Repositórios de dados
├── Service/ → Calculo/Lógica de negócio
config/
├── packages/ → Configuração de bundles
├── routes/ → Arquivos de rotas
public/
└── index.php → Ponto de entrada da aplicação
21 changes: 21 additions & 0 deletions test-api/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env php
<?php

use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

return new Application($kernel);
};
18 changes: 18 additions & 0 deletions test-api/compose.override.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

services:
###> doctrine/doctrine-bundle ###
database:
ports:
- "5432"
###< doctrine/doctrine-bundle ###

###> symfony/mailer ###
mailer:
image: axllent/mailpit
ports:
- "1025"
- "8025"
environment:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
###< symfony/mailer ###
25 changes: 25 additions & 0 deletions test-api/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

services:
###> doctrine/doctrine-bundle ###
database:
image: postgres:${POSTGRES_VERSION:-16}-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-app}
# You should definitely change the password in production
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
POSTGRES_USER: ${POSTGRES_USER:-app}
healthcheck:
test: ["CMD", "pg_isready", "-d", "${POSTGRES_DB:-app}", "-U", "${POSTGRES_USER:-app}"]
timeout: 5s
retries: 5
start_period: 60s
volumes:
- database_data:/var/lib/postgresql/data:rw
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/db/data:/var/lib/postgresql/data:rw
###< doctrine/doctrine-bundle ###

volumes:
###> doctrine/doctrine-bundle ###
database_data:
###< doctrine/doctrine-bundle ###
80 changes: 80 additions & 0 deletions test-api/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/dbal": "^3",
"doctrine/doctrine-bundle": "^2.15",
"doctrine/doctrine-migrations-bundle": "^3.4",
"doctrine/orm": "^3.5",
"nelmio/api-doc-bundle": "^5.5",
"symfony/asset": "7.3.*",
"symfony/console": "7.3.*",
"symfony/dotenv": "7.3.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "7.3.*",
"symfony/mailer": "7.3.*",
"symfony/runtime": "7.3.*",
"symfony/twig-bundle": "7.3.*",
"symfony/yaml": "7.3.*",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"bump-after-update": true,
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*",
"symfony/polyfill-php82": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.3.*"
}
},
"require-dev": {
"symfony/maker-bundle": "^1.64"
}
}
Loading