Skip to content

This Symfony Application is solely for portfolio purposes and is not used in any production environment. It's a currency converter with a local database in which all the exchange rates are stored. The app is secured by a login and an IP restriction.

Notifications You must be signed in to change notification settings

lankhaar/assessment-currency-converter

Repository files navigation

Best and most sophisticated currency converter ;-)

Table of Contents

  1. Project setup
  2. SSH to container
  3. Testing
  4. Manage the application

Project setup

Run the following command to start the project:

docker compose up

NOTE: This command could potentially take a while to finish on initial run as it'll have to install the dependencies, create a database and build the project.

After the project is running, you should compile the assets:

npm ci
npm run build

Now you can optionally run the following command to load the fixtures:

# When on host machine:
docker compose exec php sh -c "php bin/console doctrine:fixtures:load"

# When inside the container:
php bin/console doctrine:fixtures:load

BE AWARE: This will load the fixtures in the database, which means that the exchange rates will be set to the values defined in the CurrencyExchangeRateFixtures class as opposed to the real-time exchange rates which have been loaded automatically after the migrations ran. This however can still be updated later (see Update Exchange Rates).

Once the project is running, you can access the following URLs:

Be aware that the application is protected by IP restrictions, if you want to access it from outside your current network, you'll have to add your IP address to the list of allowed IP addresses.

If you chose to load the fixtures, you can login with the following credentials:

SSH to container

To get a shell inside the container (eg. to run bin/console commands), run the following command:

docker compose exec php sh

Testing

First time setup

Before you run any tests, you need to make sure to setup a test database.

To do so, run the following command in your container:

bin/console --env=test doctrine:database:create
bin/console --env=test doctrine:migrations:migrate
bin/console --env=test doctrine:fixtures:load

Run the tests

To run the tests, run the following command:

./bin/phpunit.sh

Manage the application

The application can be managed from the admin area, found at https://yourdomain.com/admin. Besides that, you can also fully manage the application using the command line. This is especially usefull when initially setting up your application as you'll have to create an admin user via the command line before you even have access to the admin panel.

User Management Commands

Add a User

To add a new user, run the following command:

php bin/console app:access:user:add <email> <password> [--admin]
  • <email>: The email of the user.
  • <password>: The password of the user.
  • --admin: (Optional) If provided, the user will be given admin privileges.

Example:

php bin/console app:access:user:add user@example.com password
php bin/console app:access:user:add admin@example.com admin --admin

List Users

To list all users, run the following command:

php bin/console app:access:user:list

This will display a table with the ID, email, and roles of each user.

Remove a User

To remove a user, run the following command:

php bin/console app:access:user:remove <email>
  • <email>: The email of the user to remove.

IP Management Commands

Add an IP Address

To add a new IP address to the allowed list, run the following command:

php bin/console app:access:ip:add <ip>
  • <ip>: The IP address to add.

Example:

php bin/console app:access:ip:add 192.168.1.100

# or an IP subnet
php bin/console app:access:ip:add 192.168.1.0/24

List IP Addresses

To list all allowed IP addresses, run the following command:

php bin/console app:access:ip:list

This will display a table with the ID and IP address of each allowed IP.

Remove an IP Address

To remove an IP address from the allowed list, run the following command:

php bin/console app:access:ip:remove <ip>
  • <ip>: The IP address to remove.

Currency Management Commands

List Supported Currencies

To list all currently supported currencies, run the following command:

php bin/console app:currencies:list

This will display a list of all supported currency codes.

Update Exchange Rates

To update the exchange rates for the given currencies, run the following command:

php bin/console app:currencies:update [<currency_codes>] [--all] [--async]
  • <currency_codes>: (Optional) A list of currency codes to update. Separate multiple codes with a space.
  • --all: (Optional) If provided, updates all existing currencies.
  • --async: (Optional) If provided, updates currencies asynchronously.

Example:

php bin/console app:currencies:update USD EUR
php bin/console app:currencies:update --all
php bin/console app:currencies:update USD EUR --async

About

This Symfony Application is solely for portfolio purposes and is not used in any production environment. It's a currency converter with a local database in which all the exchange rates are stored. The app is secured by a login and an IP restriction.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published