0–5 min
Real Hook
5–20 min
Core Concept
20–40 min
Live Coding
40–55 min
You Code It
55–60 min
Cheat Sheet
🔥 Real-World Hook (0–5 min)

You have a beautiful frontend. You have a powerful Spring Boot API. They're not talking to each other yet.

This is what separates a collection of code from a working product. Today you wire them together: React/HTML frontend → Fetch API → Spring Boot controller → JPA → MySQL. Real full-stack.

🔗 The Full-Stack Data Flow (5–20 min)

💡 Flow Diagram

👤 User fills form → 🖥 JavaScript fetch() → 🚀 Spring Boot Controller → 📧 Service → 🚬 JPA Repository → 📊 MySQL Database

Response flows back the same way: Database row → Java object → JSON → Browser renders it.

💻 Live Coding — Fix CORS + Wire Frontend (20–40 min)

// CORS config — allow frontend to call your API
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
            .allowedOrigins("http://localhost:3000", "http://localhost:5500")
            .allowedMethods("GET", "POST", "PUT", "DELETE")
            .allowedHeaders("*");
    }
}
// Full-stack: frontend script calling real API
const API_BASE = 'http://localhost:8080/api';

async function loadDashboard() {
    const [students, courses] = await Promise.all([
        fetch(`${API_BASE}/students`).then(r => r.json()),
        fetch(`${API_BASE}/courses`).then(r => r.json())
    ]);

    document.getElementById('student-count').textContent = students.length;
    document.getElementById('course-count').textContent  = courses.length;

    document.getElementById('student-list').innerHTML =
        students.slice(0, 5).map(s => `
          <tr>
            <td>${s.name}</td>
            <td>${s.dept}</td>
            <td><span class="badge">${s.gpa}</span></td>
          </tr>
        `).join('');
}

loadDashboard();
🎯 You Code It (40–55 min)
  1. Add the CorsConfig class to your Spring Boot project
  2. Restart the backend — confirm it runs on port 8080
  3. Create dashboard.html with 3 sections: stats cards, student table, add-student form
  4. Load stats (total students, average GPA) by calling your API
  5. The form should POST and instantly refresh the table without page reload
  6. Show: Dashboard loading real data from your MySQL via Spring Boot

📄 Day 11 Cheat Sheet — Full-Stack

CORS Fix

@CrossOrigin("*")Quick fix on controller
WebMvcConfigurerGlobal CORS config
allowedOrigins("url")Allowed frontend
allowedMethods("GET","POST"...)HTTP verbs allowed

Parallel Fetch

Promise.all([...])Run all in parallel
await Promise.all([f1,f2])Wait for all
const [a,b] = await...Destructure results
Promise.allSettledGet all even if some fail

Debugging Tools

F12 -> Network tabSee API calls
F12 -> ConsoleJS errors
PostmanTest API directly
spring.jpa.show-sql=trueSee SQL queries
console.log(data)Debug JS variables

Layered Architecture

ControllerHTTP in/out, no logic
ServiceBusiness rules here
RepositoryDatabase access only
EntityDatabase table model
DTOWhat client sees