Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desenvolvimento do teste de back-end #46

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
20ec703
:heavy_plus_sign: build: criacao da base do projeto em symfony
luan441 Nov 18, 2022
3a46998
:heavy_plus_sign: build: add SymfonyMakerBundle
luan441 Nov 18, 2022
c0d0bd0
:heavy_plus_sign: build: dependencias e config de banco de dados
luan441 Nov 20, 2022
b8ee7c3
:heavy_plus_sign: build: dependencia de seguranca do symfony
luan441 Nov 20, 2022
62a2d0f
:heavy_plus_sign: build: dependencia de uuid
luan441 Nov 20, 2022
db5e8ee
:sparkles: feat: entidade de usuario
luan441 Nov 21, 2022
b4c72c7
:construction: controller para criar usuario
luan441 Nov 21, 2022
bf7bfb9
:heavy_plus_sign: build: dependencia de validacao do symfony
luan441 Nov 21, 2022
f1fedf1
:sparkles: feat: registro de usuario
luan441 Nov 21, 2022
98b4a08
:fire: Removendo comentario desnecessario
luan441 Nov 21, 2022
9dd8609
:heavy_plus_sign: build: instalacao bundle de JWT do symfony
luan441 Nov 21, 2022
ee07f18
:wrench: chore: configuracao de login do JWT
luan441 Nov 21, 2022
d8da0e2
:sparkles: feat: entidade de investimento
luan441 Nov 21, 2022
905a8bb
:recycle: refactor: arrumando tipagem do id
luan441 Nov 22, 2022
f3065a5
:sparkles: feat: criacao de investimento
luan441 Nov 22, 2022
3e7ccd1
:sparkles: feat: visualizacao de investimento
luan441 Nov 23, 2022
0db51e7
:sparkles: feat: retirada de investimento
luan441 Nov 23, 2022
7378952
:sparkles: feat: lista de investimento
luan441 Nov 23, 2022
9255a9d
:heavy_plus_sign: build: dependencia de teste phpunit
luan441 Nov 23, 2022
c27293d
:white_check_mark: test: Teste de service de calculadora de investimento
luan441 Nov 24, 2022
18faaec
:books: docs: escrevendo readme
luan441 Nov 24, 2022
3848d04
:recycle: refactor: correcao da aspas no README.md
luan441 Nov 24, 2022
6260fb4
:books: docs: add links para o escopo e a API
luan441 Nov 24, 2022
67656f1
:books: docs: documentacao da API
luan441 Nov 24, 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
35 changes: 35 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=cf3bc1e10af3b41640915e46c589128b
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4"
DATABASE_URL="postgresql://app:[email protected]:5432/app?serverVersion=14&charset=utf8"
###< doctrine/doctrine-bundle ###

