- How to install and run the project locally
- Technologies used
- Functionality
- Assumptions & things done for simplicity
- Run
npm install
oryarn install
in the terminal - [Optional] Change mongoDB connection string in the .env file to connect to your own database
- When install has finished, run
npm run devstart
oryarn devstart
in the terminal - Go to localhost:3000 to see the application
- Read about functionality here if needed
Name | Usage | Location examples |
---|---|---|
Express.js | API / backend | Main functionality here / routes are in customers.js |
mongoose | Connecting/interacting with DB | Schema can be found here |
EJS | Templating engine for Express | All ejs files are in the views folder |
Heroku | Deploying to web | Live version |
MongoDB | DB for live version | If you search for customer 123 in the site that is deployed on Heroku, you can see that it is connected to a database |
dotenv | Setting environment variables | .env |
morgan | Loggin end-to-end latency | Setup is found in server.js. Logs are found in endtoend.log |
nodemon | Automatic refresh of server | package.json |
method-override | Sending more than GET/POST requests via forms | package.json |
- Search for customer by personal number
- Requires at least 3 numbers from the personal number, will not accept more than 11
- If no customers are found, a button will show an option to create the customer
- The Create new customer-button will redirect to Add new customer and automatically insert the customer number into the form
- Requires all fields to be filled out correctly
- Personal number is Norwegian standard, 11 digits where the first 6 digits represent a birthdate
- First name, last name and city require at least two characters
- You are required to choose an account type
- The customer birthdate is set based on the personal number
- The customer bank account number is generated based on the Norwegian standard
- First 4 digits are the bank register number
- Next 2 digits are based on the account type
- The 4 digits after that are a randomly generated number
- And the last digit is a control number being calculated by the mod11 algorithm
- The customer ID is the last 7 digits of the bank account number
- After successfully creating a new customer, you are redirected to the Find customer page and the personal number you used will be filled into the form so you can easily display the customer
- You first have to search for a customer (all 11 digits, for security)
- The form will then be filled in with all the details of the customer, and you can choose which you want to change
- When submitting, you get a success message as long as nothing went wrong
- You first have to search for a customer (all 11 digits, for security)
- The customer will then display with a Delete-button which will delete the customer and display a success message as long as nothing went wrong
- Latency will be logged to the terminal whenever you do something on the site that includes a mongoDB query
- The log includes the HTTP status code, method used to send, the endpoint and the mongoDB query type that was used
- The end-to-end latency is logged by morgan and saved in a log file
- The cloud processing latency is logged by mongoose pre/post-middleware that can be found in the customer schema
- The post-middleware also calls on a function which takes the last line from the end-to-end log and compares it to the current cloud processing latency calculation to get the communication latency, and finally logs everything out to the terminal in a neat form
- Customers can have only one account each
- Personal number, account number and customer ID should be unique in the database
- ABC Bank has the 'Bank register number' 1234
- If customer changes account type, a new account number will be generated
- Customer ID can not be updated, even when the account type (and therefore account number) is changed