The application will have two components:
This is the interface where the user will be able to create and view all of his notes.
There will be a blank text area, with a blank title. The user don’t have to click on any button to save a new or to edit a note. The saving should be done automatically, allowing user to save their work even if they close the browser.
Stack: React or Angular
This component has to handle all requests to save and retrieve notes. If the application receives a lot of requests that overload the database, it might be interesting to have a layer for caching, allowing to save the content of notes while users are editing them.
TODO
The web application will call the back end via REST APIs. Once logged in, the user will have a token to identify each request, to guarantee the authorization to reach the resources. Each action would be identified by the respective HTTP action (GET, POST, PUT, DELETE, etc.), unless the operation requested is too specific and doesn’t contemplate an HTTP action for that purpose.
For this simple web app, these basic endpoints will be enough.
HTTP Action | URL | Description |
---|---|---|
GET | /notes | Get all notes from the user. |
GET | /notes/{id} | Get a note from the user by ID. |
GET | /notes/filter?value={value} | Filter notes from that user that have that specific value in title or text. |
POST | /notes | Create a new note for that user. |
PUT | /notes/{id} | Update a note with the specific ID for that user. |
DELETE | /notes/{id} | Delete a note with the specific ID for that user. |
METHOD HTTP | GET |
---|---|
URL | /notes |
Description | API to get all notes from user. The verification of the user would be done by a token. |
Method HTTP | POST |
---|---|
URL | /notes |
Description | Create a note for a specific User. The verification of the user would be done by a token. |
Method HTTP | POST |
---|---|
URL | /notes |
Description | Create a note for a specific User. The verification of the user would be done by a token. |
For this application, an MVC back end will serve well. We will have 3 layers, the first one being the Controller to receive all requests. The next will be the Service layer, responsible for all business logic. The third will be the data layer, responsible to connect to the database.
Some operations, such as get note by ID, are simple. They just need to have the inputs validated before retrieving or updating the resource.
When getting all notes, they should be sorted by when they were last updated (updatedAt
), to guarantee that the notes the user is working on will appear first.
When filtering the notes, the user must be able to filter notes not only by the Title, but also by its content.
The deletion of a note should be done softly, allowing the user to roll back that action for any reason.
To allow for an effective search, the best type of database to store notes are document based databases. For this purpose, MongoDB or Elasticsearch are a good fit.
One problem for this application might occur if it has a lot of transactions in a short period of time. In this case, to prevent a lot of saving in the database while a user is writing a note, it could be interesting to have another layer for caching the modifications. This could be done using Redis.