###> lexik/jwt-authentication-bundle ###
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=b0f2e69261fdd84fe84b916cf167e78d
###< lexik/jwt-authentication-bundle ###
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> lexik/jwt-authentication-bundle ###
/config/jwt/*.pem
###< lexik/jwt-authentication-bundle ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###
107 changes: 35 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,51 @@
# Back End Test Project <img src="https://coderockr.com/assets/images/coderockr.svg" align="right" height="50px" />
# Back End Test Project

You should see this challenge as an opportunity to create an application following modern development best practices (given the stack of your choice), but also feel free to use your own architecture preferences (coding standards, code organization, third-party libraries, etc). It’s perfectly fine to use vanilla code or any framework or libraries.
Este projeto é construido em symfony.

## Scope
[Click aqui](/doc/escopo.md) para ver o escopo do teste.<br>
[Click aqui](/api/escopo.md) para ver a documentação da API.

In this challenge you should build an API for an application that stores and manages investments, it should have the following features:
## Bibliotecas instaladas

1. __Creation__ of an investment with an owner, a creation date and an amount.
1. The creation date of an investment can be today or a date in the past.
2. An investment should not be or become negative.
2. __View__ of an investment with its initial amount and expected balance.
1. Expected balance should be the sum of the invested amount and the [gains][].
2. If an investment was already withdrawn then the balance must reflect the gains of that investment
3. __Withdrawal__ of a investment.
1. The withdraw will always be the sum of the initial amount and its gains,
partial withdrawn is not supported.
2. Withdrawals can happen in the past or today, but can't happen before the investment creation or the future.
3. [Taxes][taxes] need to be applied to the withdrawals before showing the final value.
4. __List__ of a person's investments
1. This list should have pagination.
- [SymfonyMakerBundle](https://symfony.com/bundles/SymfonyMakerBundle/current/index.html)
- [DoctrineBundle](https://symfony.com/bundles/DoctrineBundle/current/installation.html)
- [SymfonySecurityBundle](https://symfony.com/doc/current/security.html)
- [SymfonyUid](https://symfony.com/doc/current/components/uid.html#installation)
- [LexikJWTAuthenticationBundle](https://symfony.com/bundles/LexikJWTAuthenticationBundle/current/index.html)
- [PhpUnit](https://symfony.com/doc/current/testing.html#the-phpunit-testing-framework)
- [SymfonyValidation](https://symfony.com/doc/current/validation.html#installation)

__NOTE:__ the implementation of an interface will not be evaluated.
## Instalação do Projeto

### Gain Calculation
### Dependencias

The investment will pay 0.52% every month in the same day of the investment creation.
- PHP >- 8.1
- composer
- docker
- docker-compose

Given that the gain is paid every month, it should be treated as [compound gain][], which means that every new period (month) the amount gained will become part of the investment balance for the next payment.
### Guia de instalação

### Taxation
para instalação em ambiente local, faça o clone do projeto e use o composer para instalar as dependencias:

When money is withdrawn, tax is triggered. Taxes apply only to the profit/gain portion of the money withdrawn. For example, if the initial investment was 1000.00, the current balance is 1200.00, then the taxes will be applied to the 200.00.
```
composer install
```

The tax percentage changes according to the age of the investment:
* If it is less than one year old, the percentage will be 22.5% (tax = 45.00).
* If it is between one and two years old, the percentage will be 18.5% (tax = 37.00).
* If older than two years, the percentage will be 15% (tax = 30.00).
Use o docker compose para instalar o banco de dados, eu utilizo mysql mas pode ficar a sua escolha, siga a documentação para instalar outros bancos de dados [documentação](https://symfony.com/doc/current/doctrine.html#configuring-the-database).

## Requirements
1. Create project using any technology of your preference. It’s perfectly OK to use vanilla code or any framework or libraries;
2. Although you can use as many dependencies as you want, you should manage them wisely;
3. It is not necessary to send the notification emails, however, the code required for that would be welcome;
4. The API must be documented in some way.
```
docker-compose up -d db
```

## Deliverables
The project source code and dependencies should be made available in GitHub. Here are the steps you should follow:
1. Fork this repository to your GitHub account (create an account if you don't have one, you will need it working with us).
2. Create a "development" branch and commit the code to it. Do not push the code to the main branch.
3. Include a README file that describes:
- Special build instructions, if any
- List of third-party libraries used and short description of why/how they were used
- A link to the API documentation.
4. Once the work is complete, create a pull request from "development" into "main" and send us the link.
5. Avoid using huge commits hiding your progress. Feel free to work on a branch and use `git rebase` to adjust your commits before submitting the final version.
Se tiver o [symfony-cli](https://symfony.com/download) use o seguinte comando:

## Coding Standards
When working on the project be as clean and consistent as possible.
```
symfony server:start
```

## Project Deadline
Ideally you'd finish the test project in 5 days. It shouldn't take you longer than a entire week.
Caso não tenha symfony-cli use o PHP puro:

## Quality Assurance
Use the following checklist to ensure high quality of the project.

### General
- First of all, the application should run without errors.
- Are all requirements set above met?
- Is coding style consistent?
- The API is well documented?
- The API has unit tests?

## Submission
1. A link to the Github repository.
2. Briefly describe how you decided on the tools that you used.

## Have Fun Coding 🤘
- This challenge description is intentionally vague in some aspects, but if you need assistance feel free to ask for help.
- If any of the seems out of your current level, you may skip it, but remember to tell us about it in the pull request.

## Credits

This coding challenge was inspired on [kinvoapp/kinvo-back-end-test](https://github.com/kinvoapp/kinvo-back-end-test/blob/2f17d713de739e309d17a1a74a82c3fd0e66d128/README.md)

[gains]: #gain-calculation
[taxes]: #taxation
[interest]: #interest-calculation
[compound gain]: https://www.investopedia.com/terms/g/gain.asp
```
php -S localhost:8000 -t public
```
17 changes: 17 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php

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

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);
};
19 changes: 19 additions & 0 deletions bin/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env php
<?php

if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}

if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
} else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}

require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
}
84 changes: 84 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.13",
"lexik/jwt-authentication-bundle": "^2.16",
"symfony/console": "6.1.*",
"symfony/dotenv": "6.1.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "6.1.*",
"symfony/proxy-manager-bridge": "6.1.*",
"symfony/runtime": "6.1.*",
"symfony/security-bundle": "6.1.*",
"symfony/uid": "6.1.*",
"symfony/validator": "6.1.*",
"symfony/yaml": "6.1.*"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "6.1.*",
"symfony/css-selector": "6.1.*",
"symfony/maker-bundle": "^1.48",
"symfony/phpunit-bridge": "^6.1"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"symfony/flex": true,
"symfony/runtime": true
},
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"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": "*"
},
"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": "6.1.*"
}
}
}
Loading