If you’ve already read Part 1 of this series, it should be clear that there is a major component to our development journey that requires some attention: the backend.
When I began programming, the distinction between frontend and backend wasn’t 100% clear to me. If you consider different architectures — servers, serverless, microservices– it can become overwhelming. My recommendation to anyone who finds themselves in this confused position is to first think about the most basic structure of an application.
The following time estimates assume 20-25 hours of study/week and some previous foundation in coding principles.Phase 5: Learn Express with Node ~ 1 month
Node gives you the ability to “start a server,” which means your personal computer will dedicate a portion of its hardware and memory to execute your node code and actively listen on a particular port. As we develop our application, our frontend will be able to communicate with our backend by sending a request to this port that we are currently “listening” to.
For example, after we’ve typed in a username and password and clicked “login,” we’ll be sending a request from our frontend to our backend server, which has an “endpoint” at that port.
In the early stages of learning backend development, it’s most important to learn how to start a simple server on your computer and to develop an intuition on how this communication between frontend and backend happens through a series of requests and responses to your different backend endpoints. As your app evolves, you’ll have endpoints for different functionalities: myserver.com/login, myserver.com/user/profile, etc.Phase 6: Databases ~ 1 month
The missing piece to a basic application architecture is a database structured to store and retrieve large amounts of data efficiently. Going back to the example with sign-in functionality (after our frontend has sent a ‘request’ to the backend endpoint www.myserver.com/signin), our backend will process the request, and then compare the credentials to what is saved in the database.
A proficient full stack developer knows how to structure a database for efficient lookup. However, this should be balanced with structuring the database for minimal duplication of data. Typically, a non-relational database offers a more simple structure and faster lookup, but more duplication of data (which means you will need to allocate more resources to accommodate for more data entries). Relational (mySql) databases have traditionally been the more common and cost-effective pick, but due to increasingly cheaper storage space, more and more are opting for the more straightforward non-relational database option.
You can create a database, add entries, and perform lookups directly through your terminal. I recommend taking a week to step away from your app/code and practice directly with your database, at least until you develop an intuition of how data is stored, and the difference between a relational and non-relational database. After you are comfortable with that, you can use an ORM, such as Mongoose, to read and write to the database directly from your code.Phase 7: Deployment ~ 1 week
Taking it a step further, if we want to deploy an application which also has backend code (our node code), we need a cloud server that will be able to constantly run this node code and actively respond to client requests. For starters, I recommend Heroku since I have found it to be the most straightforward. From there on, your code lives on servers that Heroku has configured, and any time that a new client request comes in to view your app, the bundled frontend code will be sent to that client. It will then be a series of requests and responses from the client to the Heroku servers, which is actively running the backend code.