Simple money transaction
1. Feature Mapping
2. Running Local
3. Context Mapping
4. Api Endpoints
5. Working Example
Development References
This is a study case of a system that simulates some usual transactions between users.
There are only two type of users Personal and Business and in this system we will implement some features. The current mapped features are listed below. Feature suggestion are welcome feel free to create a issue with the enhancement label.
-
Personal users
- Basic Features
- Register
- Required Information
- Full name
- CPF
- Password
- Required Restrictions
- Email should be unique
- CPF should be unique
- Additional
- Email confirmation
- Required Information
- Login
- Transactions
- Basic Features
- Add funds to the account
- Remove funds from the account
- Transfer funds to Personal users
- Transfer funds to Business users
- Receive funds from Personal users
- Receive funds from Business users
- Restrictions
- Must have funds to remove funds action
- Must have funds to transfer to other accounts
- Must validate the transference action using this data
- On trasfer fail must return the funds
- Notifications
- Notify user when a transaction occur
- Validate the notify action using this data
- Additional Features
- Apply a defined tax after a defined amount of free transactions
- Basic Features
- Register
- Basic Features
-
Business users
- Basic Features
- Register
- Required Information
- Company name
- CNPJ
- Password
- Required Restrictions
- Email should be unique
- CNPJ should be unique
- Additional
- Email confirmation
- Required Information
- Login
- Transactions
- Basic Features
- Add funds to the account
- Remove funds from the account
- Receive funds from Personal users
- Receive funds from Business users
- Restrictions
- Must have funds to remove funds action
- Must validate the transference action using this data
- On trasfer fail must return the funds
- Notifications
- Notify user when a transaction occur
- Validate the notify action using this data
- Additional Features
- Apply a defined tax when funds are received
- Basic Features
- Register
- Basic Features
- Git (Tested on version 2.25.1)
- If you dont have Git installed click here and follow the installation guide.
- Docker version 20.10.11 or higher (Tested on version 20.10.11)
- If you dont have docker installed click here and follow the installation guide.
- In your terminal run:
- git clone git@github.com:caioflavio/smts.git
- Enter on folder project:
- cd smts
- On the first run you need create the .env file that have the enviroment variables
- cp .env.example .env
- After copied the .env file you can proceed to run the project:
- ./vendor/bin/sail up
- By default the project is running on port 8081, it can be changed in .env changing the APP_PORT value.
- If database data is not loaded you should run:
- docker exec -it sail_laravel bash
- Inside the docker terminal that was open, run:
- php artisan migrate && php artisan db:seed --class=UserTypesSeeder
We will use the following context map to module development of this system. This context map image was generate with contextmapper.org tool.
- The User Context allow us manage user creation and handle their shared rules
- The Personal User Context allow us manage the specific rules from personal users.
- The Business User Context allow us manage the specific rules from business users.
- Personal User Context and Business User Context depends on User Context it makes a Shared Kernel relation.
- Personal User Context and Business User Context communnicate each other on transactions then here we must have a paterniship relation and changes must attend each other muttualy.
- The Transaction Context allow us manage general rules for transaction between users.
- The Personal User Transaction Context allow us to handle specific rules for personal users transactions.
- The Business User Transaction Context allow us to handle specific rules for business users transactions.
- The Transaction Authorization Context allow us to handle specific rules for transaction effetivation.
- The Transaction Notification Context allow us to handle specific rules for transaction notification.
- Personal User Transaction Context and Business User Transaction Context depends on Transaction Context it makes a Shared Kernel relation.
- Transaction Notification Context and Transaction Authorization Context depends on external services changes without a previous notification can occour this makes a conformist relationship.
- We will make a anti corruption layer to each to make the impact of these unwanted changes minimum if they occur.
Endpoint | Method | Description | Required Headers | Payload Example |
---|---|---|---|---|
/api/users | POST | Allows user creation | Content-Type: application/json |
{"name": "Caio F C Martins","email": "caioflavio2@hotmail.com.br","account_type": "personal","document_number": "16152358760","password": "12345678"} |
/api/users/auth | POST | Allows user token generation | Content-Type: application/json |
{"email": "caioflavio2@hotmail.com.br","password": "12345678"} |
/api/users/{user_id}/funds/add | POST | Allows add funds to a authenticated user | Content-Type: application/json Authorization: Bearer {token} |
{"description": "Add from test request","value": 50} |
/api/users/{user_id}/funds/withdraw | POST | Allows withdraw funds from a authenticated user | Content-Type: application/json Authorization: Bearer {token} |
{"description": "Add from test request","value": 50} |
- Laravel Framework - PHP Framework used on development
- Laravel Sail - Laravel's built-in docker container for application start
- Context Mapper Tool - Context mapper drawning tool
- DDD Strategic Design - Article about DDD subdomain types
- Bounded Contexts - Article about DDD bounded contexts