π DevSecOps Journey β Day 17

Building Real 3-Tier Applications with Databases (Hands-on)
Yesterday, I explored project architecture and build systems.
Today, I moved one step closer to real production systems by working on 3-Tier applications.
This learning focused on how applications connect to databases, how credentials are handled, and what a DevOps engineer must know beyond just running code.
π§± 2-Tier vs 3-Tier Architecture (Simple Explanation)
πΉ 2-Tier Architecture
Application layer
Database layer
π Suitable for small or simple systems.
πΉ 3-Tier Architecture
π₯ Presentation Layer β UI / Client
βοΈ Business Layer β Application logic
π Database Layer β Data storage
π Used in production environments for:
Better security
Scalability
Maintainability
As a DevOps engineer, understanding database setup, users, passwords, tables, and connectivity is essential.
β Project #6: 3-Tier Java + MySQL Application
π§ System Preparation
sudo apt update
sudo apt upgrade -y
Ensures latest packages and security patches.
π Installing MySQL
sudo apt install mysql-server -y
Database connection details live in
application.propertiesBest practice:
Store DB user, password, and URL in:
Environment variables
Secret managers (Vault, AWS Secrets Manager)
βΆοΈ MySQL Service Management
systemctl status mysql
sudo systemctl start mysql
sudo systemctl enable mysql
π Securing MySQL (Optional for Local)
sudo mysql_secure_installation
This helps with:
Removing anonymous users
Disabling remote root login
Removing test databases

π§βπ» Database & User Setup
CREATE DATABASE bankappdb;
CREATE USER 'adi'@'localhost' IDENTIFIED BY 'Test@123';
ALTER USER 'adi'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Test@123';
GRANT ALL PRIVILEGES ON bankappdb.* TO 'adi'@'localhost';
FLUSH PRIVILEGES;
π‘ Switching to mysql_native_password avoids the common JDBC error:
βPublic Key Retrieval is not allowedβ



π GitHub β Project #6 (Java + MySQL):
π https://github.com/Jysh06/3-Tier-Java-MySQL-Database
π Project #7: 3-Tier Node.js + MySQL Application
π Database Setup
MySQL installation & configuration
Database and table creation (
users)Credentials stored in
db.js
CREATE DATABASE test_db;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
email VARCHAR(255) UNIQUE,
role ENUM('Admin','User')
);

π₯ Client Setup
cd client
npm install
npm run build
βοΈ Server Setup
cd server
npm install
npm start


π App runs on: http://localhost:5000
This project clearly showed how backend services depend on database readiness.
π GitHub β Project #7 (Node.js + MySQL):
π https://github.com/Jysh06/3-Tier-NodeJS-MySQL-Database
π· Project #8: 3-Tier .NET + MongoDB Application
This project introduced NoSQL databases.
βοΈ Installing .NET
sudo apt install dotnet-sdk-8.0 aspnetcore-runtime-8.0 -y
π Installing MongoDB
sudo apt install mongodb-org -y
sudo systemctl enable mongod
sudo systemctl start mongod
π MongoDB Shell Usage
mongosh
show dbs
use db_name
show collections
db.Products.find().pretty()
DB credentials stored in
appsettings.json
βΆοΈ Running the App
dotnet restore
dotnet build
dotnet run

π GitHub β Project #8 (.NET + MongoDB):
π https://github.com/Jysh06/3-Tier-DotNet-MongoDB
π Project #9: 3-Tier Python + PostgreSQL Application
π§ͺ Python Virtual Environment
sudo apt install python3.12-venv -y
python3 -m venv myenv
source myenv/bin/activate
pip install -r requirements.txt
π PostgreSQL Setup
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql
CREATE USER root WITH PASSWORD 'root';
CREATE DATABASE my_database;
GRANT ALL PRIVILEGES ON DATABASE my_database TO root;

- DB details stored in
config.py
βΆοΈ Running the Application
source myenv/bin/activate
python run.py



π GitHub β Project #9 (Python + PostgreSQL):
π https://github.com/your-username/python-postgres-3tier
π DevSecOps Perspective: Credential Management
Across all projects:
β Avoid hardcoding credentials
β Use:
Environment variables
Secrets managers
This is a core DevSecOps principle.
β Day 17 Summary
Today I worked with:
β Java + MySQL
π Node.js + MySQL
π· .NET + MongoDB
π Python + PostgreSQL
And learned:
2-Tier vs 3-Tier architecture
SQL vs NoSQL basics
Database installation & security
User, password & permission handling
Applicationβdatabase integration
This hands-on experience strengthened my understanding of how real production systems are built and operated.



