A lightweight, educational JavaScript framework built from scratch to demonstrate how modern frameworks work internally. Features Virtual DOM, component-based architecture, and built-in state management - all implemented without any dependencies.
Note: This is a personal learning project created to understand the internals of frameworks like React, Redux, and React Router.
- π¨ JSX-like Syntax - Write intuitive, declarative components with familiar JSX-like syntax
- β‘ Virtual DOM - Efficient rendering and updating with a custom Virtual DOM implementation
- π§© Component-Based - Build modular, reusable UI components with isolated logic
- ποΈ State Management - Redux-like global state management built right in
- π£οΈ Client-Side Routing - Dynamic URL routing with automatic view updates
- π¦ Zero Dependencies - Lightweight and self-contained
- π οΈ CLI Tool - Quick project scaffolding with the
miniCLI
git clone <your-repo-url>
cd mini-framework
npm startThen visit http://localhost:3000 to see the todo app in action.
const Counter = () => {
const component = `
<div className="counter-app">
<h1>Counter: <span id="counter-value">{counterValue}</span></h1>
<button onClick=incrementCounter>Increment</button>
</div>
`;
const context = {
Counter: () => component,
counterValue: 0,
incrementCounter: () => {
store.dispatch({ type: "INCREMENT" });
}
};
return context;
};const initialState = { counterValue: 0 };
const reducer = (state, action) => {
switch(action.type) {
case "INCREMENT":
return { counterValue: state.counterValue + 1 };
default:
return state;
}
};
const store = new Store({ reducer, state: initialState });const routes = [
{ path: '/', component: Home },
{ path: '/counter', component: Counter },
{ path: '/about', component: About }
];
const router = new Router(routes);This project demonstrates:
- Virtual DOM Implementation - How to build a Virtual DOM from scratch
- JSX-like Parsing - Compiling template strings to Virtual DOM nodes
- State Management - Building a Redux-like store with reducers and actions
- Event System - Handling DOM events through the Virtual DOM
- Routing - Client-side routing without external libraries
- Diffing Algorithm - Efficiently updating the DOM with minimal changes
Components in Domino are functions that return a context object containing:
- The component's HTML structure (JSX-like syntax)
- Initial state values
- Event handlers
- The component render function
Domino uses a Virtual DOM to:
- Represent UI as lightweight JavaScript objects
- Calculate minimal changes needed (diffing)
- Efficiently update only what changed in the real DOM
The built-in store provides:
- Centralized state - Single source of truth for application state
- Actions - Describe what happened
- Reducers - Specify how state changes
- Automatic re-rendering - Components update when relevant state changes
The router handles:
- URL-to-component mapping
- Dynamic route parameters
- Browser history integration
- Automatic view updates on navigation
A fully-featured todo app is included in the example/ directory demonstrating all framework capabilities.
npm startThen visit http://localhost:3000 to see it in action.
Features demonstrated:
- Component composition
- State management with actions and reducers
- Event handling
- Route-based navigation (/, /active, /completed)
- Conditional rendering
- List rendering
For detailed documentation, see:
- User Guide - Comprehensive guide to building with Domino
- Examples - Sample applications and components
mini-framework/
βββ _bin/
β βββ mini.js # CLI tool for scaffolding projects
βββ _lib/
β βββ core/
β β βββ compiler/ # Custom JSX-like syntax compiler
β β βββ router/ # Client-side routing system
β β βββ runtime/ # Framework runtime engine
β β βββ stateManager/ # Redux-like state management
β β βββ vdom/ # Virtual DOM implementation
β βββ templates/ # Project templates for CLI
βββ docs/
β βββ USE.md # User guide and documentation
βββ example/ # Todo app demo
β βββ components/ # Reusable UI components
β βββ pages/ # Route-based page components
β βββ app.js # Application entry point
β βββ reducer.js # State reducer
β βββ index.html
βββ server.js # Development server
βββ package.json
This framework was created as a learning exercise to deeply understand how modern JavaScript frameworks work under the hood. By building each piece from scratch - the Virtual DOM, state management, routing, and component system - it provides hands-on insight into the inner workings of tools like React, Redux, and React Router.
- Inspired by React, Redux, and React Router
- Built to learn and understand framework internals
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
β Star this repository if you found it helpful! β
Made with β€οΈ from πΈπ³
