<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: pirvanm</title>
    <description>The latest articles on DEV Community by pirvanm (@pirvanm).</description>
    <link>https://dev.to/pirvanm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F710967%2F0245c293-67d4-4c90-9651-91836b3830ff.png</url>
      <title>DEV Community: pirvanm</title>
      <link>https://dev.to/pirvanm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pirvanm"/>
    <language>en</language>
    <item>
      <title>How do you make a FullStack [Focus on React] Demo App for Interviews using Laravel + React with Dockerize Part 5</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Thu, 04 Sep 2025 23:38:41 +0000</pubDate>
      <link>https://dev.to/pirvanm/how-do-you-make-a-fullstack-focus-on-react-demo-app-for-interviews-using-laravel-react-with-3am1</link>
      <guid>https://dev.to/pirvanm/how-do-you-make-a-fullstack-focus-on-react-demo-app-for-interviews-using-laravel-react-with-3am1</guid>
      <description>&lt;p&gt;Previously, I started react js side ,&lt;a href="https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-4-409l"&gt;Part 4- How do you make a FullStack Demo App for Interviews using Laravel + React with Dockerize&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;We’re continuing in the frontend/src/features/mentors/ section, and you’d like to refine and standardize styles inside MentorCard.module.css so it’s cleaner, reusable, and more consistent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.mentor-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.mentor-card:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.mentor-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.75rem;
}

.mentor-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.mentor-title {
  font-size: 0.95rem;
  color: #475569;
  margin-bottom: 0.25rem;
}

