|
1 | | -# React + TypeScript + Vite |
| 1 | +# Java Engineering Masterclass 🚀 |
2 | 2 |
|
3 | | -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. |
| 3 | +An interactive, production-grade React application for mastering advanced Java/JVM concepts through visual simulations and deep-dive theory. |
4 | 4 |
|
5 | | -Currently, two official plugins are available: |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
6 | 9 |
|
7 | | -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh |
8 | | -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
| 10 | +## 🎯 Features |
9 | 11 |
|
10 | | -## React Compiler |
| 12 | +### Interactive Simulators |
11 | 13 |
|
12 | | -The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). |
| 14 | +| Module | Description | Visualization | |
| 15 | +|--------|-------------|---------------| |
| 16 | +| **Garbage Collection** | Eden, Survivor, Old Gen memory pools | Object allocation & GC cycles | |
| 17 | +| **Concurrency** | Monitor locks, Entry/Wait sets | Thread state transitions | |
| 18 | +| **JIT Compilation** | Tiered compilation (Interpreted → C1 → C2) | Profiling & optimization | |
| 19 | +| **Java Memory Model** | CPU caches, Main Memory, Volatile | Cache coherence & visibility | |
| 20 | +| **Static vs Instance** | Metaspace vs Heap memory layout | Static field sharing | |
13 | 21 |
|
14 | | -## Expanding the ESLint configuration |
| 22 | +### Educational Theory |
15 | 23 |
|
16 | | -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: |
| 24 | +Each module includes comprehensive "Engineer's Guide" content covering: |
| 25 | +- Under-the-hood JVM internals |
| 26 | +- Best practices and anti-patterns |
| 27 | +- Thread safety considerations |
| 28 | +- Performance implications |
17 | 29 |
|
18 | | -```js |
19 | | -export default defineConfig([ |
20 | | - globalIgnores(['dist']), |
21 | | - { |
22 | | - files: ['**/*.{ts,tsx}'], |
23 | | - extends: [ |
24 | | - // Other configs... |
| 30 | +## 🏗️ Architecture |
25 | 31 |
|
26 | | - // Remove tseslint.configs.recommended and replace with this |
27 | | - tseslint.configs.recommendedTypeChecked, |
28 | | - // Alternatively, use this for stricter rules |
29 | | - tseslint.configs.strictTypeChecked, |
30 | | - // Optionally, add this for stylistic rules |
31 | | - tseslint.configs.stylisticTypeChecked, |
| 32 | +Built following **SOLID principles** with a modular, scalable architecture: |
32 | 33 |
|
33 | | - // Other configs... |
34 | | - ], |
35 | | - languageOptions: { |
36 | | - parserOptions: { |
37 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
38 | | - tsconfigRootDir: import.meta.dirname, |
39 | | - }, |
40 | | - // other options... |
41 | | - }, |
42 | | - }, |
43 | | -]) |
44 | 34 | ``` |
| 35 | +src/ |
| 36 | +├── components/ # Reusable UI components |
| 37 | +│ ├── Layout/ # Header, Layout wrapper |
| 38 | +│ ├── UI/ # Button, Console, MemoryBlock |
| 39 | +│ └── Hub/ # Module selection grid |
| 40 | +├── features/ # Feature modules (one per topic) |
| 41 | +│ ├── gc/ # Garbage Collection |
| 42 | +│ ├── threads/ # Concurrency |
| 43 | +│ ├── jit/ # JIT Compilation |
| 44 | +│ ├── jmm/ # Java Memory Model |
| 45 | +│ └── static/ # Static vs Instance |
| 46 | +├── hooks/ # Custom React hooks (simulation logic) |
| 47 | +├── contexts/ # React Context providers |
| 48 | +├── types/ # TypeScript type definitions |
| 49 | +└── App.tsx # Root application component |
| 50 | +``` |
| 51 | + |
| 52 | +## 🚀 Getting Started |
| 53 | + |
| 54 | +### Prerequisites |
| 55 | + |
| 56 | +- Node.js 18+ |
| 57 | +- npm or yarn |
| 58 | + |
| 59 | +### Installation |
| 60 | + |
| 61 | +```bash |
| 62 | +# Clone the repository |
| 63 | +git clone https://github.com/pramithamj/java-masterclass.git |
| 64 | +cd java-masterclass |
| 65 | + |
| 66 | +# Install dependencies |
| 67 | +npm install |
| 68 | + |
| 69 | +# Start development server |
| 70 | +npm run dev |
| 71 | +``` |
| 72 | + |
| 73 | +Open [http://localhost:5173](http://localhost:5173) in your browser. |
45 | 74 |
|
46 | | -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: |
47 | | - |
48 | | -```js |
49 | | -// eslint.config.js |
50 | | -import reactX from 'eslint-plugin-react-x' |
51 | | -import reactDom from 'eslint-plugin-react-dom' |
52 | | - |
53 | | -export default defineConfig([ |
54 | | - globalIgnores(['dist']), |
55 | | - { |
56 | | - files: ['**/*.{ts,tsx}'], |
57 | | - extends: [ |
58 | | - // Other configs... |
59 | | - // Enable lint rules for React |
60 | | - reactX.configs['recommended-typescript'], |
61 | | - // Enable lint rules for React DOM |
62 | | - reactDom.configs.recommended, |
63 | | - ], |
64 | | - languageOptions: { |
65 | | - parserOptions: { |
66 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
67 | | - tsconfigRootDir: import.meta.dirname, |
68 | | - }, |
69 | | - // other options... |
70 | | - }, |
71 | | - }, |
72 | | -]) |
| 75 | +### Build for Production |
| 76 | + |
| 77 | +```bash |
| 78 | +npm run build |
| 79 | +npm run preview # Preview production build locally |
73 | 80 | ``` |
| 81 | + |
| 82 | +## 🌐 Deployment |
| 83 | + |
| 84 | +### GitHub Pages |
| 85 | + |
| 86 | +The app is configured for GitHub Pages deployment: |
| 87 | + |
| 88 | +1. Build the project: `npm run build` |
| 89 | +2. Push to your repository |
| 90 | +3. Enable GitHub Pages in repository settings (deploy from `gh-pages` branch or `/docs` folder) |
| 91 | + |
| 92 | +> **Note**: The `base` path in `vite.config.ts` must match your repository name. |
| 93 | +
|
| 94 | +## 📚 Module Details |
| 95 | + |
| 96 | +### Garbage Collection Simulator |
| 97 | + |
| 98 | +Visualize the **Generational Hypothesis** in action: |
| 99 | +- **Eden Space**: Where new objects are allocated |
| 100 | +- **Survivor Space**: Objects that survive Minor GC |
| 101 | +- **Old Generation**: Long-lived objects (tenured) |
| 102 | +- Trigger Minor GC and Full GC to see object lifecycle |
| 103 | + |
| 104 | +### Concurrency Simulator |
| 105 | + |
| 106 | +Understand Java's **Monitor Lock** mechanism: |
| 107 | +- See threads competing for synchronized blocks |
| 108 | +- Watch Entry Set (blocked) and Running states |
| 109 | +- Visualize lock acquisition and release |
| 110 | + |
| 111 | +### JIT Compilation Simulator |
| 112 | + |
| 113 | +Watch code get "hot" and tiered compilation kick in: |
| 114 | +- **Interpreted**: Initial slow execution |
| 115 | +- **C1 Compiler**: Quick compilation, basic optimizations |
| 116 | +- **C2 Compiler**: Aggressive optimization (inlining, escape analysis) |
| 117 | + |
| 118 | +### Java Memory Model Lab |
| 119 | + |
| 120 | +Understand **visibility** and **happens-before**: |
| 121 | +- CPU L1 caches vs Main Memory |
| 122 | +- Volatile writes flush to memory |
| 123 | +- Non-volatile reads may see stale data |
| 124 | + |
| 125 | +### Static vs Instance Lab |
| 126 | + |
| 127 | +Visualize where static and instance members live: |
| 128 | +- **Metaspace**: Class-level static fields (shared) |
| 129 | +- **Heap**: Per-instance fields (unique per object) |
| 130 | +- See how static changes affect ALL instances |
| 131 | + |
| 132 | +## 🛠️ Technology Stack |
| 133 | + |
| 134 | +- **React 19** - UI framework with hooks |
| 135 | +- **TypeScript 5.9** - Type safety |
| 136 | +- **Vite 7** - Fast build tool with HMR |
| 137 | +- **CSS Modules** - Scoped styling |
| 138 | +- **ESLint** - Code quality |
| 139 | + |
| 140 | +## 📝 Design Principles |
| 141 | + |
| 142 | +1. **Single Responsibility (SRP)**: Each component/hook has one clear purpose |
| 143 | +2. **Open/Closed (OCP)**: Easy to add new modules without modifying core |
| 144 | +3. **Dependency Inversion (DIP)**: Contexts provide injectable dependencies |
| 145 | +4. **Interface Segregation (ISP)**: Small, focused type interfaces |
| 146 | + |
| 147 | +## 🤝 Contributing |
| 148 | + |
| 149 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 150 | + |
| 151 | +1. Fork the repository |
| 152 | +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) |
| 153 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) |
| 154 | +4. Push to the branch (`git push origin feature/AmazingFeature`) |
| 155 | +5. Open a Pull Request |
| 156 | + |
| 157 | +## 📄 License |
| 158 | + |
| 159 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 160 | + |
| 161 | +## 🙏 Acknowledgments |
| 162 | + |
| 163 | +- Inspired by the need for better JVM education tools |
| 164 | +- Built with modern React best practices |
| 165 | +- Designed for developers learning advanced Java concepts |
| 166 | + |
| 167 | +--- |
0 commit comments