The way I build the whole application

The way I build the whole application

Posted date 2023-03-01

Everyone has their own way when building an application from scratch, and sometimes we’re not convenient with their way because each person has their own cozy method, so do I.

In this post I would tell you what I did for building an application from scratch, for now example we would build a Todolist application.

Defining what application we will build

Before we work on the application any further, we should define what application we’re gonna build, like what feature of the application needed, so that the next step can be easier.

Because the application is very simple, the features are as follows :

  • Users create todo records.
  • Users can mark the todo as finished or undo it as unfinished.
  • Users can delete todo records.

We got the definition of application above, the more complicated the application, the more points we have to define.

Flow of application

Flow application describing how the application interaction with user from start to the end, you can create flow application just using notes, or using diagram.

Based on Define of the application, we can write down the flow application using diagram like this :

Flow-app

as you can see above, we define all the required application features into workflows the application :

  1. User enter the page
  2. User create new todo
  3. User mark as finished todo
  4. User mark as unfinished todo
  5. User delete todo
  6. User delete all todo completed

Mindmap

Mind map explaining what information, what element, and what user interface (UI) that we’re gonna show to users when he enter the page.

Based on flowmap application, we can see that all we need is only one page, in my vision the mind map of application just contain only :

mindmap

When user enter our application, we present a page with elements :

  1. At the top of the page we’re gonna show header of our Application
  2. Under header element we will put form element that user will type and enter new to do in it.
  3. When the todo lists contain todo, we will show button that can delete all todo finished.
  4. Below the form element we will show all todo lists the user input.
  5. Inside todo element we will put 2 button, the button to mark todo as finished and the button to delete todo
  6. And at the bottom of the page we will show footer.

The mind map above also makes us easier when making the sketch view, the initial design as the basis of full design.

Sketch

The sketch view just a simple display, the initial design for our application, without coloring, without typography and based on it, we can do full design of application.

Based on the mindmap we can draw sketch like so :

sketch

We add button delete all completed so user can easily delete all completed todo insted of delete it one by one.

Design

After we draw the sketch design, we have view of the full design of application, we have to define the sketch into a completed design, the completed design make it easier for us when we build a frontend application.

You can use one of many tools like Figma, Adobe XD, InVison, and so on to work on designs. We did a design using figma, and here are the end results :

design

I do not explain in detail how to design it, likes how to create rounded line, button and etc, because it will takes a very long session.

Preparation to do Frontend application

Now the time has come, we’re gonna coding frontend application, but before we doing that process, it would be better if we’re analyze the design and got the conclusion what elements will we create.

This is how I analyze the design and got conclusion what element that I would create :

analyze-design

As seen above, we will create as many as 5 components namely :

  1. Header.
  2. Button.
  3. Form.
  4. Todo.
  5. Todolists.

Coding Frontend application

There are many types of framework and programming language to create a frontend application, I considered choosing the hype framework called React that uses javascript language for building this app.

I don’t tell you how to setup a new project frontend application, what code editor I use, and etc that we can’t tell you detail here.

To make this post not too long, I just tell you how I build the each component application.

The structure of frontend application would look like so :

Show code!

Let’s start by creating the header component

The header component will contain simple code that will return element h1 with text React todolist as head of application.

header-app

Create Header.jsx file with following content :

Show code!

Create the button component

The button element, we will use in many places, like form, todo list and others.

button-app

Create a Folder name Button, and create index.css file, the style for Button component, this is the content of the file.

Show code!

Create index.jsx file with following content :

Show code!

Create component form to type new todo

The form where user can type new todo, and we’re gonna put some function in this element, like when user submit the form, we will put the new todo in to todolist and we will clear the form, so user can type new todo again.

form-app

Create folder name Form, then create index.css file, with the following content

Show code!

Create a file index.jsx, the form component with the following content

Show code!

Create todo component

Todo component will contain button to delete todo and button to toggle todo as Completed or Incompleted, and the text of todo.

todo-app

Create Todo.jsx file with the following content

Show code!

Create lists of todo component

The todo list component will looping data of todo list and will create todo component for each todo data.

todolist-app

Show code!

Combining all component

We will combine all component that we create, so it becoming the whole front application and work like we expected.

design

Create a file App.css style for default web with the following content

Show code!

Create App.jsx file, that will combine all component

Show code!

The front end application is completed, we can do manipulation data for now, but the data is temprorary because we don’t store it to any database.

We need to build backend application to store all data that we’re going to do in the next step.

Designing backend application

As previously, before we do coding for backend applications, it would be better to analyze what data to store and what service that front end application needed.

Based on design application, we just need data structure to store as below

  • Id (Unique identity of record).
  • Todo (Value of todo).
  • isCompleted (The mark of todo is that completed or no).

Whereas the service of backend we’re just need :

  • Service to create new todo
  • Service to mark todo as complete or incomplete
  • Service to delete todo

Creating database based on data structure

Because we already know how data structure needed, We can create database first before we do code for backend application I decided to use mysql database for this application among many choices database management system, this is the database view that I setup :

Show code!

Coding for backend application

There are many programming languages for creating backend applications. I considered using PHP, a popular language since 1995, the folder structure would look like :

Show code!

let’s get started.

File connection from app to database

Create a file Connect.php, the file to connecting application to database.

Show code!

.htaccess file to redirect all request to index.php

.htaccess file that will rule apache server

Show code!

Model application

The Model is the part of MVC which implements the domain logic. In simple terms, this logic is used to handle the data passed between the database and the user interface (UI).

The Model is known as domain object or domain entity.

Create Model.php with the following content :

Show code!

Index application and also the controller

A controller is responsible for controlling the way that a user interacts with an MVC application. A controller contains the flow control logic for an ASP.NET MVC application. A controller determines what response to send back to a user when a user makes a browser request.

Create index.php file, with the following content

Show code!

Integration between backend application vs front end application

We are almost done, we will add some function every application doing manipulation data like add todo, mark todo as completed or uncompleted, and delete todo, let’s get into it

Add some function to interact with backend application

Edit App.jsx and add some function like below :

Show code!

Conclusion

Impossible for somebody to build complex applications alone, because it is impossible for someone to be an expert in everything, this meme may can relate ✌️.

meme

Ducks can’t move fast like dogs, can’t swim agile like fish, and can’t fly high like birds.

Building an application sometimes it’s fun, but when the application gets more complex you may need to prepare a lot of patience, because your intelligence, your skill, your IQ is not enough to finish the whole application alone.

This Post become simple because I didn’t tell you another process that very important likes :

  1. How to setting up a new project before we build the application.
  2. How to do unit testing for each file.
  3. How to do integration testing of the whole application.
  4. How to do End To End testing the whole application.
  5. How to test security of the application.
  6. How to create Continuous integration / Continuous deployment.
  7. How to deploy applications to the cloud or server.
  8. And many more that I don’t know yet 😀

Thanks For reading my post, hopefully can add to your insight about how to build a whole application from scratch 🙏