Skip to content

PramithaMJ/java-masterclass

Repository files navigation

Java Engineering Masterclass 🚀

An interactive, production-grade React application for mastering advanced Java/JVM concepts through visual simulations and deep-dive theory.

React TypeScript Vite License

🎯 Features

Interactive Simulators

Module Description Visualization
Garbage Collection Eden, Survivor, Old Gen memory pools Object allocation & GC cycles
Concurrency Monitor locks, Entry/Wait sets Thread state transitions
JIT Compilation Tiered compilation (Interpreted → C1 → C2) Profiling & optimization
Java Memory Model CPU caches, Main Memory, Volatile Cache coherence & visibility
Static vs Instance Metaspace vs Heap memory layout Static field sharing

Educational Theory

Each module includes comprehensive "Engineer's Guide" content covering:

  • Under-the-hood JVM internals
  • Best practices and anti-patterns
  • Thread safety considerations
  • Performance implications

🏗️ Architecture

Built following SOLID principles with a modular, scalable architecture:

src/
├── components/           # Reusable UI components
│   ├── Layout/          # Header, Layout wrapper
│   ├── UI/              # Button, Console, MemoryBlock
│   └── Hub/             # Module selection grid
├── features/            # Feature modules (one per topic)
│   ├── gc/              # Garbage Collection
│   ├── threads/         # Concurrency
│   ├── jit/             # JIT Compilation
│   ├── jmm/             # Java Memory Model
│   └── static/          # Static vs Instance
├── hooks/               # Custom React hooks (simulation logic)
├── contexts/            # React Context providers
├── types/               # TypeScript type definitions
└── App.tsx              # Root application component

🚀 Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/pramithamj/java-masterclass.git
cd java-masterclass

# Install dependencies
npm install

# Start development server
npm run dev

Open http://localhost:5173 in your browser.

Build for Production

npm run build
npm run preview    # Preview production build locally

🌐 Deployment

GitHub Pages

The app is configured for GitHub Pages deployment:

  1. Build the project: npm run build
  2. Push to your repository
  3. Enable GitHub Pages in repository settings (deploy from gh-pages branch or /docs folder)

Note: The base path in vite.config.ts must match your repository name.

📚 Module Details

Garbage Collection Simulator

Visualize the Generational Hypothesis in action:

  • Eden Space: Where new objects are allocated
  • Survivor Space: Objects that survive Minor GC
  • Old Generation: Long-lived objects (tenured)
  • Trigger Minor GC and Full GC to see object lifecycle

Concurrency Simulator

Understand Java's Monitor Lock mechanism:

  • See threads competing for synchronized blocks
  • Watch Entry Set (blocked) and Running states
  • Visualize lock acquisition and release

JIT Compilation Simulator

Watch code get "hot" and tiered compilation kick in:

  • Interpreted: Initial slow execution
  • C1 Compiler: Quick compilation, basic optimizations
  • C2 Compiler: Aggressive optimization (inlining, escape analysis)

Java Memory Model Lab

Understand visibility and happens-before:

  • CPU L1 caches vs Main Memory
  • Volatile writes flush to memory
  • Non-volatile reads may see stale data

Static vs Instance Lab

Visualize where static and instance members live:

  • Metaspace: Class-level static fields (shared)
  • Heap: Per-instance fields (unique per object)
  • See how static changes affect ALL instances

🛠️ Technology Stack

  • React 19 - UI framework with hooks
  • TypeScript 5.9 - Type safety
  • Vite 7 - Fast build tool with HMR
  • CSS Modules - Scoped styling
  • ESLint - Code quality

📝 Design Principles

  1. Single Responsibility (SRP): Each component/hook has one clear purpose
  2. Open/Closed (OCP): Easy to add new modules without modifying core
  3. Dependency Inversion (DIP): Contexts provide injectable dependencies
  4. Interface Segregation (ISP): Small, focused type interfaces

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Inspired by the need for better JVM education tools
  • Built with modern React best practices
  • Designed for developers learning advanced Java concepts