Developer: Igor Vasiljev
'Enter the Matrix' program accepts a user input of 2, 3 or 4 lines of numbers, then builds and returns the matrix and its determinant. The program also allows to create a unique user login and password.
The tool's objective is to help the user with math calculations of finding 2x2, 3x3 or 4x4 matrix determinant.
- Project Goals
- User Experience
- User Stories
- Technical Design
- Technologies Used
- Features
- Validation
- Testing
- Bugs
- Deployment
- Credits
- Acknowledgements
- Ability to create an account.
- Run math calculations and get the results.
- Create a useful tool with clear and understandable objectives.
- Easy to use, user-friendly and intuitive navigation.
- Everyone who's aware of what matrices and their determinants are.
- Easy navigation.
- Clear program response to the user input.
- Non-bulky texts.
- Correct math results of the program.
Click here to view instructions
On the main screen menu the program logo is displayed, and the user will have 2 options here - create a new username or use an existing login information.
Options:
- create username
- login
First, the user has an input line to enter a new username.
Input name:
- Please type in a new username
If an existing username is entered, then the program will notify the user about it and ask to enter another user name, or return to the main screen.
Options:
- retry new username
- return to the main screen
Once the user name is created, the program will ask you to enter a password. If the program is terminated at this point, then the username will be purged from the data base on the next run.
Input password:
- Please type in a new password
When a user name and password are created, the user can either login or return to the main screen.
Options:
- login
- return to the main screen
Login option can be used when the user has created the user name and password.
Input:
- Type in the username
If the user name entered is incorrect, the program will notify the user and give 2 options:
- retry login
- return to the main screen
In case if user name is entered correctly, then the user is asked to type in the password:
- Type in password
And if the password is entered incorrectly, the user will need to start the authentication process from the beginning:
- retry login
- return to the main screen
When the user successfully logs in, the information window will be displayed with a brief description of how to use the program and the example. Apart from that there 2 options:
- start
- return to the main screen
Once the program has started the user is advised to enter 2, 3 or 4 numbers, separated by a comma. If the input is invalid, the corresponding error message will be returned. If 2 numbers are entered first, then the program will request another 2 numbers in the next input. As before, in case of incorrect input the error message will be returned. Same for 3 and 4 numbers.
Once the final batch of numbers is entered, the program will process the overall input and return the matrix and calculate its determinant using the corresponding math formulas.
The program will ask if the user wishes to run the program again, or return to the main screen:
- try again
- return to the main screen
- As a user I want to select to create a new user name or use the existing.
- I want to have functionality to create a new user name and password.
- I want to have the ability to use existing user name and password.
- I want to have a clear understanding of what went wrong in the case of error.
- I want to have understandable, non-bulky instructions of use.
- I want to be able to easily navigate from any point in the program to the main screen.
- I want to run the program and get the correct results based on my input.
- I want to have the ability to repeat the program multiple times without re-logging.
- As a site owner, I want the users to have a perfect understanding of what the program does.
- I want the login details saved to the spreadsheet.
- I want the data to be correctly validated and the correct results are returned.
The following flowchart represents the matrix input and calculation program logic:
- Python as the programming language
- GitHub as a repository for the project code
- Google Cloud Platform to access and manipulate data on spreadsheets
- Google Sheets to store the authentification details
- PEP8 to validate the code
- Heroku to deploy the project
- unittest was used for testing matrix determinant calculations
- os - to clear the console
- gspread - Justification: gspread was used to manipulate data on the Google spreadsheet.
- google.oauth2.service_account - Justification: Google OAuth was used to access Google API with the information generated in creds.json file. This information is also used in the deployment to Heroku.
- Welcome message is displayed.
- 2 options to select from:
- create username
- login
- Covered by user stories 1 and 5
- A new username input is displayed.
- Covered by user stories 1 and 2
- Existing username input is displayed.
- Covered by user stories 1 and 3
- Instructions on how to use the program are displayed.
- 2 options to select from:
- start
- return to the main screen
- Covered by user story 5
- A message suggesting to enter 2, 3 or 4 numbers is displayed.
- Covered by user stories 4 and 7
- Matrix and its determinant are displayed.
- 2 options to select from:
- try again
- return to the main screen
- Covered by user stories 5 and 8
- An error message is displayed when incorrect symbol is entered in 1-2 menu selections.
- Covered by user stories 4, 5 and 11
- An error message is displayed when the number lines are entered in incorrect format.
- An error message is shown when using incorrect user name on login.
- Another error message is displayed when using an existing username on username creation.
PEP8 online was used to check the code for errors. Code passed validation in all files.
The project was tested using 2 methods:
- Manually
- Unit testing
User stories testing
- As a user I want to select to create a new user name or use the existing.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Main screen | Select 'create username' | Navigate to new user creation screen | Works as expected |
Main screen | Select 'login' | Navigate to existing user login | Works as expected |
Main screen | Enter any symbol that is not 1 or 2 | Return the correct error message | Works as expected |
- I want to have functionality to create a new user name and password.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
New username | Enter existing username | Return error and show navigation options | Works as expected |
New username | Enter non-existing username | Navigate to password selection | Works as expected |
New username | Terminate the program without setting a password | The username entered will be deleted | Works as expected |
New username | Login using new username and password | Navigate to the instructions screen | Works as expected |
New username | Use incorrect login details | Return error and show navigation options | Works as expected |
- I want to have the ability to use existing user name and password.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Existing username | Enter non-existing username | Return error and show navigation options | Works as expected |
Existing username | Enter existing username | Navigate to password selection | Works as expected |
Existing username | Enter incorrect password | Return error and show navigation options | Works as expected |
Existing username | Enter correct password | Navigate to the instructions screen | Works as expected |
- I want to have a clear understanding of what went wrong in the case of error.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Generic | Enter any symbol that is not 1 or 2 in the 1-2 selection | Return the correct error and description | Works as expected |
Entering the matrix | Enter 3 numbers when 2 or 4 were requested | Return the correct error and description | Works as expected |
Entering the matrix | Enter any letter(s) | Return the correct error and description | Works as expected |
- I want to have understandable, non-bulky instructions of use.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Instructions | Navigate to instructions screen | All text is perfectly aligned and readable | Works as expected |
Results screen | Enter the numbers and get the results | All text is perfectly aligned and readable | Works as expected |
- I want to be able to easily navigate from any point in the program to the main screen.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Incorrect user name | Enter an incorrect username | There is an option to navigate to the main screen | Works as expected |
Incorrect password | Enter an incorrect password | There is an option to navigate to the main screen | Works as expected |
Instructions | Navigate to instructions screen | There is an option to navigate to the main screen | Works as expected |
Results | Run the program and get to results screen | There is an option to navigate to the main screen | Works as expected |
- I want to run the program and get the correct results based on my input.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Start the matrix calculation | Enter 2,3 or 4 number lines | The program requests the correct amount of numbers | Works as expected |
Results | Enter 2,3 or 4 number lines | The program returns the correct determinant value | Works as expected |
- I want to have an ability to repeat the program multiple times without re-logging.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Results | Use 'Try again' function | The matrix input function restarts | Works as expected |
- As a site owner, I want the users to have a perfect understanding of what the program do.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Main screen | Show informational messages | Clear description of the program functions | Works as expected |
Instructions | Show informational messages | Clear description of how to use the program | Works as expected |
Results | Show informational messages | Clear outcome of the user input | Works as expected |
- I want the login details saved to the spreadsheet.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Create a new user name | Enter a new username | The new user name gets saved on the spreadsheet | Works as expected |
Create a new user name | Enter a new password | The new password gets saved on the spreadsheet against the new user name | Works as expected |
Create a new user name | Enter a new username and exit the program | The user name without a password gets purged from the spreadsheet | Works as expected |
- I want the data to be correctly validated and the correct results are returned.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Login | Enter the correct username | The correct message is displayed and password is requested | Works as expected |
Login | Enter the correct password | Log in and navigate to the instructions screen | Works as expected |
Create a new username | Enter non-existing username | The correct message is displayed and password is requested | Works as expected |
Create a new username | Enter a password | The correct navigation options are displayed | Works as expected |
Unit testing
- Unit tests were written using 'unittest' library.
- Tests are designed to check matrix determinant calculations.
- assertEqual() method was used to make sure the results are returned as per input.
Bug | Fix |
---|---|
Login and password column headers in the spreadsheet worked as credentials for login | Remove the 'login' and 'password' headers from the spreadsheet |
Unable to login if using an existing password | Function that matches password against the username is amended |
Only login is added to the spreadsheet when terminating the program after new user name input | Function added to remove the username if there is no password for it |
New login and password overriding the existing ones | Function that looks for the last empty row in the spreadsheet was fixed |
Unexpected square brackets displayed in the matrix output | Added replace() method to the matrix output function |
Text issues decreasing readability | Line breaks added and removed overflowing equal signs |
The project was deployed using Heroku by the following steps:
- Create or log in to your account at heroku.com
- Click 'New' -> 'Create new app'
- Type in the app name (current project name is 'type-in-matrix') -> select the region -> 'Create app'
- Navigate to 'Settings' tab
- Click 'Reveal Config Vars' -> Add 'CREDS' key -> paste the content of creds.json file to 'value field -> 'Add'
- Add one more config var with the key 'PORT' and value '8000'
- Then click 'Add buildpack' -> add 'python' -> add 'nodejs'
- Navigate to 'Deploy' tab
- Select 'GitHub' in the 'Deployment method' area
- Enter the GitHub repository name in the search bar -> 'Connect'
- Click 'Deploy Branch' and wait for it to be built
- Navigate to the GitHub repository
- Click the 'Code' button (next to the green 'Gitpod' button)
- Copy the HTTPS link
- Navigate to Git Bash -> working directory
- Type 'git clone' and paste the URL received in step 3
- Press 'Enter
- Messletters text generator was used to create the program logo.
- gspread was used to get an examples of module usage.
- Stack overflow was used to find answers related to the correct syntax use.
Big thanks to everyone who trusted in me(if any) during the course of this project. A special thanks to my mentor Mo for support, guidance and very helpful feedback.