.mentor-expertise {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.mentor-link {
  font-size: 0.9rem;
  color: #4f46e5;
  text-decoration: none;
  font-weight: 500;
}

.mentor-link:hover {
  text-decoration: underline;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ll keep it consistent with the same folder level (frontend/src/features/mentors/) and design style you just refined for MentorCard.module.css.&lt;br&gt;
Here’s a clean, reusable SkeletonMentorCard.module.css you can drop in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.mentor-card {
  display: flex;
  flex-direction: column;
  text-align: center;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}

.mentor-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #e2e8f0;
  margin-bottom: 0.75rem;
  animation: pulse 2s infinite ease-in-out;
}

.mentor-name {
  height: 24px;
  width: 120px;
  background: #e2e8f0;
  border-radius: 0.375rem;
  margin: 0.25rem 0;
  animation: pulse 2s infinite ease-in-out;
  animation-delay: 0.2s;
}

.mentor-title {
  height: 18px;
  width: 140px;
  background: #f7fafc;
  border-radius: 0.375rem;
  margin: 0.25rem 0;
  animation: pulse 2s infinite ease-in-out;
  animation-delay: 0.4s;
}

.mentor-expertise {
  height: 16px;
  width: 110px;
  background: #f7fafc;
  border-radius: 0.375rem;
  margin: 0.75rem 0;
  animation: pulse 2s infinite ease-in-out;
  animation-delay: 0.6s;
}

.mentor-link {
  display: inline-block;
  height: 32px;
  width: 90px;
  background: #e2e8f0;
  border-radius: 0.5rem;
  margin-top: 0.5rem;
  animation: pulse 2s infinite ease-in-out;
  animation-delay: 0.8s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here’s a tidy, reusable MentorCard.tsx “partial”-style component that lines up with the CSS module you’ve set up. Drop this into frontend/src/features/mentors/MentorCard.tsx.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link } from 'react-router';
import styles from './MentorCard.module.css'
import type { Mentor } from '../../types/mentor';


const MentorCard: React.FC&amp;lt;Mentor&amp;gt; = ({
  id,
  title,
  fullName,
  expertise,
  avatar
}) =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
    &amp;lt;article className={styles['mentor-card']}&amp;gt;
        &amp;lt;img src={avatar ?? 'https://randomuser.me/api/portraits/women/45.jpg'} alt={fullName} className={styles['mentor-avatar']} /&amp;gt;
        &amp;lt;h2 className={styles['mentor-name']}&amp;gt;{fullName}&amp;lt;/h2&amp;gt;
        &amp;lt;div className={styles['mentor-title']}&amp;gt;{title}&amp;lt;/div&amp;gt;
        &amp;lt;div className={styles['mentor-expertise']}&amp;gt;{expertise.slice(0, 3).join(' • ').toUpperCase()}&amp;lt;/div&amp;gt;
        &amp;lt;Link to={`/mentor/${id}`} className={styles['mentor-link']}&amp;gt;View Profile&amp;lt;/Link&amp;gt;
      &amp;lt;/article&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default MentorCard;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here’s a solid MentorCard.test.tsx using React Testing Library + Jest.&lt;br&gt;
It covers rendering, tags, avatar vs initials fallback, card click, primary action (and that it doesn’t bubble), custom className, aria-label, and children rendering.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { render, screen } from '@testing-library/react';
import MentorCard from './MentorCard';
import type { Mentor } from '../../types/mentor';
import { MemoryRouter } from 'react-router';

const mockMentor: Mentor = {
  id: 1,
  fullName: 'Sarah Chen',
  email: 'sarah@example.com',
  title: 'Senior Frontend Engineer',
  bio: 'Passionate about React and mentoring.',
  technicalBio: 'Passionate about React and mentoring.',
  mentoringStyle: 'Passionate about React and mentoring.',
  audience: 'Passionate about React and mentoring.',
  avatar: 'https://example.com/avatar.jpg',
  expertise: ['react', 'typescript'],
  availability: 'open',
  joined_at: 'Jun 2020',
};

describe('MentorCard', () =&amp;gt; {
  test('renders mentor data correctly', () =&amp;gt; {
    render(
         &amp;lt;MemoryRouter&amp;gt;
            &amp;lt;MentorCard {...mockMentor} /&amp;gt;``
        &amp;lt;/MemoryRouter&amp;gt;
    );

    expect(screen.getByText('Sarah Chen')).toBeInTheDocument();
    expect(screen.getByText('Senior Frontend Engineer')).toBeInTheDocument();
    expect(screen.getByText('REACT • TYPESCRIPT')).toBeInTheDocument();

    const img = screen.getByAltText('Sarah Chen');
    expect(img).toBeInTheDocument();
    expect(img).toHaveAttribute('src', mockMentor.avatar);
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s add a tiny layer of logic so your UI cleanly handles loading, success, empty, and error states, all at the same folder level: frontend/src/features/mentors/.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useMentors } from "../../api/queries/mentors/useMentors";
import Error from "../../shared/ui/Error/Error";
import MentorCard from "./MentorCard";
import SkeletonMentorCard from "./SkeletonMentorCard";

const MentorList: React.FC = () =&amp;gt; {
  const { data: mentors, isLoading, error } = useMentors();

if (isLoading) {
  return (
    &amp;lt;main className="mentors-grid"&amp;gt;
      &amp;lt;SkeletonMentorCard /&amp;gt;
      &amp;lt;SkeletonMentorCard /&amp;gt;
      &amp;lt;SkeletonMentorCard /&amp;gt;
      &amp;lt;SkeletonMentorCard /&amp;gt;
      &amp;lt;SkeletonMentorCard /&amp;gt;
      &amp;lt;SkeletonMentorCard /&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}

  if (error) return &amp;lt;Error /&amp;gt;;
  if (!mentors || mentors.length === 0) return &amp;lt;p&amp;gt;No mentors available.&amp;lt;/p&amp;gt;;

  return (
    &amp;lt;&amp;gt;
        &amp;lt;main className="mentors-grid"&amp;gt;
          {mentors.map((mentor) =&amp;gt; (
            &amp;lt;MentorCard key={mentor.id} {...mentor} /&amp;gt;
          ))}
        &amp;lt;/main&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default MentorList;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let’s wrap the mentors feature folder (frontend/src/features/mentors/) with a clean index barrel so everything exports in a predictable, maintainable way. This way, consumers only import from the folder, not individual files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import styles from './SkeletonMentorCard.module.css';

const SkeletonMentorCard: React.FC = () =&amp;gt; {
  return (
    &amp;lt;article className={styles['mentor-card']}&amp;gt;
      &amp;lt;div className={styles['mentor-avatar']} /&amp;gt;
      &amp;lt;div className={styles['mentor-name']} /&amp;gt;
      &amp;lt;div className={styles['mentor-title']} /&amp;gt;
      &amp;lt;div className={styles['mentor-expertise']} /&amp;gt;
      &amp;lt;div className={styles['mentor-link']} /&amp;gt;
    &amp;lt;/article&amp;gt;
  );
};

export default SkeletonMentorCard;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get back 1 step and go next folder layouts so we  in frontend/src/layouts&lt;br&gt;
/MainLayout.tsx got  :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Outlet } from "react-router";
import MainNavbar from "./MainNavbar";

const MainLayout: React.FC = () =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
        &amp;lt;MainNavbar /&amp;gt;
        &amp;lt;div className="page-container"&amp;gt;
            &amp;lt;Outlet /&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default MainLayout;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And for navigation, we got frontend/src/layouts&lt;br&gt;
/MainNavbar.tsx :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Link } from 'react-router';

const MainNavbar: React.FC = () =&amp;gt; {
  return (
    &amp;lt;nav className="navbar"&amp;gt;
      &amp;lt;div className="nav-container"&amp;gt;
        &amp;lt;Link to={'/'} className="nav-logo"&amp;gt;MentorHub&amp;lt;/Link&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/nav&amp;gt;
  );
};

export default MainNavbar;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we end this part with "types" ,frontend/src/types&lt;br&gt;
/mentor.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export type Mentor = {
  id: number;
  fullName: string;
  email: string | null;
  title: string;
  bio: string | null;
  technicalBio: string | null;
  mentoringStyle: string | null;
  audience: string | null;
  avatar: string | null;
  expertise: string[];
  availability: 'open' | 'limited' | 'full' | 'paused';
  joined_at: string;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How do you make FullStack Demo App for Interviews using Laravel + React with Dockerize Part 4</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Fri, 29 Aug 2025 13:59:38 +0000</pubDate>
      <link>https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-4-409l</link>
      <guid>https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-4-409l</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-59hc"&gt;How to Build a Full-Stack Demo App for Interviews with Laravel + React (Dockerized) – Part 1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-2-2haf"&gt;Building a Full-Stack Demo App for Interviews (Laravel + React, Dockerized) – Part 2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-59hc"&gt;How to Build a Full-Stack Demo App for Interviews with Laravel + React (Dockerized) – Part 3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the second main Part B, and Part 4 of the full series. You can access the previous parts above. I think I’m speaking more like someone recording a personal journal — maybe with a bit too much imagination.&lt;/p&gt;

&lt;p&gt;Let’s start coding! Just type this command in the terminal. (Of course, this is a Linux terminal — for Windows users, you can use Cmder or Laragon, by the way.)npm create vite@latest my-app&lt;/p&gt;

&lt;p&gt;Then I selected the React framework for the lightweight version, and chose TypeScript — because it seems TypeScript is loved even more than Go now.&lt;/p&gt;

&lt;p&gt;After pressing Enter in the terminal a few times, I ended up with this familiar JavaScript package manager file: package.json.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "my-app",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc -b &amp;amp;&amp;amp; vite build",
    "lint": "eslint .",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^19.1.1",
    "react-dom": "^19.1.1"
  },
  "devDependencies": {
    "@eslint/js": "^9.33.0",
    "@types/react": "^19.1.10",
    "@types/react-dom": "^19.1.7",
    "@vitejs/plugin-react": "^5.0.0",
    "eslint": "^9.33.0",
    "eslint-plugin-react-hooks": "^5.2.0",
    "eslint-plugin-react-refresh": "^0.4.20",
    "globals": "^16.3.0",
    "typescript": "~5.8.3",
    "typescript-eslint": "^8.39.1",
    "vite": "^7.1.2"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Corrected:&lt;br&gt;
In my package.json, at the end I have:&lt;/p&gt;

&lt;p&gt;First, checking one by one:&lt;/p&gt;

&lt;p&gt;In "scripts":&lt;/p&gt;

&lt;p&gt;Next, in "dependencies", I added:&lt;/p&gt;

&lt;p&gt;"@tanstack/react-query": "^5.84.1",&lt;br&gt;
"axios": "^1.11.0",&lt;br&gt;
"react-router": "^7.7.1"&lt;/p&gt;

&lt;p&gt;And in the last step for packages, I just added one line in "scripts":&lt;/p&gt;

&lt;p&gt;"test": "vitest"&lt;/p&gt;

&lt;p&gt;In "devDependencies", I added:&lt;/p&gt;

&lt;p&gt;"vitest": "^3.2.4"&lt;/p&gt;

&lt;p&gt;After that, I think all the magic happens in frontend/src/, which is in the same folder as the previous backend folder.&lt;/p&gt;

&lt;p&gt;In frontend/src&lt;br&gt;
/.env&lt;br&gt;
I get it, but I think this is more logical in Docker, which I’ll talk about later — maybe in the next part.&lt;/p&gt;

&lt;p&gt;frontend/src&lt;br&gt;
/main.tsx before i start overwrite this i have :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'

createRoot(document.getElementById('root')!).render(
  &amp;lt;StrictMode&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/StrictMode&amp;gt;,
)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After some work, some ambition — maybe too much work...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import { BrowserRouter } from 'react-router'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

const queryClient = new QueryClient();

createRoot(document.getElementById('root')!).render(
  &amp;lt;StrictMode&amp;gt;
    &amp;lt;BrowserRouter&amp;gt;
      &amp;lt;QueryClientProvider client={queryClient}&amp;gt;
        &amp;lt;App /&amp;gt;
      &amp;lt;/QueryClientProvider&amp;gt;
    &amp;lt;/BrowserRouter&amp;gt;,
  &amp;lt;/StrictMode&amp;gt;,
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maybe it’s because I’m old — but not that old — I’m still a fan of ESLint config. So I made this one for formatting, in the eslint.config.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { globalIgnores } from 'eslint/config'

export default tseslint.config([
  globalIgnores(['dist']),
  {
    files: ['**/*.{ts,tsx}'],
    extends: [
      js.configs.recommended,
      tseslint.configs.recommended,
      reactHooks.configs['recommended-latest'],
      reactRefresh.configs.vite,
    ],
    languageOptions: {
      ecmaVersion: 2020,
      globals: globals.browser,
    },
  },
])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some basic HTML for the main page: index.html&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;!doctype html&amp;gt;&lt;br&gt;
&amp;lt;html lang="en"&amp;gt;&lt;br&gt;
  &amp;lt;head&amp;gt;&lt;br&gt;
    &amp;lt;meta charset="UTF-8" /&amp;gt;&lt;br&gt;
    &amp;lt;link rel="icon" type="image/svg+xml" href="/vite.svg" /&amp;gt;&lt;br&gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;&lt;br&gt;
    &amp;lt;title&amp;gt;Vite + React + TS&amp;lt;/title&amp;gt;&lt;br&gt;
  &amp;lt;/head&amp;gt;&lt;br&gt;
  &amp;lt;body&amp;gt;&lt;br&gt;
    &amp;lt;div id="root"&amp;gt;&amp;lt;/div&amp;gt;&lt;br&gt;
    &amp;lt;script type="module" src="/src/main.tsx"&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;
  &amp;lt;/body&amp;gt;&lt;br&gt;
&amp;lt;/html&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After that, to run tests properly, I created a file setupTests.ts with the following code:&lt;/p&gt;

&lt;p&gt;import '@testing-library/jest-dom';&lt;/p&gt;

&lt;p&gt;As the next sub-stage of Stage B, I made a pages folder inside src, like this:&lt;/p&gt;

&lt;p&gt;src&lt;br&gt;
 └── pages/&lt;/p&gt;

&lt;p&gt;Inside it i have AUth, Home, MentorProfile &lt;br&gt;
In Auth , more precise on : &lt;br&gt;
frontend/src/pages/Auth&lt;br&gt;
/Login.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Login: React.FC = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;

    &amp;lt;/div&amp;gt;
  );
}

export default Login;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On register :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Register: React.FC = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;

    &amp;lt;/div&amp;gt;
  );
}

export default Register;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One step closer to finishing this part, we go to Home.tsx&lt;/p&gt;

&lt;p&gt;Path: frontend/src/pages/Home/Home.tsx&lt;br&gt;
And the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import MentorList from "../../features/mentors/MentorsList";

const Home: React.FC = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;
        &amp;lt;header className="page-header"&amp;gt;
            &amp;lt;h1&amp;gt;Find a Mentor&amp;lt;/h1&amp;gt;
            &amp;lt;p&amp;gt;Get guidance from experienced developers, designers, and leaders.&amp;lt;/p&amp;gt;
        &amp;lt;/header&amp;gt;
        &amp;lt;MentorList /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default Home;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And on the latest step of this part 4 of series, we made a new folder &lt;/p&gt;

&lt;p&gt;src/pages&lt;br&gt;
/MentorProfile/&lt;/p&gt;

&lt;p&gt;Some CSS for beginners in web development — boring or seemingly useless stuff, but still necessary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: #475569;
    text-decoration: none;
    font-size: 0.95rem;
}

.back-link:hover {
    color: #1e293b;
}

.mentor-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.mentor-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.mentor-info {
    flex: 1;
}

.mentor-name {
    font-size: 1.8rem;
    font-weight: 600;
    color: #1e293b;
}

.mentor-title {
    font-size: 1rem;
    color: #475569;
    margin: 0.25rem 0;
}

.mentor-expertise {
    font-size: 0.95rem;
    color: #64748b;
}

.mentor-bio {
    line-height: 1.7;
    color: #334155;
    margin-bottom: 2rem;
}

.mentor-bio h2 {
    font-size: 1.3rem;
    margin: 1.5rem 0 1rem;
    color: #1e293b;
}

.mentor-bio p {
    margin-bottom: 1rem;
}

.mentor-requirements {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    color: #475569;
}

.mentor-requirements h3 {
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 0.75rem;
}

.apply-section {
    text-align: center;
    margin-top: 1rem;
}

.btn-apply {
    display: inline-block;
    background-color: #4f46e5;
    color: white;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.btn-apply:hover {
    background-color: #4338ca;
}

@media (max-width: 640px) {
    .mentor-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .mentor-name {
        font-size: 1.6rem;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;/MentorProfile.module.css&lt;/p&gt;

&lt;p&gt;In the next file: frontend/src/pages/MentorProfile/MentorProfile.test.tsx&lt;/p&gt;

&lt;p&gt;i got&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { render, screen } from '@testing-library/react';
import MentorProfile from './MentorProfile';
import { useMentor } from '../../api/queries/mentors/useMentor';
import { MemoryRouter } from 'react-router';


vi.mock('../../api/queries/mentors/useMentor');

describe('MentorProfile', () =&amp;gt; {
  test('shows skeleton when loading', () =&amp;gt; {
    (useMentor as jest.Mock).mockReturnValue({
      data: null,
      isLoading: true,
      error: null,
    });

    render(&amp;lt;MentorProfile /&amp;gt;);

    expect(screen.getByTestId('skeleton-avatar')).toBeInTheDocument();
  });

  test('shows error component when error occurs', () =&amp;gt; {
    (useMentor as jest.Mock).mockReturnValue({
      data: null,
      isLoading: false,
      error: new Error('Failed to fetch'),
    });

    render(&amp;lt;MemoryRouter&amp;gt;
        &amp;lt;MentorProfile /&amp;gt;
    &amp;lt;/MemoryRouter&amp;gt;);

    expect(screen.getByText('Whoops!')).toBeInTheDocument();
  });

  test('renders full profile when data is loaded', () =&amp;gt; {
    (useMentor as jest.Mock).mockReturnValue({
      data: {
        id: 1,
        fullName: 'Sarah Chen',
        title: 'Senior Frontend Engineer',
        expertise: ['React', 'TypeScript'],
        bio: 'I love mentoring.',
        technicalBio: 'I love mentoring.',
        mentoringStyle: 'I love mentoring.',
        audience: 'I love mentoring.',
        availability: 'open',
      },
      isLoading: false,
      error: null,
    });

    render(&amp;lt;MemoryRouter&amp;gt;
        &amp;lt;MentorProfile /&amp;gt;
    &amp;lt;/MemoryRouter&amp;gt;);

    expect(screen.getByText('Sarah Chen')).toBeInTheDocument();
    expect(screen.getByText('Senior Frontend Engineer')).toBeInTheDocument();
    expect(screen.getByText('REACT • TYPESCRIPT')).toBeInTheDocument();
    expect(screen.getByText('Apply to Be My Mentee')).toBeInTheDocument();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On MentorProfile.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link, useParams } from 'react-router';
import styles from './MentorProfile.module.css'
import { useMentor } from '../../api/queries/mentors/useMentor';
import SkeletonMentorProfile from './SkeletonMentorProfile';
import Error from '../../shared/ui/Error/Error';

const MentorProfile: React.FC = () =&amp;gt; {
  const { id }  = useParams&amp;lt;{id: string}&amp;gt;();

  const { data: mentor, isLoading, error } = useMentor(parseInt(id ?? '0'));

  if (isLoading) {
    return (
      &amp;lt;SkeletonMentorProfile /&amp;gt;
    )
  }

  if (error) return &amp;lt;Error /&amp;gt;;

  return (
    &amp;lt;main className={styles['mentor-detail']}&amp;gt;
      &amp;lt;Link to={'/'} className={styles['back-link']}&amp;gt;&amp;amp;larr; Back to mentors&amp;lt;/Link&amp;gt;


      &amp;lt;div className={styles['mentor-header']}&amp;gt;
        &amp;lt;img src={mentor?.avatar ?? 'https://randomuser.me/api/portraits/women/45.jpg'} alt={mentor?.fullName} className={styles['mentor-avatar']} /&amp;gt;
        &amp;lt;div className={styles['mentor-info']}&amp;gt;
          &amp;lt;h1 className={styles['mentor-name']}&amp;gt;{mentor?.fullName}&amp;lt;/h1&amp;gt;
          &amp;lt;div className={styles['mentor-title']}&amp;gt;{mentor?.title}&amp;lt;/div&amp;gt;
          &amp;lt;div className={styles['mentor-expertise']}&amp;gt;{mentor?.expertise.slice(0, 3).join(' • ').toUpperCase()}&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;

      &amp;lt;section className={styles['mentor-bio']}&amp;gt;
        &amp;lt;h2&amp;gt;About {mentor?.fullName}&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;
          {mentor?.bio}
        &amp;lt;/p&amp;gt;

        &amp;lt;h2&amp;gt;What I Can Help With&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;
          {mentor?.technicalBio}
        &amp;lt;/p&amp;gt;

        &amp;lt;h2&amp;gt;My Mentoring Style&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;
            {mentor?.mentoringStyle}
        &amp;lt;/p&amp;gt;
      &amp;lt;/section&amp;gt;

      &amp;lt;section className={styles['mentor-requirements']}&amp;gt;
        &amp;lt;h3&amp;gt;Who I'm Looking For&amp;lt;/h3&amp;gt;
        &amp;lt;p&amp;gt;
          {mentor?.audience}
        &amp;lt;/p&amp;gt;
      &amp;lt;/section&amp;gt;

      &amp;lt;div className={styles['apply-section']}&amp;gt;
        &amp;lt;Link to={`/mentor/${id}`} className={styles['btn-apply']}&amp;gt;
          Apply to Be My Mentee
        &amp;lt;/Link&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}

export default MentorProfile;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In frontend/src/pages/MentorProfile/SkeletonMentorProfile.module.css&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.back-link {
  display: inline-block;
  width: 120px;
  height: 16px;
  background: #e2e8f0;
  border-radius: 0.375rem;
  margin-bottom: 1.5rem;
  animation: pulse 2s infinite ease-in-out;
}

.mentor-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.mentor-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #e2e8f0;
  animation: pulse 2s infinite ease-in-out;
}

.mentor-info {
  flex: 1;
}

.mentor-name {
  width: 180px;
  height: 36px;
  background: #e2e8f0;
  border-radius: 0.375rem;
  margin: 0.25rem 0;
  animation: pulse 2s infinite ease-in-out;
  animation-delay: 0.2s;
}

.mentor-title {
  width: 200px;
  height: 18px;
  background: #f7fafc;
  border-radius: 0.375rem;
  margin: 0.25rem 0;
  animation: pulse 2s infinite ease-in-out;
  animation-delay: 0.4s;
}

.mentor-expertise {
  width: 160px;
  height: 16px;
  background: #f7fafc;
  border-radius: 0.375rem;
  margin-top: 0.5rem;
  animation: pulse 2s infinite ease-in-out;
  animation-delay: 0.6s;
}

.apply-section {
  text-align: center;
  margin-top: 1rem;
}

.btn-apply {
  display: inline-block;
  width: 200px;
  height: 48px;
  background: #e2e8f0;
  border-radius: 0.5rem;
  animation: pulse .3s infinite ease-in-out;
  animation-delay: 0.8s;
}

/* Pulse Animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the latest file for this part.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import styles from './SkeletonMentorProfile.module.css';

const SkeletonMentorProfile: React.FC = () =&amp;gt; {
  return (
    &amp;lt;main className={styles['mentor-detail']}&amp;gt;
      &amp;lt;div className={styles['back-link']}&amp;gt;&amp;lt;/div&amp;gt;

      &amp;lt;div className={styles['mentor-header']}&amp;gt;
        &amp;lt;div className={styles['mentor-avatar']} data-testid="skeleton-avatar"/&amp;gt;
        &amp;lt;div className={styles['mentor-info']}&amp;gt;
          &amp;lt;div className={styles['mentor-name']} /&amp;gt;
          &amp;lt;div className={styles['mentor-title']} /&amp;gt;
          &amp;lt;div className={styles['mentor-expertise']} /&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;

      &amp;lt;div className={styles['apply-section']}&amp;gt;
        &amp;lt;div className={styles['btn-apply']} /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
  );
};

export default SkeletonMentorProfile;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I think this can be seen as a full-stack course for someone who wants to move from mid-level to senior. For more awesome courses, I invite you to check out my live React/Laravel project, hosted on DigitalOcean with GitHub Actions and Docker. &lt;br&gt;
&lt;a href="https://coursecasts.com/" rel="noopener noreferrer"&gt;CourseCasts&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>react</category>
      <category>docker</category>
      <category>npm</category>
      <category>laravel</category>
    </item>
    <item>
      <title>How do you make FullStack Demo App for Interviews using Laravel + React with Dockerize Part 3</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Wed, 27 Aug 2025 15:12:33 +0000</pubDate>
      <link>https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-3-mci</link>
      <guid>https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-3-mci</guid>
      <description>&lt;p&gt;This is a new part of my Laravel + React dockerized series. Before moving on, you can check out the previous parts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-59hc"&gt; Laravel + React and Docker Part 1&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-2-2haf"&gt;Laravel + React and Docker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will continue now with the next part of the backend. This time, we’ll go a little deeper into Laravel, and even touch on some PHP-level details, starting with the bootstrap file located in:&lt;/p&gt;

&lt;p&gt;backend/bootstrap&lt;br&gt;
/app.php&lt;/p&gt;

&lt;p&gt;Basically, we slightly overwrote Laravel’s core:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    -&amp;gt;withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    -&amp;gt;withMiddleware(function (Middleware $middleware): void {
        //
    })
    -&amp;gt;withExceptions(function (Exceptions $exceptions): void {
        //
    })-&amp;gt;create();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I added four lines to bring the API into our app, which improves performance and reminds me of Lumen, or even other microframeworks like Slim PHP.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    -&amp;gt;withProviders([
            App\Infrastructure\Providers\AppServiceProvider::class,
    ])
    -&amp;gt;withRouting(
        web: __DIR__.'/../routes/web.php',
        api: __DIR__.'/../routes/api.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
        then: function () {

        }
    )
    -&amp;gt;withMiddleware(function (Middleware $middleware) {
        $middleware-&amp;gt;statefulApi();
        $middleware-&amp;gt;redirectGuestsTo('/v1/login');
    })
    -&amp;gt;withExceptions(function (Exceptions $exceptions): void {
        //
    })-&amp;gt;create();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because we want to communicate between the backend and frontend via HTTP, we need to allow access in Laravel by defining some configurations. One of them is creating a new file in backend/config named cors.php with the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

return [

    /*
    |--------------------------------------------------------------------------
    | Cross-Origin Resource Sharing (CORS) Configuration
    |--------------------------------------------------------------------------
    |
    | Here you may configure your settings for cross-origin resource sharing
    | or "CORS". This determines what cross-origin operations may execute
    | in web browsers. You are free to adjust these settings as needed.
    |
    | To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
    |
    */

    'paths' =&amp;gt; ['api/*', 'sanctum/csrf-cookie', "*"],

    'allowed_methods' =&amp;gt; ['*'],

    'allowed_origins' =&amp;gt; ['*'],

    'allowed_origins_patterns' =&amp;gt; [],

    'allowed_headers' =&amp;gt; ['*'],

    'exposed_headers' =&amp;gt; [],

    'max_age' =&amp;gt; 0,

    'supports_credentials' =&amp;gt; false,

];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are still working in the config folder, but this time we overwrite an existing file instead of creating a new one: database.php.&lt;/p&gt;

&lt;p&gt;Inside the 'sqlite' =&amp;gt; [ section, after 'synchronous' =&amp;gt; null, we add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'transaction_mode' =&amp;gt; 'DEFERRED',
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the JavaScript level, Axios is already included in Laravel 12, so there’s no need to install it separately. Since we are not using Inertia or Blade in Laravel, we can skip the resources/views folder.&lt;/p&gt;

&lt;p&gt;There are no navigation pages, commands, or console interactions on the Laravel backend side, so in this case we can also skip web.php and console.php from the routes folder.&lt;/p&gt;

&lt;p&gt;However, some routes are still required to send data from the database to React. For this purpose, we use api.php in the routes folder, which contains the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Infrastructure\Http\Controllers\API\User\MeController;
use App\Infrastructure\Http\Controllers\API\User\LoginController;
use App\Infrastructure\Http\Controllers\API\User\LogoutController;
use App\Infrastructure\Http\Controllers\API\User\RegisterController;
use App\Infrastructure\Http\Controllers\API\Mentor\MentorListController;
use App\Infrastructure\Http\Controllers\API\Mentor\MentorProfileController;

// we can have the api routes here, no issue
Route::prefix('v1')-&amp;gt;group(function () {
    Route::middleware('guest')-&amp;gt;group(function () {
        Route::post('/register', RegisterController::class);
        Route::post('/login', LoginController::class);
        Route::get('/mentors', MentorListController::class);
        Route::get('/mentors/{id}', MentorProfileController::class);
    });

    Route::middleware('auth:sanctum')-&amp;gt;group(function () {
        Route::get('/me', MeController::class);
        Route::post('/logout', LogoutController::class);
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though we are not talking about Sail, we should still discuss composer.json. We also mention Docker briefly, since in this case it’s just a small part.&lt;/p&gt;

&lt;p&gt;Because we updated the folder structure to follow DDD, we defined our own namespaces. We then used them in our code, and it looks like this:&lt;/p&gt;

&lt;p&gt;in array : "autoload": {&lt;br&gt;
        "psr-4": {&lt;/p&gt;

&lt;p&gt;}&lt;br&gt;
I added:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"App\\Domain\\": "app/Domain",  
"App\\Application\\": "app/Application",  
"App\\Infrastructure\\": "app/Infrastructure"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"autoload": {
        "psr-4": {
            "App\\": "app/",
            "App\\Domain\\": "app/Domain",
            "App\\Application\\": "app/Application",
            "App\\Infrastructure\\": "app/Infrastructure",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rest is the same with compose.json. The final step to dockerize a basic Laravel app is as follows: in the backend folder, create a new folder called docker. Inside it, create a file named Dockerfile (without any extension). Also, inside the docker folder, create another folder called nginx.&lt;/p&gt;

&lt;p&gt;Our Dockerfile contains the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# docker/Dockerfile
FROM php:8.3-fpm

# Install system dependencies including PostgreSQL dev headers
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y \
    git \
    curl \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    zip \
    unzip \
    libpq-dev   
RUN rm -rf /var/lib/apt/lists/*

# Install PHP extensions (now pdo_pgsql will work)
RUN docker-php-ext-install pdo pdo_pgsql mbstring exif pcntl bcmath

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html

# Copy composer files
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-scripts

# Copy the rest of the application
COPY . .

# Fix permissions
RUN chown -R www-data:www-data /var/www/html \
    &amp;amp;&amp;amp; chmod -R 775 storage bootstrap/cache

EXPOSE 9000

CMD ["php-fpm"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our last file default.conf which is inside of nginx folder had following code :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
    listen 80;
    server_name localhost;
    root /var/www/html/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To start this project (backend only for now), you need to follow these steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Install backend
Infrastructure following the DDD(ish) way of organizing the application.

1.cd backend

2.cp .env.example .env

3../dc.sh build ( docker compose buid )

4../dc.sh up -d ( docker compose up -d )

5../install.sh ( composer install, migrate and seed database )

Backend URL: http://localhost:8001/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope we can move forward with React after this. If you need a course—whether you’re at a junior or senior level—feel free to message me, or you can follow me on LinkedIn at LevelCoding&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How do you make FullStack Demo App for Interviews using Laravel + React with Dockerize Part 2</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Tue, 26 Aug 2025 08:09:02 +0000</pubDate>
      <link>https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-2-2haf</link>
      <guid>https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-part-2-2haf</guid>
      <description>&lt;p&gt;Previously, I stepped into the world of DDD. Now I’ll continue on the backend side with more DTOs and Infrastructure, which form the main Part 1 with its second subpart.&lt;/p&gt;

&lt;p&gt;For the business logic, we’ll continue with Mentor and User. So, let’s move to the next level:&lt;br&gt;
backend/app/Application/Mentor/&lt;/p&gt;

&lt;p&gt;Here, we start with the DTOs, and the first class we have is MentorDTO, with the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\Mentor\DTOs;

readonly class MentorDTO
{
    public function __construct(
        public int $id,
        public string $title,
        public array $expertise,
        public string $availability,
        public ?string $avatar = null,
        public string $bio,
        public string $technicalBio,
        public string $mentoringStyle,
        public string $audience,
    ) {}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the second DTO, we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\Mentor\DTOs;

readonly class MentorProfileDTO
{
    public function __construct(
        public int $id,
        public string $title,
        public string $fullName,
        public ?string $avatar,
        public array $expertise,
        public string $availability,
        public string $bio,
        public string $email,
        public string $technicalBio,
        public string $mentoringStyle,
        public string $audience,
    ) {}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s continue with the Queries for this business logic application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\Mentor\Queries;

use Illuminate\Support\Collection;
use Illuminate\Database\ConnectionInterface;
use App\Application\Mentor\DTOs\MentorProfileDTO;

class GetMentorsWithUsersQuery
{
    public function __construct(private ConnectionInterface $db) {}

    /**
     * Fetch the list of mentors with user data.
     *
     * @return Collection&amp;lt;int, MentorListDto&amp;gt;
     */
    public function execute(): Collection
    {
        return $this-&amp;gt;db-&amp;gt;table('mentors')
            -&amp;gt;join('users', 'mentors.user_id', '=', 'users.id')
            -&amp;gt;where('mentors.availability', '!=', 'paused')
            -&amp;gt;orderBy('mentors.created_at', 'desc')
            -&amp;gt;select([
                'mentors.id',
                'mentors.title',
                'mentors.expertise',
                'mentors.availability',
                'mentors.avatar as mentor_avatar',
                'mentors.bio',
                'mentors.technical_bio',
                'mentors.mentoring_style',
                'mentors.audience',
                'users.first_name',
                'users.last_name',
                'users.email',
            ])
            -&amp;gt;get()
            -&amp;gt;map(function ($row) {
                return new MentorProfileDTO(
                    id: $row-&amp;gt;id,
                    title: $row-&amp;gt;title,
                    fullName: "$row-&amp;gt;first_name $row-&amp;gt;last_name",
                    avatar: $row-&amp;gt;mentor_avatar ?? null,
                    expertise: json_decode($row-&amp;gt;expertise, true),
                    availability: $row-&amp;gt;availability,
                    bio: $row-&amp;gt;bio,
                    technicalBio: $row-&amp;gt;technical_bio,
                    mentoringStyle: $row-&amp;gt;mentoring_style,
                    audience: $row-&amp;gt;audience,
                    email: $row-&amp;gt;email,
                );
            });
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we have the Query class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\Mentor\Queries;

use Illuminate\Support\Facades\DB;
use Illuminate\Database\ConnectionInterface;
use App\Application\Mentor\DTOs\MentorProfileDTO;

class MentorProfileQuery
{
    public function __construct(private ConnectionInterface $db) {}

    public function execute(int $mentorId): ?MentorProfileDTO
    {
        $record = $this-&amp;gt;db-&amp;gt;table('mentors')
            -&amp;gt;join('users', 'mentors.user_id', '=', 'users.id')
            -&amp;gt;where('mentors.id', $mentorId)
            -&amp;gt;where('mentors.availability', '!=', 'paused') // only active
            -&amp;gt;select([
                'mentors.id as mentor_id',
                'users.first_name',
                'users.last_name',
                'users.email',
                'mentors.title',
                'mentors.bio',
                'mentors.technical_bio',
                'mentors.mentoring_style',
                'mentors.audience',
                'mentors.avatar as mentor_avatar',
                'mentors.expertise',
                'mentors.availability',
                'mentors.created_at as mentor_created_at',
            ])
            -&amp;gt;first();

        if (! $record) {
            return null;
        }

        return new MentorProfileDTO(
            id: $record-&amp;gt;mentor_id,
            fullName: $record-&amp;gt;first_name . ' ' . $record-&amp;gt;last_name,
            email: $record-&amp;gt;email,
            title: $record-&amp;gt;title,
            bio: $record-&amp;gt;bio,
            technicalBio: $record-&amp;gt;technical_bio,
            mentoringStyle: $record-&amp;gt;mentoring_style,
            audience: $record-&amp;gt;audience,
            avatar: $record-&amp;gt;mentor_avatar ?? $record-&amp;gt;user_avatar,
            expertise: json_decode($record-&amp;gt;expertise, true),
            availability: $record-&amp;gt;availability,
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we move on to the User business logic, which is more advanced. A new feature in this project is the use of Actions, with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\User\Actions;

use App\Domain\User\Entities\User;
use App\Application\User\DTOs\LoginUserDTO;
use App\Domain\User\Repositories\UserRepositoryInterface;

class AuthenticateUserAction
{
    public function __construct(
        private UserRepositoryInterface $userRepository
    ) {}

    public function execute(LoginUserDTO $dto): User
    {

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To wrap things up, here’s the Action class:&lt;br&gt;
`&lt;br&gt;
&amp;lt;?php&lt;/p&gt;

&lt;p&gt;namespace App\Application\User\Actions;&lt;/p&gt;

&lt;p&gt;use App\Application\User\DTOs\RegisterUserDTO;&lt;br&gt;
use App\Domain\User\Entities\User;&lt;br&gt;
use App\Domain\User\Repositories\UserRepositoryInterface;&lt;/p&gt;

&lt;p&gt;class RegisterUserAction&lt;br&gt;
{&lt;br&gt;
    public function __construct(&lt;br&gt;
        private UserRepositoryInterface $userRepository&lt;br&gt;
    ) {}&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function execute(RegisterUserDTO $dto): User
{

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;}`&lt;/p&gt;

&lt;p&gt;Now we step back one level to define a DTO class for it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\User\DTOs;

class LoginUserDTO
{
    public function __construct(
        public readonly string $email,
        public readonly string $password
    ) {}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Continuing in the DTO folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\User\DTOs;

class RegisterUserDTO
{
    public function __construct(
        public readonly string $name,
        public readonly string $email,
        public readonly string $password
    ) {}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And lastly, we have the DTOs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\User\DTOs;

class UserDTO
{
    public function __construct(
        public readonly int $id,
        public readonly string $name,
        public readonly string $email,
        public readonly string $password,
    ) {}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, I can’t say that Resources are something new in Laravel—I think I first used them back in a Laravel 7 project, which was personal and is still running online for everyone who loves chill music.&lt;/p&gt;

&lt;p&gt;Here’s an example I found, which I think is a more modern way to avoid code conflicts. It feels almost like a TypeScript-style version of PHP. :))&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Application\User\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class UserResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id' =&amp;gt; $this-&amp;gt;id(),
            'name' =&amp;gt; $this-&amp;gt;name(),
            'email' =&amp;gt; $this-&amp;gt;email()-&amp;gt;value(),
        ];
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we go back two levels and continue with Infrastructure. At first, it may look like a slightly ‘hellish’ DDD concept, but after years of working with it, I find it closer to Symfony. And even though it’s considered dead, it still reminds me of the Yii framework.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Factories;

use App\Application\Mentor\DTOs\MentorDTO;
use App\Domain\Mentor\Entities\Mentor;
use App\Domain\Mentor\Enums\Availability;
use App\Domain\Mentor\Factories\MentorFactoryInterface;
use App\Domain\Mentor\ValueObjects\ExpertiseList;

class MentorFactory implements MentorFactoryInterface
{
    public function from(object|array $data): Mentor
    {
        return new Mentor(
            id: $record-&amp;gt;id,
            title: $record-&amp;gt;title,
            expertise: new ExpertiseList(json_decode($record-&amp;gt;expertise, true)),
            availability: Availability::from($data-&amp;gt;availability),
            avatar: $record-&amp;gt;avatar,
            bio: $record-&amp;gt;bio
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A smaller example compared to the previous one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Factories;

use App\Domain\Mentor\ValueObjects\ExpertiseList;
use App\Domain\User\ValueObjects\MentorValueObjectsFactoryInterface;

class MentorValueObjectsFactory implements MentorValueObjectsFactoryInterface
{
    public function expertiseList(array $value): ExpertiseList
    {
        return new ExpertiseList($value);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I think this is more of an extension of the basic factory, but it’s a well-structured UserFactory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Factories;

use App\Application\User\DTOs\UserDTO;
use App\Domain\User\ValueObjects\UserValueObjectsFactoryInterface;

class UserFactory
{
    public function __construct(
        private readonly UserValueObjectsFactoryInterface $voFactory
    ) {}

    public function from(object|array $data): Entity
    {
        return new Entity(
            id: $record-&amp;gt;id,
            first_name: $record-&amp;gt;first_name,
            last_name: $record-&amp;gt;last_name,
            email: $this-&amp;gt;voFactory-&amp;gt;email($record-&amp;gt;email),
            password: $this-&amp;gt;voFactory-&amp;gt;password($record-&amp;gt;password),
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And lastly, the Factory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Factories;

use App\Domain\User\ValueObjects\Email;
use App\Domain\User\ValueObjects\Password;
use App\Domain\User\ValueObjects\UserValueObjectsFactoryInterface;

class UserValueObjectsFactory implements UserValueObjectsFactoryInterface
{
    public function email(string $value): Email
    {
        return new Email($value);
    }

    public function password(string $value): Password
    {
        return new Password($value);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we continue with one of the oldest and most common patterns in Laravel—the Controller. It’s simply been moved to another folder and given a more modern structure. As usual, we’ll keep the business logic for Mentor and User.&lt;/p&gt;

&lt;p&gt;Inside API/Mentor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Http\Controllers\API\Mentor;

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Infrastructure\Http\Controllers\Controller;
use App\Application\Mentor\Queries\GetMentorsWithUsersQuery;

class MentorListController extends Controller
{    
    public function __invoke(GetMentorsWithUsersQuery $query): JsonResponse
    {
       $mentors = $query-&amp;gt;execute();

        return response()-&amp;gt;json([
            'data' =&amp;gt; $mentors,
            'total' =&amp;gt; $mentors-&amp;gt;count(),
        ]);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to wrap up, here’s the Mentor controller:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Http\Controllers\API\Mentor;

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Infrastructure\Http\Controllers\Controller;
use App\Application\Mentor\Queries\MentorProfileQuery;
use App\Application\Mentor\Queries\GetMentorsWithUsersQuery;

class MentorProfileController extends Controller
{    
    public function __invoke(MentorProfileQuery $query, int $id): JsonResponse
    {
        $mentor = $query-&amp;gt;execute($id);

        return response()-&amp;gt;json(['data' =&amp;gt; $mentor ?? null]);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Something rare I’ve seen in Laravel is a refactored LoginController. I think 90% of Laravel projects end up with a lot of code inside it, almost like a Singleton class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Http\Controllers\API\User;

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Application\User\DTOs\LoginUserDTO;
use App\Application\User\Resources\UserResource;
use App\Infrastructure\Requests\LoginRequest;
use App\Infrastructure\Http\Controllers\Controller;
use App\Application\User\Actions\AuthenticateUserAction;

class LoginController extends Controller
{
    public function __construct(
        private readonly AuthenticateUserAction $authAction
    ) {}

    public function __invoke(
        LoginRequest $request
    ): JsonResponse {
        $user = $authAction-&amp;gt;execute($request-&amp;gt;dto());

        // Start session
        \Auth::loginUsingId($user-&amp;gt;id());

        return UserResource::make($user)-&amp;gt;response();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s another example from the category of web development pleasures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Http\Controllers\API\User;

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Infrastructure\Http\Controllers\Controller;

class LogoutController extends Controller
{    
    public function __invoke(Request $request): JsonResponse
    {
        \Auth::guard('web')-&amp;gt;logout();
        $request-&amp;gt;session()-&amp;gt;invalidate();
        $request-&amp;gt;session()-&amp;gt;regenerateToken();

        return response()-&amp;gt;json(['message' =&amp;gt; 'Logged out']);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In general, most Laravel versions use a facade or a custom class to retrieve the current user. I think this is a good example of optimization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Http\Controllers\API\User;

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Application\User\Resources\UserResource;
use App\Infrastructure\Http\Controllers\Controller;

class MeController extends Controller
{    
    public function __invoke(Request $request): JsonResponse
    {
        $user = $request-&amp;gt;user();

        if (! $user) {
            return response()-&amp;gt;json(['message' =&amp;gt; 'Unauthenticated'], 401);
        }

        return UserResource::make($user)-&amp;gt;response();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let’s look at the longest controller in our project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Http\Controllers\API\User;

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Application\User\DTOs\RegisterUserDTO;
use App\Application\User\Resources\UserResource;
use App\Infrastructure\Http\Controllers\Controller;
use App\Application\User\Actions\RegisterUserAction;
use App\Infrastructure\Requests\RegisterRequest;

class RegisterController extends Controller
{
    public function __construct(
        private readonly RegisterUserAction $registerUserAction
    ) {}

    public function __invoke(
        RegisterRequest $request,
    ): JsonResponse {

        $user = $this-&amp;gt;registerUserAction-&amp;gt;execute($request-&amp;gt;dto());

        return response()-&amp;gt;json([
            'message' =&amp;gt; 'User registered successfully',
        ], 201);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Personally, I’m a fan of the Service concept. For me, relying only on controllers feels limiting in the PHP world.&lt;/p&gt;

&lt;p&gt;To take another step in the request lifecycle, I’ll continue with the Request concept.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Requests;

use DomainException;

use App\Application\User\DTOs\LoginUserDTO;
use Illuminate\Foundation\Http\FormRequest;

class LoginRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;

    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array&amp;lt;string, \Illuminate\Contracts\Validation\ValidationRule|array&amp;lt;mixed&amp;gt;|string&amp;gt;
     */
    public function rules(): array
    {
        return [
            'email' =&amp;gt; ['required', 'email'],
            'password' =&amp;gt; ['required', 'string'],
        ];
    }

    public function dto(): LoginUserDTO
    {
        return new LoginUserDTO(
            email: $this-&amp;gt;string('email')-&amp;gt;trim()-&amp;gt;toString(),
            password: $this-&amp;gt;string('password')-&amp;gt;trim()-&amp;gt;toString()
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I think this is a new function, dto(). I didn’t see it in Laravel 11.&lt;/p&gt;

&lt;p&gt;It looks like another Symfony pattern adapted to Laravel. I got this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Requests;

use App\Application\User\DTOs\RegisterUserDTO;
use Illuminate\Foundation\Http\FormRequest;

class RegisterRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array&amp;lt;string, \Illuminate\Contracts\Validation\ValidationRule|array&amp;lt;mixed&amp;gt;|string&amp;gt;
     */
    public function rules(): array
    {
        return [
            'first_name' =&amp;gt; ['required', 'string', 'max:255'],
            'last_name' =&amp;gt; ['required', 'string', 'max:255'],
            'email' =&amp;gt; ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' =&amp;gt; ['required', 'string', 'min:8'],
        ];
    }

    public function dto(): RegisterUserDTO
    {
        return new RegisterUserDTO(
            first_name: $this-&amp;gt;string('first_name')-&amp;gt;trim()-&amp;gt;toString(),
            last_name: $this-&amp;gt;string('last_name')-&amp;gt;trim()-&amp;gt;toString(),
            email: $this-&amp;gt;string('email')-&amp;gt;trim()-&amp;gt;toString(),
            password: $this-&amp;gt;string('password')-&amp;gt;trim()-&amp;gt;toString(),
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model isn’t new in Laravel, but here it’s simply placed in the Infrastructure folder. In my view, compared with other frameworks (except for the big switch in version 12), Laravel is still quite easy to adapt across versions—probably thanks to its strong documentation. So, I don’t really see anything new here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    /** @use HasFactory&amp;lt;\Database\Factories\UserFactory&amp;gt; */
    use HasFactory, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var list&amp;lt;string&amp;gt;
     */
    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var list&amp;lt;string&amp;gt;
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * Get the attributes that should be cast.
     *
     * @return array&amp;lt;string, string&amp;gt;
     */
    protected function casts(): array
    {
        return [
            'email_verified_at' =&amp;gt; 'datetime',
            'password' =&amp;gt; 'hashed',
        ];
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this project, we don’t need to use any providers, so we can skip that step. This brings us to one of the most loved features in Laravel when it comes to project optimization: repositories.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Repositories;

use App\Domain\Mentor\Entities\Mentor;
use App\Domain\Mentor\Repositories\MentorRepositoryInterface;
use App\Domain\Mentor\Factories\MentorEntityFactoryInterface;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Support\Collection;

class MentorRepository implements MentorRepositoryInterface
{
    public function __construct(
        private ConnectionInterface $db,
        private MentorEntityFactoryInterface $entityFactory
    ) {}

    public function findAll(): Collection
    {
        $records = $this-&amp;gt;db-&amp;gt;table('mentors')
            -&amp;gt;where('availability', '!=', 'paused')
            -&amp;gt;orderBy('created_at', 'desc')
            -&amp;gt;get();

        return $records-&amp;gt;map(fn ($r) =&amp;gt; $this-&amp;gt;toEntity($r));
    }

    public function findById(int $id): ?Mentor
    {
        $record = $this-&amp;gt;db-&amp;gt;table('mentors')-&amp;gt;where('id', $id)-&amp;gt;first();

        return $record ? $this-&amp;gt;toEntity($record) : null;
    }

    private function toEntity(array $record): Mentor
    {
        return $this-&amp;gt;entityFactory-&amp;gt;from([
            'id' =&amp;gt; $record['id'],
            'title' =&amp;gt; $record['title'],
            'expertise' =&amp;gt; json_decode($record['expertise'], true),
            'availability' =&amp;gt; $record['availability'],
            'avatar' =&amp;gt; $record['avatar'] ?? null,
            'bio' =&amp;gt; $record['bio'] ?? null
        ]);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, regarding the UserRepository class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Infrastructure\Repositories;

use App\Domain\User\Entities\User;
use App\Domain\User\ValueObjects\Email;
use Illuminate\Database\ConnectionInterface;
use App\Infrastructure\Factories\UserFactory;
use App\Domain\User\Factories\UserEntityFactoryInterface;
use App\Domain\User\Repositories\UserRepositoryInterface;

class UserRepository implements UserRepositoryInterface
{
    public function __construct(
        private ConnectionInterface $db,
        private UserEntityFactoryInterface $userFactory,
        private UserFactory $dataMapper
    ) {}

    /**
     * Create a new user in the database
     */
    public function create(User $user): User
    {
        $id = $this-&amp;gt;db-&amp;gt;table('users')-&amp;gt;insertGetId([
            'first_name' =&amp;gt; $user-&amp;gt;firstName(),
            'last_name' =&amp;gt; $user-&amp;gt;lastName(),
            'email' =&amp;gt; $user-&amp;gt;email()-&amp;gt;value(),
            'password' =&amp;gt; $user-&amp;gt;password()-&amp;gt;value(),
            'created_at' =&amp;gt; now(),
            'updated_at' =&amp;gt; now(),
        ]);

        return $this-&amp;gt;findById($id);
    }

    /**
     * Find user by email
     */
    public function findByEmail(Email $email): ?User
    {
        $record = $this-&amp;gt;db-&amp;gt;table('users')-&amp;gt;where('email', $email-&amp;gt;value())-&amp;gt;first();

        if (! $record) {
            return null;
        }

        return $this-&amp;gt;userFactory-&amp;gt;from($record);
    }

    /**
     * Find user by ID
     */
    public function findById(int $id): ?User
    {
        $record = $this-&amp;gt;db-&amp;gt;table('users')-&amp;gt;where('id', $id)-&amp;gt;first();

        if (! $record) {
            return null;
        }

        return $this-&amp;gt;userFactory-&amp;gt;from($record);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For now, we’ll end with this part. In the next section, we’ll continue with another Laravel concept to reach our final goal: enabling communication between the React and Laravel app in a dockerized environment.&lt;/p&gt;

&lt;p&gt;If you like my work, you can find me on levelcoding.com&lt;br&gt;
 or on LinkedIn (levelcoding). A share or follow on LinkedIn would really help!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How do you make FullStack Demo App for Interviews using Laravel + React with Dockerize Part 1</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Mon, 25 Aug 2025 11:00:28 +0000</pubDate>
      <link>https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-59hc</link>
      <guid>https://dev.to/pirvanm/how-do-you-make-fullstack-demo-app-for-interviews-using-laravel-react-with-dockerize-59hc</guid>
      <description>&lt;p&gt;Sometimes, even if the interview is only for a frontend role, I know from experience that it doesn’t take long until the discussion shifts toward full-stack. For example, at the end of one process, HR ended up asking about my experience with Go, even though the position was originally for React. &lt;br&gt;
  That’s why I often push myself: instead of building only the frontend in React, I also implement the backend. &lt;br&gt;
  Since I’m more familiar with Laravel, I usually create the backend part as well, set up the communication between the two, and even prepare a Dockerized version. &lt;br&gt;
How are interviews usually structured for you? &lt;br&gt;
I completed this practical test for a specific country and company in Europe.&lt;/p&gt;

&lt;p&gt;This project feels like a Middle–Senior level challenge, so I plan to split it into 2 main parts.&lt;/p&gt;

&lt;p&gt;Each Main Part will then be divided into 4–5 subparts to keep the learning and implementation process structured.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Main Part 1 &lt;br&gt;
→ Subpart 1 (since we need to start working with dynamic data, this will be the first step).&lt;/p&gt;

&lt;p&gt;In project  backend/ in folder database which have  /migrations/ i made :&lt;/p&gt;

&lt;p&gt;create_mentors_table.php&lt;br&gt;
create_mentor_applications_table.php&lt;br&gt;
create_mentorships_table.php&lt;br&gt;
_create_personal_access_tokens_table.php&lt;/p&gt;

&lt;p&gt;create_mentors_table.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function up(): void
    {
        Schema::create('mentors', function (Blueprint $table) {
            $table-&amp;gt;id();
            $table-&amp;gt;unsignedBigInteger('user_id');
            $table-&amp;gt;string('title');
            $table-&amp;gt;text('bio');
            $table-&amp;gt;text('technical_bio');
            $table-&amp;gt;text('mentoring_style');
            $table-&amp;gt;text('audience');
            $table-&amp;gt;string('avatar')-&amp;gt;nullable();
            $table-&amp;gt;json('expertise');
            $table-&amp;gt;string('availability');
            $table-&amp;gt;timestamps();


            $table-&amp;gt;foreign('user_id')-&amp;gt;references('id')-&amp;gt;on('users')-&amp;gt;onDelete('cascade');
            $table-&amp;gt;index('user_id');
        });
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;create_mentor_applications_table.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Schema::create('mentor_applications', function (Blueprint $table) {
            $table-&amp;gt;id();
            $table-&amp;gt;unsignedBigInteger('mentor_id'); // foreign to user_id
            $table-&amp;gt;unsignedBigInteger('mentee_id'); // foreign to user_id
            $table-&amp;gt;text('message');
            $table-&amp;gt;string('status'); // pending, accepted, rejected, withdrawn
            $table-&amp;gt;timestamp('responded_at')-&amp;gt;nullable();
            $table-&amp;gt;timestamps();
        });

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create_mentorships_table.php

` public function up(): void
    {
        Schema::create('mentorships', function (Blueprint $table) {
            $table-&amp;gt;id();
            $table-&amp;gt;unsignedBigInteger('mentor_id'); // foreign to user_id
            $table-&amp;gt;unsignedBigInteger('mentee_id'); // foreign to user_id
            $table-&amp;gt;timestamp('started_at');
            $table-&amp;gt;timestamp('ended_at')-&amp;gt;nullable();
            $table-&amp;gt;string('status'); // active, completed, terminated
            $table-&amp;gt;timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('mentorships');
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In file personal_access_tokens_table.php i write :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Schema::create('personal_access_tokens', function (Blueprint $table) {
            $table-&amp;gt;id();
            $table-&amp;gt;morphs('tokenable');
            $table-&amp;gt;text('name');
            $table-&amp;gt;string('token', 64)-&amp;gt;unique();
            $table-&amp;gt;text('abilities')-&amp;gt;nullable();
            $table-&amp;gt;timestamp('last_used_at')-&amp;gt;nullable();
            $table-&amp;gt;timestamp('expires_at')-&amp;gt;nullable()-&amp;gt;index();
            $table-&amp;gt;timestamps();
        });

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;database/factories&lt;br&gt;
/ MentorDatabaseFactory.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public function create(array $overrides = []): int
    {
        $data = array_merge([
            'user_id' =&amp;gt; $overrides['user_id'] ?? throw new \InvalidArgumentException('user_id is required'),
            'title' =&amp;gt; fake()-&amp;gt;jobTitle(),
            'bio' =&amp;gt; fake()-&amp;gt;paragraph(3),
            'technical_bio' =&amp;gt; fake()-&amp;gt;paragraph(3),
            'mentoring_style' =&amp;gt; fake()-&amp;gt;paragraph(3),
            'audience' =&amp;gt; fake()-&amp;gt;paragraph(3),
            'avatar' =&amp;gt; fake()-&amp;gt;optional(0.7)-&amp;gt;imageUrl(300, 300, 'people'),
            'expertise' =&amp;gt; json_encode(fake()-&amp;gt;words(random_int(3, 6))),
            'availability' =&amp;gt; fake()-&amp;gt;randomElement(['open', 'limited']),
            'created_at' =&amp;gt; now(),
            'updated_at' =&amp;gt; now(),
        ], $overrides);

        return DB::table('mentors')-&amp;gt;insertGetId($data);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;UserDatabaseFactory.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class UserDatabaseFactory
{
    public function create(array $overrides = []): int
    {
        $firstName = $overrides['first_name'] ?? fake()-&amp;gt;firstName();
        $lastName = $overrides['last_name'] ?? fake()-&amp;gt;lastName();

        $data = array_merge([
            'first_name' =&amp;gt; $firstName,
            'last_name' =&amp;gt; $lastName,
            'email' =&amp;gt; $overrides['email'] ?? strtolower("{$firstName}.{$lastName}") . '@example.com',
            'password' =&amp;gt; $overrides['password'] ?? bcrypt('password'),
            'email_verified_at' =&amp;gt; now(),
            'created_at' =&amp;gt; now(),
            'updated_at' =&amp;gt; now(),
        ], $overrides);

        return DB::table('users')-&amp;gt;insertGetId($data);
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;database/seeders&lt;br&gt;
/DatabaseSeeder.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        $userFactory = new UserDatabaseFactory();
        $mentorFactory = new MentorDatabaseFactory();

        $mentorsData = [
            [
                'first_name' =&amp;gt; 'Sarah',
                'last_name' =&amp;gt; 'Johnson',
                'title' =&amp;gt; 'Senior Laravel Developer',
                'expertise' =&amp;gt; ['laravel', 'php', 'testing', 'ddd'],
                'availability' =&amp;gt; 'open',
                'avatar' =&amp;gt; 'https://randomuser.me/api/portraits/men/45.jpg',
            ],
            [
                'first_name' =&amp;gt; 'Michael',
                'last_name' =&amp;gt; 'Chen',
                'title' =&amp;gt; 'Full-Stack Engineer &amp;amp; Mentor',
                'expertise' =&amp;gt; ['vue', 'javascript', 'api', 'architecture'],
                'availability' =&amp;gt; 'open',
                'avatar' =&amp;gt; 'https://randomuser.me/api/portraits/women/45.jpg',
            ],
            [
                'first_name' =&amp;gt; 'Amina',
                'last_name' =&amp;gt; 'Khalid',
                'title' =&amp;gt; 'Backend Specialist',
                'expertise' =&amp;gt; ['php', 'symfony', 'laravel', 'microservices'],
                'availability' =&amp;gt; 'limited',
                'avatar' =&amp;gt; 'https://randomuser.me/api/portraits/men/45.jpg',
            ],
            [
                'first_name' =&amp;gt; 'James',
                'last_name' =&amp;gt; 'Wilson',
                'title' =&amp;gt; 'DevOps &amp;amp; Laravel CI/CD',
                'expertise' =&amp;gt; ['docker', 'ci/cd', 'aws', 'deployment'],
                'availability' =&amp;gt; 'open',
                'avatar' =&amp;gt; 'https://randomuser.me/api/portraits/men/45.jpg',
            ],
            [
                'first_name' =&amp;gt; 'Elena',
                'last_name' =&amp;gt; 'Martinez',
                'title' =&amp;gt; 'UX Engineer &amp;amp; Mentor',
                'expertise' =&amp;gt; ['ux', 'figma', 'tailwind', 'frontend'],
                'availability' =&amp;gt; 'limited',
                'avatar' =&amp;gt; 'https://randomuser.me/api/portraits/men/45.jpg',
            ],
            [
                'first_name' =&amp;gt; 'David',
                'last_name' =&amp;gt; 'Park',
                'title' =&amp;gt; 'Laravel Educator',
                'expertise' =&amp;gt; ['teaching', 'laravel', 'best practices', 'security'],
                'availability' =&amp;gt; 'open',
                'avatar' =&amp;gt; 'https://randomuser.me/api/portraits/women/45.jpg',
            ],
        ];

        foreach ($mentorsData as $data) {
            $userId = $userFactory-&amp;gt;create([
                'first_name' =&amp;gt; $data['first_name'],
                'last_name' =&amp;gt; $data['last_name'],
            ]);

            $mentorFactory-&amp;gt;create([
                'user_id' =&amp;gt; $userId,
                'title' =&amp;gt; $data['title'],
                'expertise' =&amp;gt; json_encode($data['expertise']),
                'availability' =&amp;gt; $data['availability'],
                'avatar' =&amp;gt; $data['avatar']
            ]);
        }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✨ Even though I started my career with Laravel 4 and have worked with every version since, I was very curious about Laravel 12. That curiosity pushed me to dive deeper into Domain-Driven Design (DDD), and I’ve been learning and practicing it.&lt;/p&gt;

&lt;p&gt;✅ For now, I feel comfortable enough with the fundamentals, so I’m ready to move on to the next step. This will be Subpart 2 of Main Part 1: Domain, where I’ll continue exploring with some practical examples.&lt;/p&gt;

&lt;p&gt;This way, it flows naturally:&lt;/p&gt;

&lt;p&gt;You highlight your experience.&lt;/p&gt;

&lt;p&gt;You show curiosity and learning (DDD).&lt;/p&gt;

&lt;p&gt;As business logic we can split this app in 2 part Mentor and User : &lt;/p&gt;

&lt;p&gt;on user next steps is this folder structure : &lt;br&gt;
backend/app/Domain&lt;br&gt;
/User/&lt;/p&gt;

&lt;p&gt;backend/app/Domain/User/Entities&lt;br&gt;
/User.php&lt;/p&gt;

&lt;p&gt;I think the model is the most common part of every Laravel app, and now we can quickly see the differences in models within a modern Laravel 12 application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Domain\User\Entities;

use App\Domain\User\ValueObjects\Email;
use App\Domain\User\ValueObjects\Password;

class User
{
    public function __construct(
        private int $id,
        private string $first_name,
        private string $last_name,
        private Email $email,
        private Password $password
    ) {}

    public function id(): int
    {
        return $this-&amp;gt;id;
    }

    public function firstName(): string
    {
        return $this-&amp;gt;first_name;
    }

    public function lastName(): string
    {
        return $this-&amp;gt;last_name;
    }

    public function email(): Email
    {
        return $this-&amp;gt;email;
    }

    public function password(): Password
    {
        return $this-&amp;gt;password;
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;app/Domain/User/Factories&lt;br&gt;
/UserFactoryInterface.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Domain\User\Factories;

use App\Application\User\DTOs\UserDTO;
use App\Domain\User\Entities\User;

interface UserFactoryInterface
{
    public function from(object|array $data): Entity;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;backend/app/Domain/User/Factories&lt;br&gt;
/UserValueObjectsFactoryInterface.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Domain\User\Factories;

use App\Domain\User\ValueObjects\Email;
use App\Domain\User\ValueObjects\Password;

interface UserValueObjectsFactoryInterface
{
    public function email(string $value): Email;
    public function password(string $value): Password;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;backend/app/Domain/User/Repositories&lt;br&gt;
/UserRepositoryInterface.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Domain\User\Repositories;

use App\Domain\User\Entities\User;
use App\Domain\User\ValueObjects\Email;

interface UserRepositoryInterface
{
    public function create(array $data): User;
    public function findByEmail(Email $email): ?User;
    public function findById(int $id): ?User;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;backend/app/Domain/User/ValueObjects&lt;br&gt;
/Email.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Domain\User\ValueObjects;

use InvalidArgumentException;

class Email
{
    public function __construct(private string $value)
    {
        if (! filter_var($value, FILTER_VALIDATE_EMAIL)) {
            throw new InvalidArgumentException("Invalid email: {$value}");
        }
        $this-&amp;gt;value = strtolower(trim($value));
    }

    public function value(): string
    {
        return $this-&amp;gt;value;
    }

    public function equals(self $other): bool
    {
        return $this-&amp;gt;value() === $other-&amp;gt;value();
    }

    public function __toString(): string
    {
        return $this-&amp;gt;value();
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;app/Domain/User/ValueObjects&lt;br&gt;
/Password.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Domain\User\ValueObjects;

use InvalidArgumentException;

class Password
{
    public function __construct(private string $value)
    {
        if (strlen($value) &amp;lt; 8) {
            throw new InvalidArgumentException('Password must be at least 8 characters.');
        }
    }

    public function value(): string
    {
        return $this-&amp;gt;value;
    }

    public function matches(string $plainText): bool
    {
        return password_verify($plainText, $this-&amp;gt;value);
    }

    public static function hash(string $plainText): self
    {
        return new self(password_hash($plainText, PASSWORD_DEFAULT));
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🛠 Maybe because 4 months ago I worked with the Symfony Framework, and since I’m a full-stack developer, I often work with different technologies.&lt;/p&gt;

&lt;p&gt;In 2023, I spent some time with CodeIgniter, while most of my frontend work was with Vue.js. Occasionally, I also worked with React. Unfortunately, in 2024, I had to spend a lot of time using jQuery (because of company requirements).&lt;/p&gt;

&lt;p&gt;Now, I feel a bit unsure about what the best practices in Laravel are today. 🤔&lt;br&gt;
👉 Any feedback or advice from the community would be really welcome.&lt;/p&gt;

&lt;p&gt;After this, I will continue with the rest of the DDD implementation in the Laravel 12 app.&lt;/p&gt;

&lt;p&gt;If you like my work, feel free to follow me on the web or on LinkedIn at LevelCoding.”&lt;/p&gt;

&lt;p&gt;And I used AI only to correct my grammatical phrases — the code is entirely thought out by me.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>migration</category>
      <category>ddd</category>
      <category>database</category>
    </item>
    <item>
      <title>100 Days of Servers Distributions- Day 9: Why HAProxy for Load Balancing?</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Tue, 15 Oct 2024 16:26:18 +0000</pubDate>
      <link>https://dev.to/pirvanm/100-days-of-servers-distributions-day-9-why-haproxy-for-load-balancing-2o3e</link>
      <guid>https://dev.to/pirvanm/100-days-of-servers-distributions-day-9-why-haproxy-for-load-balancing-2o3e</guid>
      <description>&lt;p&gt;When it comes to ensuring the scalability, reliability, and high availability of your web applications, choosing the right load balancer is critical. Among the myriad of options available, HAProxy stands out as a popular and trusted solution. Here’s why HAProxy continues to be a top choice for load balancing across different environments:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Proven Reliability and Stability&lt;br&gt;
HAProxy has been around for over two decades, and during that time, it has earned a reputation for being extremely reliable. Many large-scale enterprises, including the likes of Airbnb, Twitter, and Stack Overflow, rely on HAProxy to keep their applications running smoothly. Its performance is battle-tested in some of the most demanding environments, which makes it a trustworthy choice for both small startups and large enterprises.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;High Performance and Low Latency&lt;br&gt;
HAProxy is known for its ability to handle extremely high volumes of traffic with minimal latency. It’s designed to efficiently distribute requests across multiple servers, maximizing the use of available resources and ensuring that users experience fast, uninterrupted service. Whether handling hundreds of requests per second or hundreds of thousands, HAProxy performs exceptionally well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Advanced Features for Flexible Load Balancing&lt;br&gt;
HAProxy offers a wide range of load balancing algorithms to fit different needs, from simple round-robin to more advanced options like least connections, source IP hashing, and URI-based routing. This flexibility allows you to tailor the traffic distribution to the specific requirements of your application, ensuring optimal performance.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It also supports both Layer 4 (TCP) and Layer 7 (HTTP) load balancing, giving you more control over traffic routing. At Layer 7, it can inspect HTTP headers, cookies, and content, which enables intelligent traffic routing based on deeper application logic.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Health Checks and Failover
HAProxy has built-in health checks, which regularly monitor the health of backend servers. If a server becomes unresponsive or fails, HAProxy automatically removes it from the pool, directing traffic only to healthy servers. This ensures high availability and helps avoid downtime, which is crucial for mission-critical applications.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Additionally, in the event of server failure, HAProxy supports automatic failover, rerouting traffic to backup servers or another data center, ensuring continuity of service.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Security
In today’s digital landscape, security is paramount, and HAProxy provides several mechanisms to protect your application:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;SSL termination: HAProxy can handle SSL encryption and decryption, offloading this processor-heavy task from your application servers.&lt;br&gt;
DDoS protection: HAProxy can mitigate certain types of DDoS attacks by limiting the number of requests from a single IP address or by enforcing rate limits.&lt;br&gt;
Access control: You can define rules to restrict access based on IP, geolocation, or other criteria, preventing malicious actors from reaching your application.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ease of Use and Configuration
Despite being powerful, HAProxy remains relatively straightforward to set up and configure. Its configuration file is well-documented and highly customizable, making it easy to tailor HAProxy to your specific needs. Whether you’re setting up a simple load balancer or a complex architecture with SSL offloading and multiple backend pools, HAProxy makes it accessible.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Moreover, HAProxy offers a web-based management interface, allowing for real-time monitoring and adjustments, further simplifying administration.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Source with a Strong Community
HAProxy is open-source, which means it’s free to use and has a vibrant community of developers contributing to its ongoing improvement. This open nature ensures that HAProxy remains up-to-date with the latest trends in web traffic management while being accessible to a wide range of users.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you need additional enterprise-level features, HAProxy Technologies offers a commercial version, HAProxy Enterprise, which provides enhanced support, advanced features, and long-term stability.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Scalability&lt;br&gt;
As your business grows, so will the demands on your infrastructure. HAProxy is built to scale, making it easy to add new servers to your backend pool and balance the increasing traffic load. Whether you’re running on a single server or a distributed, multi-data-center setup, HAProxy can handle the scaling demands seamlessly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cost Efficiency&lt;br&gt;
HAProxy is free and open-source, which allows organizations to significantly cut down on costs associated with load balancing solutions. Even with large-scale operations, HAProxy’s performance, combined with its low resource consumption, makes it a cost-effective choice.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Conclusion&lt;br&gt;
HAProxy’s combination of performance, flexibility, and reliability makes it an outstanding choice for load balancing. Whether you're running a small web app or managing a complex, high-traffic infrastructure, HAProxy provides a solid foundation for ensuring high availability and efficient traffic management.&lt;/p&gt;

&lt;p&gt;With its open-source nature, advanced features, and proven track record in real-world applications, HAProxy continues to be a go-to solution for developers and system administrators looking to ensure the scalability and stability of their applications.&lt;/p&gt;

&lt;p&gt;Is HAProxy the right choice for your project? If you’re looking for a load balancer that is powerful, reliable, and easy to configure, it very well might be. Share your thoughts or experiences with HAProxy below!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/company/104881120/admin/dashboard/" rel="noopener noreferrer"&gt;Follow me&lt;/a&gt; for more on my page!&lt;/p&gt;

</description>
      <category>performance</category>
    </item>
    <item>
      <title>100 Days of Servers Distributions- Day 8: What is a Load Balancer?</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Wed, 09 Oct 2024 19:22:42 +0000</pubDate>
      <link>https://dev.to/pirvanm/100-days-of-servers-distributions-day-8-what-is-a-load-balancer-38m3</link>
      <guid>https://dev.to/pirvanm/100-days-of-servers-distributions-day-8-what-is-a-load-balancer-38m3</guid>
      <description>&lt;p&gt;What is a Load Balancer? A Comprehensive Overview&lt;/p&gt;

&lt;p&gt;In the modern era of cloud computing, large-scale applications, and distributed systems, ensuring reliable, fast, and efficient service delivery is paramount. One of the essential tools that help achieve this is a load balancer. But what exactly is a load balancer, and why is it so important in today's digital infrastructure? Let’s dive in.&lt;/p&gt;

&lt;p&gt;What is a Load Balancer?&lt;br&gt;
A load balancer is a system (hardware or software) that automatically distributes incoming network traffic across multiple servers or resources. Its primary goal is to ensure that no single server bears too much load, which could slow down performance, or worse, crash the system.&lt;/p&gt;

&lt;p&gt;In simpler terms, a load balancer acts as a “traffic cop” sitting in front of your servers. It routes client requests efficiently to ensure that the system remains highly available and can handle heavy traffic without hiccups. It also helps scale resources to accommodate fluctuating workloads, ensuring high availability and reliability of applications.&lt;/p&gt;

&lt;p&gt;Types of Load Balancers&lt;br&gt;
There are several types of load balancers, each tailored to specific needs:&lt;/p&gt;

&lt;p&gt;Layer 4 Load Balancers (Transport Layer):&lt;/p&gt;

&lt;p&gt;Operates at the transport layer (Layer 4 of the OSI model) and routes traffic based on IP addresses and port numbers.&lt;br&gt;
This type of load balancer is fast since it doesn’t inspect the actual content of the data but only deals with connection-level information (e.g., TCP/UDP).&lt;br&gt;
It distributes traffic evenly by looking at simple data such as source and destination IP addresses.&lt;br&gt;
Layer 7 Load Balancers (Application Layer):&lt;/p&gt;

&lt;p&gt;Operates at the application layer (Layer 7 of the OSI model) and is more advanced.&lt;br&gt;
Layer 7 load balancers make routing decisions based on the actual content of the application, such as HTTP headers, URLs, or cookies.&lt;br&gt;
For example, you can configure a Layer 7 load balancer to direct traffic requesting videos to one server, while traffic requesting static images goes to another.&lt;br&gt;
Hardware Load Balancers:&lt;/p&gt;

&lt;p&gt;These are physical devices dedicated to balancing loads between servers.&lt;br&gt;
They are often more expensive and are used in large data centers where performance needs to be optimized to the highest degree.&lt;br&gt;
Examples: F5 Networks, Citrix ADC.&lt;br&gt;
Software Load Balancers:&lt;/p&gt;

&lt;p&gt;These are software solutions that run on standard servers and can perform the same function as hardware load balancers, often at a lower cost.&lt;br&gt;
Examples include HAProxy, Nginx, and software-based solutions from cloud providers like AWS Elastic Load Balancer (ELB) or Google Cloud Load Balancing.&lt;br&gt;
Global Load Balancers:&lt;/p&gt;

&lt;p&gt;Distribute traffic across servers that may be located in different geographic regions.&lt;br&gt;
Used to improve latency and availability by routing users to the closest data center.&lt;br&gt;
How Does a Load Balancer Work?&lt;br&gt;
When a client (such as a web browser) sends a request to a web application, the load balancer is the first point of contact. Here’s a step-by-step breakdown:&lt;/p&gt;

&lt;p&gt;Client Request: The client sends a request (for example, to access a website) to the load balancer's public IP address.&lt;/p&gt;

&lt;p&gt;Traffic Distribution: The load balancer receives the request and determines which backend server (also known as a "node") is the best one to handle the request. This decision is made based on the load balancing algorithm being used.&lt;/p&gt;

&lt;p&gt;Server Response: Once the load balancer forwards the client’s request to a server, that server processes the request and returns the response back to the load balancer.&lt;/p&gt;

&lt;p&gt;Return to Client: The load balancer then sends the server’s response back to the client as if the load balancer itself was the original server.&lt;/p&gt;

&lt;p&gt;In this entire process, the load balancer ensures that no one server is overwhelmed with too many requests, maintaining optimal performance.&lt;/p&gt;

&lt;p&gt;Load Balancing Algorithms&lt;br&gt;
Different load balancers use various algorithms to determine how traffic is distributed. Some of the most common algorithms include:&lt;/p&gt;

&lt;p&gt;Round Robin:&lt;/p&gt;

&lt;p&gt;This is the simplest method where incoming requests are distributed sequentially to each server.&lt;br&gt;
Ideal for systems where all servers have similar capabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2uean29sblegqh1sf6k6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2uean29sblegqh1sf6k6.png" alt="Image description" width="800" height="2280"&gt;&lt;/a&gt;&lt;br&gt;
Least Connections:&lt;/p&gt;

&lt;p&gt;Traffic is routed to the server with the fewest active connections.&lt;br&gt;
This method is beneficial when the load varies for each request, ensuring that no server gets overloaded.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpv6ltcl1tiplkg31hwib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpv6ltcl1tiplkg31hwib.png" alt="Image description" width="800" height="2039"&gt;&lt;/a&gt;&lt;br&gt;
IP Hash:&lt;/p&gt;

&lt;p&gt;The client’s IP address is used to determine which server receives the request.&lt;br&gt;
This is useful for cases where you want the same client to be routed to the same server for session persistence.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzjje1vni0mlc0tzz0uk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzjje1vni0mlc0tzz0uk.png" alt="Image description" width="800" height="2300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Weighted Round Robin:&lt;/p&gt;

&lt;p&gt;Similar to Round Robin but assigns a weight to each server based on its capacity. Servers with higher weights will receive more requests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjcjrazenphd5nnnroad9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjcjrazenphd5nnnroad9.png" alt="Image description" width="800" height="1230"&gt;&lt;/a&gt;&lt;br&gt;
Random:&lt;/p&gt;

&lt;p&gt;Requests are randomly distributed to servers, which can work well for small systems with evenly matched servers.&lt;br&gt;
Benefits of a Load Balancer&lt;br&gt;
Improved Availability:&lt;/p&gt;

&lt;p&gt;By distributing traffic across multiple servers, a load balancer ensures that the failure of one server doesn't bring down the entire application. If one server fails, the load balancer reroutes traffic to the healthy servers, ensuring high availability.&lt;br&gt;
Scalability:&lt;/p&gt;

&lt;p&gt;Load balancers make it easier to add or remove servers to handle varying traffic loads. This ensures that applications can scale effectively as traffic demands increase.&lt;br&gt;
Optimized Performance:&lt;/p&gt;

&lt;p&gt;By intelligently distributing traffic, a load balancer helps prevent any one server from being overwhelmed, reducing response times and improving overall performance.&lt;br&gt;
Fault Tolerance:&lt;/p&gt;

&lt;p&gt;In case of server failure, the load balancer can quickly reroute traffic to other operational servers, providing fault tolerance to ensure smooth operation.&lt;br&gt;
Enhanced Security:&lt;/p&gt;

&lt;p&gt;Load balancers can add an extra layer of security by preventing direct access to backend servers, which reduces the risk of Distributed Denial of Service (DDoS) attacks and other security threats.&lt;br&gt;
Real-World Applications of Load Balancers&lt;br&gt;
Web Applications:&lt;/p&gt;

&lt;p&gt;Many web applications today are highly dynamic, serving millions of users globally. Load balancers help ensure these applications remain responsive and available by balancing the traffic across multiple servers.&lt;br&gt;
Content Delivery Networks (CDN):&lt;/p&gt;

&lt;p&gt;CDNs use global load balancing to direct users to the nearest server, optimizing the delivery of media and static content like images, videos, and scripts.&lt;br&gt;
Database Load Balancing:&lt;/p&gt;

&lt;p&gt;Load balancing can also be used for database clusters, ensuring that read and write requests are distributed among multiple database nodes for high performance and reliability.&lt;br&gt;
Cloud Computing:&lt;/p&gt;

&lt;p&gt;Cloud platforms like AWS, Google Cloud, and Microsoft Azure offer load balancing as a core service, helping businesses manage and scale applications in the cloud.&lt;br&gt;
Conclusion&lt;br&gt;
In today’s fast-paced digital world, ensuring that applications are always available and can handle large volumes of traffic is crucial. A load balancer plays a critical role in achieving this by distributing traffic across multiple servers, enhancing performance, and increasing fault tolerance. Whether in small-scale deployments or large, geographically distributed systems, load balancers are an indispensable component of modern IT infrastructure.&lt;/p&gt;

&lt;p&gt;If you like and wanna suport, make a &lt;a href="https://coursecasts.com/signup" rel="noopener noreferrer"&gt;account &lt;/a&gt;and navigate!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>100 Days of Servers Distributions- Day 7: Importance of Load Balancing</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Mon, 07 Oct 2024 18:23:41 +0000</pubDate>
      <link>https://dev.to/pirvanm/100-days-of-servers-distributions-day-7-importance-of-load-balancing-1pok</link>
      <guid>https://dev.to/pirvanm/100-days-of-servers-distributions-day-7-importance-of-load-balancing-1pok</guid>
      <description>&lt;p&gt;In today’s fast-paced digital world, we rely on websites, apps, and cloud services more than ever. Whether you're shopping online, streaming your favorite show, or working remotely, you expect everything to work smoothly, right? That’s where load balancing comes in. It’s one of the behind-the-scenes heroes that ensures you get a seamless experience when using digital services. Let’s break down what load balancing is, why it’s so important, and how it keeps things running without a hitch.&lt;/p&gt;

&lt;p&gt;What is Load Balancing, Anyway?&lt;br&gt;
Imagine you’re at a busy restaurant, and there’s one overwhelmed server trying to handle all the tables. That’s a recipe for long waits, missed orders, and unhappy customers. Now, picture that same restaurant with multiple servers sharing the workload equally. Suddenly, everything runs smoothly, orders come out faster, and the customers are happy.&lt;/p&gt;

&lt;p&gt;That’s essentially what load balancing does for websites and apps. Instead of overloading a single server with too many requests, a load balancer spreads the traffic across multiple servers, making sure none of them get overwhelmed. This way, your website stays fast, responsive, and available even when there’s a sudden surge in visitors or users.&lt;/p&gt;

&lt;p&gt;Why Load Balancing is a Big Deal&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Better Performance and Speed&lt;br&gt;
Nobody likes waiting for a website to load. Slow pages can frustrate users and make them leave. Load balancing ensures that no single server gets bogged down by too many requests, so everything works faster. Whether it’s someone streaming a video, downloading a file, or making a purchase, the load balancer keeps things moving efficiently by directing users to the server that can handle their request the quickest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less Downtime, More Uptime&lt;br&gt;
Downtime is every website owner's worst nightmare. Imagine your site crashes just when traffic spikes (like during a big sale or promotion). Load balancing helps prevent this by monitoring which servers are healthy. If one server goes down, the load balancer redirects traffic to the others that are still working. This keeps your site up and running, even if there’s a hiccup behind the scenes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability: Growing Pains Solved&lt;br&gt;
As your business grows, so does your traffic. Load balancing makes it easy to scale. You can add more servers as needed, and the load balancer will automatically distribute the increased traffic across them. It’s like adding extra lanes to a highway during rush hour—everything moves more smoothly when there’s more capacity to handle the demand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Built-in Backup Plan (aka Fault Tolerance)&lt;br&gt;
No one likes to think about their servers failing, but it happens. Load balancing adds a layer of protection by distributing traffic across multiple servers, so if one fails, there’s always another one to pick up the slack. In more complex setups, load balancers can even redirect traffic to servers in other regions if there’s a big issue, like a power outage or natural disaster in one area.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdjh0xu4s8qlrelg2ej0p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdjh0xu4s8qlrelg2ej0p.png" alt="Image description" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Using Resources Wisely&lt;br&gt;
Think of load balancing like a well-organized assembly line. It ensures every server is working at its best capacity without getting overwhelmed. If one server is less busy, it will take on more tasks; if another is at its limit, the load balancer stops sending traffic there until it can handle more. This efficient use of resources keeps everything running smoothly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bonus: Extra Security Features&lt;br&gt;
Some load balancers come with handy security features like protection against Distributed Denial of Service (DDoS) attacks (when bad actors flood a site with fake traffic to take it down) and SSL encryption (which keeps your data safe). It’s like having a digital bouncer that ensures only legitimate traffic gets through while keeping your servers secure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Different Types of Load Balancers&lt;br&gt;
Not all load balancers work the same way. There are a few different types, each suited to different needs:&lt;/p&gt;

&lt;p&gt;DNS Load Balancers: These route traffic based on where the user is located or how fast a server can respond. They’re great for distributing traffic across multiple data centers or cloud regions.&lt;br&gt;
Hardware Load Balancers: Physical devices that handle massive traffic loads, often used by big companies in data centers.&lt;br&gt;
Software Load Balancers: These run on servers and are commonly used in the cloud because they’re flexible and easy to scale.&lt;br&gt;
Layer 4 vs. Layer 7 Load Balancers:&lt;br&gt;
Layer 4 works with basic data like IP addresses and ports.&lt;br&gt;
Layer 7 goes deeper, making decisions based on the actual content of the request (like looking at specific URLs or cookies), allowing for smarter traffic distribution.&lt;/p&gt;

&lt;p&gt;Real-Life Examples of Load Balancing in Action&lt;br&gt;
E-commerce Sites: Imagine a major online retailer like Amazon during Black Friday. Without load balancing, their servers would buckle under the sheer volume of people trying to shop all at once. Load balancing spreads that traffic out, ensuring a smooth shopping experience.&lt;/p&gt;

&lt;p&gt;Streaming Services: If you’re watching a movie on Netflix, you probably don’t think about how many others are watching at the same time. Load balancers ensure millions of users can stream without interruption, even during peak hours.&lt;/p&gt;

&lt;p&gt;Cloud Platforms: Services like AWS and Google Cloud use load balancing to distribute workloads across their vast network of servers, ensuring that clients' apps and websites run smoothly, no matter how many users log in.&lt;/p&gt;

&lt;p&gt;Wrapping It Up&lt;br&gt;
Load balancing is the unsung hero of modern IT. It keeps websites and apps running smoothly, even during traffic surges, server failures, or rapid growth. By spreading out the workload, it ensures that no single server gets overwhelmed, making everything faster and more reliable for users.&lt;/p&gt;

&lt;p&gt;In a world where people expect websites to be fast, available 24/7, and able to handle a sudden rush of traffic, load balancing isn’t just a nice-to-have—it’s a must. Whether you’re running a small online store or a global enterprise, load balancing helps you stay competitive by keeping your services fast, secure, and always online.&lt;/p&gt;

&lt;p&gt;For more courses follow me &lt;a href="https://coursecasts.com/signup" rel="noopener noreferrer"&gt;course casts&lt;/a&gt;&lt;/p&gt;

</description>
      <category>performance</category>
      <category>linux</category>
    </item>
    <item>
      <title>100 Days of Servers Distributions- Day 6: Exploring DNS and IP Routing</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Fri, 04 Oct 2024 18:36:57 +0000</pubDate>
      <link>https://dev.to/pirvanm/100-days-of-servers-distributions-day-6-exploring-dns-and-ip-routing-5314</link>
      <guid>https://dev.to/pirvanm/100-days-of-servers-distributions-day-6-exploring-dns-and-ip-routing-5314</guid>
      <description>&lt;p&gt;Day 6: Exploring DNS and IP Routing – A Journey into the Heart of the Internet&lt;br&gt;
Welcome to Day 6 of our tech adventure! Today, we’re diving into two of the most crucial elements that keep the internet running smoothly: DNS (Domain Name System) and IP routing. While these might sound like technical buzzwords, they play a massive role in how we experience the internet every day—from sending emails to loading a web page in seconds. Let’s break them down into digestible, human-friendly bites.&lt;/p&gt;

&lt;p&gt;What is DNS? (And why should you care?)&lt;br&gt;
Imagine you’re in a huge city, and every building has a unique, hard-to-remember address (like 192.168.1.1—sound familiar?). That’s how computers communicate, using IP addresses that look like strings of random numbers. But we humans are better at remembering names than numbers, right? That’s where DNS (Domain Name System) steps in.&lt;/p&gt;

&lt;p&gt;DNS acts as the phonebook of the internet. When you type a website name like &lt;a href="http://www.example.com" rel="noopener noreferrer"&gt;www.example.com&lt;/a&gt; into your browser, DNS translates it into the corresponding IP address. It's like asking a friend for the address of that new restaurant downtown—your friend (the DNS server) tells you where to go!&lt;/p&gt;

&lt;p&gt;We'll use Docker to containerize it.&lt;/p&gt;

&lt;p&gt;Here's how we can achieve that:&lt;/p&gt;

&lt;p&gt;Steps:&lt;br&gt;
Create a simple web application (we’ll use Python with Flask as an example).&lt;br&gt;
Write a Dockerfile to package this application into a Docker container.&lt;br&gt;
Build and run the Docker container.&lt;br&gt;
Let’s break it down.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the Application
We’ll use Flask to serve your article as a web page. Flask is a lightweight web framework for Python.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;File structure:&lt;br&gt;
bash&lt;br&gt;
Copy code&lt;br&gt;
dockerized-article/&lt;br&gt;
│&lt;br&gt;
├── app/&lt;br&gt;
│   ├── templates/&lt;br&gt;
│   │   └── index.html&lt;br&gt;
│   ├── app.py&lt;br&gt;
├── Dockerfile&lt;br&gt;
├── requirements.txt&lt;br&gt;
Step 1.1: Create the Flask app (app.py)&lt;br&gt;
Inside the app/ directory, create the app.py file to serve the article.&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
Copy code&lt;br&gt;
from flask import Flask, render_template&lt;/p&gt;

&lt;p&gt;app = Flask(&lt;strong&gt;name&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;@app.route('/')&lt;br&gt;
def home():&lt;br&gt;
    return render_template('index.html')&lt;/p&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == '&lt;strong&gt;main&lt;/strong&gt;':&lt;br&gt;
    app.run(host='0.0.0.0', port=5000)&lt;br&gt;
Step 1.2: Create the HTML template (index.html)&lt;br&gt;
Inside the app/templates/ directory, create index.html to display the article content.&lt;/p&gt;

&lt;p&gt;html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Day 6: Exploring DNS and IP Routing&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Day 6: Exploring DNS and IP Routing&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;Welcome to Day 6 of our tech adventure! Today, we’re diving into two of the most crucial elements that keep the internet running smoothly: DNS (Domain Name System) and IP routing...&amp;lt;/p&amp;gt;
    &amp;lt;!-- You can copy and paste the rest of the article here --&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 1.3: Specify dependencies (requirements.txt)&lt;br&gt;
Create a requirements.txt file in the root of your project directory to specify the Python dependencies:&lt;/p&gt;

&lt;p&gt;makefile&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Flask==2.1.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Write a Dockerfile&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Next, we’ll create a Dockerfile to define how our application should be packaged into a Docker image.&lt;/p&gt;

&lt;p&gt;Create a Dockerfile in the root of your project directory:&lt;/p&gt;

&lt;p&gt;Dockerfile&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 1: Use an official Python runtime as a parent image
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM python:3.9-slim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 2: Set the working directory in the container
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;WORKDIR /app&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 3: Copy the current directory contents into the container at /app
&lt;/h1&gt;

&lt;p&gt;COPY . /app&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 4: Install any necessary dependencies
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;RUN pip install --no-cache-dir -r requirements.txt&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 5: Make port 5000 available to the world outside this container
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;EXPOSE 5000&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 6: Run the application
&lt;/h1&gt;

&lt;p&gt;CMD ["python", "app/app.py"]&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build and Run the Docker Container
Step 3.1: Build the Docker image
In the terminal, navigate to the project directory (dockerized-article/), then run the following command to build your Docker image:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;docker build -t dns-ip-routing-article .&lt;/code&gt;&lt;br&gt;
Step 3.2: Run the Docker container&lt;br&gt;
Once the image is built, you can run the container using:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -d -p 5000:5000 dns-ip-routing-article&lt;/code&gt;&lt;br&gt;
This command will:&lt;/p&gt;

&lt;p&gt;Run the container in the background (-d).&lt;br&gt;
Map port 5000 on your local machine to port 5000 in the container (-p 5000:5000).&lt;/p&gt;

&lt;p&gt;Step 3.3: Access the web page&lt;br&gt;
Once the container is up and running, open your browser and go to &lt;a href="http://localhost:5000" rel="noopener noreferrer"&gt;http://localhost:5000&lt;/a&gt;. You should see the article displayed on the webpage.&lt;/p&gt;

&lt;p&gt;Without DNS, we’d have to memorize numbers instead of domain names. Imagine having to remember IP addresses for every website you visit! No thanks!&lt;/p&gt;

&lt;p&gt;Here’s a real-world example:&lt;/p&gt;

&lt;p&gt;You type &lt;a href="http://www.example.com" rel="noopener noreferrer"&gt;www.example.com&lt;/a&gt; into your browser.&lt;br&gt;
Your browser asks the DNS server, “Hey, what’s the IP address for this domain?”&lt;br&gt;
DNS responds with something like, “Sure, it’s 93.184.216.34.”&lt;br&gt;
Now, your browser knows where to go to load the website!&lt;br&gt;
Why should you care? Every time you search for something or access a webpage, DNS is working behind the scenes, making your internet experience faster and easier. Understanding DNS also helps troubleshoot when websites seem unreachable. It could be a DNS issue!&lt;/p&gt;

&lt;p&gt;IP Routing: The Internet’s Roadmap&lt;br&gt;
Once DNS translates the domain into an IP address, the next step is getting your data to its destination. This is where IP routing comes into play. Imagine driving from your home to a new restaurant. You might use a GPS app to find the best route, right? IP routing works in a similar way—it figures out the best path for your data to travel across the internet.&lt;/p&gt;

&lt;p&gt;But the internet’s roads aren’t made of concrete—they’re made of networks. Routers act like traffic controllers, deciding where to send packets of data. Your data doesn’t travel in one giant piece; instead, it’s broken down into smaller packets, each of which takes the most efficient route possible to reach its destination.&lt;/p&gt;

&lt;p&gt;Here’s how IP routing works in simple steps:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymq9h0mfw39bbs7gq0wk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymq9h0mfw39bbs7gq0wk.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your computer sends a packet of data to the destination IP address (which DNS helped you find).&lt;br&gt;
The data passes through a series of routers, each one directing it closer to the destination.&lt;br&gt;
Finally, the packets arrive, and the website loads or your email is delivered.&lt;br&gt;
It sounds simple, but behind the scenes, routers are making split-second decisions based on traffic, distance, and other factors to ensure that your data gets where it needs to go. IP routing is what ensures that you can send a message from New York to Tokyo in the blink of an eye, with the data hopping between networks along the way.&lt;/p&gt;

&lt;p&gt;Bringing DNS and IP Routing Together&lt;br&gt;
Here’s how it all ties together: Every time you open a website, send an email, or stream a video, DNS and IP routing are working in tandem to make it happen.&lt;/p&gt;

&lt;p&gt;DNS first translates the user-friendly domain name into an IP address.&lt;br&gt;
IP routing then ensures that data travels across the most efficient networks to its destination.&lt;br&gt;
Think of DNS as the translator and IP routing as the delivery service. Without one, you wouldn’t be able to find what you’re looking for, and without the other, your data wouldn’t know where to go.&lt;/p&gt;

&lt;p&gt;Troubleshooting: When Things Go Wrong&lt;br&gt;
Understanding the basics of DNS and IP routing can be a huge help when the internet isn’t cooperating. Here are two common scenarios:&lt;/p&gt;

&lt;p&gt;Problem: You can’t access a website, but everything else works.&lt;/p&gt;

&lt;p&gt;Potential cause: DNS issue. If DNS can’t translate the domain name into an IP address, your browser won’t know where to go.&lt;br&gt;
Quick fix: Try clearing your DNS cache or switching to a public DNS service like Google’s 8.8.8.8.&lt;br&gt;
Problem: Everything is super slow or not loading properly.&lt;/p&gt;

&lt;p&gt;Potential cause: Routing issue. If there’s heavy traffic on the networks your data is traveling through, it can slow things down.&lt;br&gt;
Quick fix: Restarting your router might help, or you can try using a VPN to route your traffic through less congested networks.&lt;br&gt;
Why Understanding This Matters&lt;br&gt;
It’s easy to take the internet for granted. We expect websites to load instantly, emails to send in seconds, and videos to stream smoothly. But when something goes wrong, having a basic understanding of DNS and IP routing gives you the power to diagnose issues, fix problems, or simply appreciate the complexity of what’s happening behind the scenes.&lt;/p&gt;

&lt;p&gt;These two systems—DNS and IP routing—are like the air traffic controllers of the internet. They make sure your data gets where it needs to go quickly, efficiently, and safely. So, the next time you type a web address or send an email, give a nod to these unsung heroes that make your digital life seamless.&lt;/p&gt;

&lt;p&gt;You wanna support me ? Just make a &lt;a href="https://coursecasts.com/signup" rel="noopener noreferrer"&gt;account&lt;/a&gt; and navigate!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>100 Days of Servers Distributions- Day 5: Network Layers and Protocols – Understanding the Foundation of Network Communication</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Wed, 02 Oct 2024 16:44:13 +0000</pubDate>
      <link>https://dev.to/pirvanm/day-5-network-layers-and-protocols-understanding-the-foundation-of-network-communication-1f8a</link>
      <guid>https://dev.to/pirvanm/day-5-network-layers-and-protocols-understanding-the-foundation-of-network-communication-1f8a</guid>
      <description>&lt;p&gt;What Are Network Layers?&lt;br&gt;
In networking, network layers refer to the structured levels that organize how data travels from one point to another across a network. Each layer has a specific function and works in concert with other layers to ensure successful communication.&lt;/p&gt;

&lt;p&gt;The most common framework to understand network layers is the OSI Model (Open Systems Interconnection), which breaks networking into seven distinct layers. Each of these layers handles specific tasks related to network communication, starting from the physical transmission of data up to the application that uses the data.&lt;/p&gt;

&lt;p&gt;Here’s a quick overview of the 7 Layers of the OSI Model:&lt;/p&gt;

&lt;p&gt;Physical Layer: This is the lowest layer and is responsible for the transmission of raw bitstreams (binary data) over a physical medium like cables or wireless signals.&lt;/p&gt;

&lt;p&gt;Data Link Layer: It establishes and terminates connections between physically connected nodes. It also handles error detection and correction to ensure data integrity over the physical layer.&lt;/p&gt;

&lt;p&gt;Network Layer: This layer determines the best physical path for data to travel, which is crucial in routing. IP (Internet Protocol) is a well-known example of a network layer protocol.&lt;/p&gt;

&lt;p&gt;Transport Layer: It ensures reliable data transfer between systems, managing flow control, error recovery, and data segmentation. TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are key protocols here.&lt;/p&gt;

&lt;p&gt;Session Layer: This layer establishes, manages, and terminates communication sessions. It is responsible for maintaining sessions between devices for the duration of their connection.&lt;/p&gt;

&lt;p&gt;Presentation Layer: It acts as the translator for the network, ensuring that data is in a usable format for the application layer. It deals with data encryption, compression, and encoding.&lt;/p&gt;

&lt;p&gt;Application Layer: The top layer, which interacts directly with the end-user. This layer encompasses protocols used for specific applications such as HTTP for web browsing, SMTP for email, and FTP for file transfer.&lt;/p&gt;

&lt;p&gt;How Network Layers and Protocols Work Together&lt;br&gt;
When data is sent over a network, it doesn’t just jump from one device to another. It undergoes a series of transformations as it moves through each network layer, a process known as encapsulation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwgdp1w66y27203419axr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwgdp1w66y27203419axr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine sending an email:&lt;/p&gt;

&lt;p&gt;At the Application Layer, the email is created.&lt;br&gt;
The Presentation Layer converts the data into a format that the network can understand.&lt;br&gt;
The Transport Layer breaks the email into smaller pieces, called segments, and ensures it can be reassembled correctly.&lt;br&gt;
The Network Layer adds addressing information so the email can be routed to its destination.&lt;br&gt;
The Data Link Layer adds error-checking information and prepares the data for transmission.&lt;br&gt;
Finally, the Physical Layer converts the data into electrical, radio, or optical signals that are sent through the network.&lt;br&gt;
When the email reaches its destination, the layers on the receiving device reverse the process to reconstruct the email.&lt;/p&gt;

&lt;p&gt;Who we can dockerize ?&lt;/p&gt;

&lt;p&gt;Docker Compose (Optional)&lt;br&gt;
If you want to add more services (e.g., a database or caching layer), you could use Docker Compose. Here’s a basic docker-compose.yml file for running the app alone:&lt;/p&gt;

&lt;p&gt;docker-compose.yml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3'
services:
  web:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - .:/app
    environment:
      - NODE_ENV=development
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Building and Running the Dockerized App&lt;br&gt;
Step 1: Build the Docker Image&lt;br&gt;
To build the Docker image for the application, run the following command from the project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t network-layers-app .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command tells Docker to build an image with the name network-layers-app based on the Dockerfile.&lt;/p&gt;

&lt;p&gt;Step 2: Run the Docker Container&lt;br&gt;
Once the image is built, you can run the app in a Docker container using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 3000:3000 network-layers-app
This binds port 3000 on your host machine to port 3000 inside the container, allowing you to access the app in your browser by visiting http://localhost:3000.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more course click &lt;a href="https://coursecasts.com/signup" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>network</category>
    </item>
    <item>
      <title>100 Days of Servers Distributions- Days 4 and 100 Day 4 Introduction to Web Servers</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Mon, 30 Sep 2024 09:57:22 +0000</pubDate>
      <link>https://dev.to/pirvanm/100-days-of-servers-distributions-days-4-and-100-day-4-introduction-to-web-servers-1m44</link>
      <guid>https://dev.to/pirvanm/100-days-of-servers-distributions-days-4-and-100-day-4-introduction-to-web-servers-1m44</guid>
      <description>&lt;h1&gt;
  
  
  Day 4  Introduction to Web Servers
&lt;/h1&gt;

&lt;p&gt;In this journey of our article series, we will dive deeper into one of the key and essential components for the functioning of the internet: web servers. The KISS principle (Keep It Simple, Stupid) is a fundamental concept that should be frequently maintained to keep everything clean and straightforward. For this reason, we will strengthen beginner-level knowledge to understand web servers, which is essential for building and hosting websites or web applications.&lt;/p&gt;

&lt;p&gt;Personally, for one of my projects in a real-world scenario, I use Laravel for the backend and Flutter for the mobile app front end. Additionally, I use Vue.js for another project, and for a more ambitious web project, I’m using React.&lt;/p&gt;

&lt;p&gt;A web server is a system that should have the sole responsibility for storing, processing, and delivering web pages to users. We are now talking about both the software and hardware aspects that make websites accessible.&lt;/p&gt;

&lt;p&gt;this is nuxt config :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require("dotenv").config();
export default {
  env: {
    baseUrl: process.env.BASE_URL,
  },
  generate: {
    /* routes () {
        return axios.get('https://myapisite.com/')
            .then((res) =&amp;gt; {
                return res.data.map((user) =&amp;gt; {
                    return '/users/' + user.id
                })
            })
    }*/
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5k26oicea1i4goklqzk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5k26oicea1i4goklqzk.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
When we type a URL or even an IP address into a browser, we are making a request to a server, with the URL being the path to the server. The web server receives the request, processes it, and sends back the appropriate response, which could be an HTML page, an image, a video, or other resources.&lt;/p&gt;

&lt;p&gt;At its most basic level, a web server has two primary roles:&lt;br&gt;
Handle HTTP Requests: Respond to HTTP or HTTPS requests made by clients (web browsers).&lt;br&gt;
Serve Content: Deliver static or dynamic content like HTML pages, CSS, JavaScript, images, and multimedia files.&lt;/p&gt;

&lt;p&gt;Handle HTTP Requests: Respond to HTTP or HTTPS requests made by clients (web browsers).&lt;br&gt;
Serve Content: Deliver static or dynamic content like HTML pages, CSS, JavaScript, images, and multimedia files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhv7o8l7kg3ckbhninbw5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhv7o8l7kg3ckbhninbw5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How a Web Server Works
&lt;/h2&gt;

&lt;p&gt;Step by step, a server follows these stages:&lt;/p&gt;

&lt;p&gt;Client Request: A client (your browser) sends an HTTP request to the web server. For example, when you type &lt;a href="http://www.mysite.com" rel="noopener noreferrer"&gt;www.mysite.com&lt;/a&gt;, the browser sends a request to the server hosting the site.&lt;/p&gt;

&lt;p&gt;The Server Processes the Request: The web server receives the request and checks for the requested content. If the content exists, it is prepared for response (such as an HTML file, an image, etc.).&lt;/p&gt;

&lt;p&gt;The Web Server Sends the Response: The server sends the response back to the client. If the content is not found, the server returns or should return, as a best practice, an error message like the classic "404 Not Found."&lt;/p&gt;

&lt;p&gt;The Client Displays the Content: In the browser, the server's response is processed, and the pages or various resources are rendered or displayed.&lt;/p&gt;
&lt;h2&gt;
  
  
  Types of Web Servers
&lt;/h2&gt;

&lt;p&gt;Several web servers are available, each with its own strengths and use cases. Here are some of the most popular ones:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Apache HTTP Server&lt;/strong&gt;
Overview: Apache is one of the oldest and most widely used web servers. It's open-source and highly configurable, making it a top choice for many web hosting companies and developers.
Use Cases: Suitable for small to large-scale websites, offering extensive customization and control over server configurations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nginx&lt;/strong&gt;
Overview: Nginx (pronounced "Engine-X") is known for its performance, scalability, and efficient resource usage. It's designed to handle high loads and is often used as a reverse proxy or load balancer.
Use Cases: Ideal for high-traffic websites, API management, and microservices architecture.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft IIS (Internet Information Services)&lt;/strong&gt;
Overview: IIS is Microsoft's web server, tightly integrated with Windows servers. It supports multiple languages, including ASP.NET, PHP, and others.
Use Cases: Preferred for Windows-based environments and enterprise solutions that rely on Microsoft technologies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LiteSpeed&lt;/strong&gt;
Overview: LiteSpeed is a lightweight, high-performance web server that offers compatibility with Apache's configuration files. It’s designed to boost performance while keeping resource consumption low.
Use Cases: Suitable for high-performance websites where speed and low server load are critical.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Node.js&lt;/strong&gt;
Overview: Node.js is not a traditional web server but a JavaScript runtime that allows you to create web servers using JavaScript. It is highly efficient for real-time applications and services.
Use Cases: Perfect for dynamic, real-time applications like chat apps, live video streaming, and APIs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For a express server as locally : &lt;br&gt;
in my package.json: I have :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "node-hello-world",
  "private": true,
  "version": "0.0.1",
  "description": "Node.js Hello world app on docker",
  "author": "hypriot.com",
  "dependencies": {
    "express": "4.12.0"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in same folder : &lt;br&gt;
 I have index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var express = require('express');
var os = require("os");

var app = express();
var hostname = os.hostname();



app.get('/', function (req, res) {
  const ip = req.headers['x-forwarded-for'];

  res.send('&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;Node.js container ' + hostname + ' ' + 'Client IP: ' + ip + '&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;');
});

app.listen(80);
console.log('Running on http://localhost');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After I write those files, I need just run npm install  and node index.js!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web Servers&lt;/strong&gt; can serve both static and dynamic content, depending on the type of website and its configuration, which can vary:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Server&lt;/strong&gt; simply delivers stored files to the client without processing them. Static websites are faster but limited in interactivity. The files are pre-built in HTML, CSS, and JavaScript, and they do not change when the user accesses them.&lt;/p&gt;

&lt;p&gt;Example: A portfolio website or a company's homepage.&lt;br&gt;
Dynamic Servers handle more complex requests by generating content progressively. These typically involve a database and a server-side programming language such as PHP, Python, or Node.js.&lt;/p&gt;

&lt;p&gt;Example: An online store provides content that is updated based on user interaction.&lt;/p&gt;

&lt;p&gt;For efficient operation, a web server contains several components. The primary elements include:&lt;/p&gt;

&lt;p&gt;HTTP Software: It handles HTTP requests and responses. This software is responsible for delivering content and communicating with clients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operating System&lt;/strong&gt;: The web server runs on an operating system like Linux, Windows, or macOS, which allows for the management of server resources, files, and processes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database (Optional)&lt;/strong&gt;: Many websites with dynamic content require a database, such as MySQL or PostgreSQL, to store or retrieve data in real-time. For example, when we log in, the information is fetched from the database.&lt;/p&gt;

&lt;p&gt;Server-Side Language (Optional): Languages such as PHP, Python, or JavaScript (Node.js) control dynamic content and interaction with the database.&lt;/p&gt;

&lt;p&gt;There are different ways you can host your website:&lt;br&gt;
Local Hosting: Running a web server on your own computer for development purposes. You can use tools like XAMPP (for Apache) or a Node.js server for testing your applications.&lt;br&gt;
Shared Hosting: A cost-effective solution where multiple websites share the same server resources. It’s commonly offered by web hosting providers.&lt;br&gt;
&lt;strong&gt;VPS Hosting&lt;/strong&gt;: Virtual Private Server (VPS) hosting gives you more control and resources than shared hosting by providing a virtual server dedicated to your needs.&lt;br&gt;
&lt;strong&gt;Cloud Hosting&lt;/strong&gt;: Services like Amazon Web Services (AWS), Google Cloud, or Microsoft Azure offer scalable, pay-as-you-go web hosting options for large-scale applications.&lt;br&gt;
Sunt diferite modalitate a gazdui un website : &lt;br&gt;
&lt;strong&gt;Local Hosting&lt;/strong&gt; : Running a web server on your own computer for development purposes. You can use tools like XAMPP (for Apache) or a Node.js server for testing your applications.&lt;br&gt;
Shared Hosting: A cost-effective solution where multiple websites share the same server resources. It’s commonly offered by web hosting providers.&lt;/p&gt;

&lt;p&gt;VPS Hosting: Virtual Private Server (VPS) hosting gives you more control and resources than shared hosting by providing a virtual server dedicated to your needs.&lt;/p&gt;

&lt;p&gt;Personally, when it comes to a portfolio, I use a shared hosting solution. A VPS is ideal for solutions that require a custom server. From what I know, it's quite difficult to set up a shared server for Node.js, so a VPS is the best solution.&lt;/p&gt;

&lt;p&gt;On DigitalOcean, I have a web server for the API built with Laravel, and for rendering with Nuxt.js, which communicates with interactions from Vue.js, I use a Node.js server that uses half the resources of the API.&lt;/p&gt;

&lt;p&gt;For more follow me on &lt;a href="https://coursecasts.com/signup" rel="noopener noreferrer"&gt;more courses&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>nuxt</category>
      <category>express</category>
    </item>
    <item>
      <title>100 Days of Servers Distributions- Days 3 and 100</title>
      <dc:creator>pirvanm</dc:creator>
      <pubDate>Fri, 27 Sep 2024 17:56:35 +0000</pubDate>
      <link>https://dev.to/pirvanm/100-days-of-servers-distributions-days-3-and-100-58hi</link>
      <guid>https://dev.to/pirvanm/100-days-of-servers-distributions-days-3-and-100-58hi</guid>
      <description>&lt;h2&gt;
  
  
  Servers, Virtualization, and Containers
&lt;/h2&gt;

&lt;p&gt;Nowadays, it could be said that the path between virtualization and servers, through containers, is an essential part. These three elements form a fundamental component of modern infrastructure, designed to provide a scalable and manageable solution for deploying applications, whether they are web or software. In this article, we will delve deeper into the world of servers, virtualization, and containers, exploring and discussing how they work. We will highlight their benefits and roles in providing a better-structured IT infrastructure compared to classic servers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuookri6vp68c3vu9xtjf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuookri6vp68c3vu9xtjf.png" alt="Image description" width="800" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Servers: The Heart of IT Infrastructure&lt;br&gt;
It is certainly true that the core, or heart, of any IT infrastructure is represented by servers. A server is a powerful computer dedicated to processing requests and delivering information to other computers (clients) via a network, whether it be the internet or an intranet. Servers come in various types, each serving a specific role in the IT world.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File Servers&lt;/strong&gt;: Manage and store data accessed by users or the system.&lt;br&gt;
Web Servers: Deliver content such as HTML pages (as the final product) of a web application, or media files to users over the internet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Servers&lt;/strong&gt;: Store and manage collections of data, allowing access and queries through applications. Personally, I see them as structured data tables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application Servers&lt;/strong&gt;: Host and communicate with applications, sending data and various services to end users. &lt;/p&gt;

&lt;p&gt;A modern aspect is that today we have both frontend web servers and backend servers, with intermediaries such as Next.js or Nuxt.js for Vue.js fans.&lt;/p&gt;

&lt;p&gt;Traditional servers were essentially physical machines hosted in data centers. However, with their evolution, the concept of a server has extended beyond the first level of the development environment, leading to virtualization.&lt;/p&gt;

&lt;p&gt;Personally, at my job, I have worked with AWS, and for personal cloud use, I have been using DigitalOcean for several years.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4s2g6t3o177xzfwip7dd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4s2g6t3o177xzfwip7dd.png" alt="Image description" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Virtualization is the process of creating virtual versions of a physical server, allowing multiple operations and applications to run on the same hardware. By using a hypervisor (software that processes and enables the virtualization environment), you can divide a single physical server into multiple virtual machines (VMs), each running its own independent operating system.&lt;/p&gt;

&lt;p&gt;Looking back on my professional experience, I can say that I first used virtual machines in 2016 through VirtualBox on a Windows operating system. Around 2018, I discovered Docker, which I used for a few months, but by 2020, I unconsciously returned to VirtualBox. In 2021, however, I came back to the Docker world and have stayed in it ever since.&lt;br&gt;
Since 2022, I’ve been using WSL (Windows Subsystem for Linux), virtualizing Ubuntu through Windows in my professional work, but personally, I prefer dual-boot and running Docker directly from Ubuntu, as WSL causes various issues.&lt;/p&gt;

&lt;p&gt;Benefits of virtualization:&lt;/p&gt;

&lt;p&gt;Cost efficiency: By consolidating multiple VMs on a single physical server, organizations reduce the need for more hardware units, saving money on both hardware and software.&lt;br&gt;
Resource optimization: Virtualization offers better management of resources like CPU, memory, and storage. I can also add that Docker Desktop is quite helpful, even though Docker can be used without Docker Desktop on Linux. However, Docker Desktop is a good, free option.&lt;br&gt;
Scalability: Virtual machines can be created, modified, and deleted quickly based on the company's needs.&lt;br&gt;
Isolation: Each VM operates independently, ensuring that issues in one VM do not affect the others, unlike on a physical server.&lt;br&gt;
Common hypervisors include VMware ESXi, Microsoft Hyper-V, and KVM (Kernel-based Virtual Machine). Virtualization has transformed the way IT infrastructure is managed, making it easier to dynamically allocate resources and run multiple environments on a single piece of hardware.&lt;/p&gt;

&lt;p&gt;If you are not a fan of virtual machines like VirtualBox, fortunately, Hyper-V comes preinstalled with Docker Desktop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjcifkytqclz2gvy04br.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjcifkytqclz2gvy04br.png" alt="Image description" width="800" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Corectura în limba română:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Containerele: Nivelul următor al virtualizării&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Un punct important în revoluționarea virtualizării unei infrastructuri îl reprezintă containerele, fiind un pas înainte către viitor. Containerele oferă o modalitate curată și portabilă de a împacheta și reutiliza aplicațiile împreună cu toate dependențele lor, permițându-le să funcționeze constant în diverse medii, de la dezvoltare până la producție.&lt;/p&gt;

&lt;p&gt;Spre deosebire de mașinile virtuale (VM-uri), care necesită un sistem de operare complet pentru fiecare instanță, containerele împart același kernel al sistemului de operare, ceea ce le face mai eficiente și mai rapide pentru a fi repornite de la zero. Această abordare duce la o mai bună utilizare a resurselor și la o scalabilitate sporită, în special pentru arhitecturile de tip microserviciu.&lt;/p&gt;

&lt;p&gt;Diferențele cheie între containere și mașinile virtuale:&lt;/p&gt;

&lt;p&gt;Mașinile virtuale: Fiecare VM rulează un sistem de operare complet, ceea ce duce la un consum mai mare de resurse, dar oferă o izolare mai mare între medii.&lt;br&gt;
Containerele: Împart sistemul de operare al gazdei, ceea ce le face mai rapide, mai economice din punctul de vedere al resurselor și mai portabile, dar cu o izolare ușor mai redusă.&lt;br&gt;
Traducerea în engleză:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Containers: The Next Level of Virtualization&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An important point in the revolution of infrastructure virtualization is containers, as they are a step forward into the future. Containers provide a clean, portable way to package and reuse applications with all their dependencies, allowing them to run consistently across different environments, from development to production.&lt;/p&gt;

&lt;p&gt;Unlike virtual machines (VMs), which require a full operating system for each instance, containers share the same OS kernel, making them more efficient and faster to restart from scratch. This approach leads to improved resource efficiency and scalability, especially in microservices architectures.&lt;/p&gt;

&lt;p&gt;Key Differences Between Containers and Virtual Machines:&lt;/p&gt;

&lt;p&gt;Virtual Machines: Each VM runs a full operating system, resulting in more overhead but providing greater isolation between environments.&lt;br&gt;
Containers: Share the host OS, making them faster, more resource-efficient, and more portable, but with slightly less isolation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzmmvhkddxh49bk9ct125.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzmmvhkddxh49bk9ct125.png" alt="Image description" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Popular Containerization Platforms:&lt;br&gt;
Docker: One of the most popular platforms for developing, shipping, and running applications in containers. It simplifies the deployment process by creating consistent environments across different stages of the software lifecycle.&lt;br&gt;
Kubernetes: A container orchestration platform that automates the deployment, scaling, and management of containerized applications. Kubernetes is often used to manage large-scale, distributed applications composed of multiple containers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm21nqu09ekjfk193t1r9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm21nqu09ekjfk193t1r9.png" alt="Image description" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more awesome see more: &lt;a href="https://coursecasts.com/signup" rel="noopener noreferrer"&gt;courses &lt;/a&gt;&lt;/p&gt;

</description>
      <category>virtualmachine</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
