Logo hdtoledo
hdtoledo.dev
Módulos_del_Sistema
MÓDULO_TEÓRICO

Architecture of your New System

Client Server Architecture

Architecture of your New System

Doña Pepa now has a robust, fast, and secure database! But she has realized a big problem: She doesn't want to type SQL commands on a black screen every time she sells a milk.

She wants a beautiful application, with colorful buttons and easy-to-use forms, just like modern applications. To achieve this, we need to build a Three-Tier System (Client-Server Architecture).


The 3 Tiers of the System

Imagine that Doña Pepa's store is now a giant restaurant. She needs three teams working together:

1. The Counter (Frontend - HTML/CSS/JS)

This is the visible face of the store. Here are the buttons, colors, and forms that Doña Pepa uses.

  • Its job: Show pretty information and collect the data Doña Pepa types (e.g., "Sell 2 milks").
  • Limitation: The counter is a bit "dumb". It doesn't know how to save things or do complex calculations; it only obeys display orders.

2. The Waiter / Intermediary (Backend - Node.js/Express)

This is Doña Pepa's trusted employee. The Counter passes orders to this employee.

  • His job: He receives the order, checks that everything is correct (that no one is trying to cheat with negative prices), and is the only one who has the key to enter the vault to save or take out information.

3. The Vault (Database - PostgreSQL/MySQL)

This is the SQL database we just built in the previous lessons. Secure, fast, and armored.

  • Its job: Save the information forever in a structured way.

Why not connect the Counter directly to the Vault?

A very common question is: "Why don't we use HTML and JavaScript to send data directly to the Database and skip the Backend?"

For Security. The Counter's code (Frontend) lives in the user's web browser (Chrome, Safari). Anyone can see the code by right-clicking -> "Inspect element". If you put your database password there, any curious customer could drain all of Doña Pepa's financial information in 5 minutes!

These types of attacks are called SQL Injection. That is why we always need our trusted Waiter (The Backend) in the middle.

Conclusion: It's time to get our hands dirty building the application! In the next lesson, we will prepare "The Counter" by creating a Web Interface (Frontend) with HTML and CSS so Doña Pepa can register her products.