Skip to content

A lightweight educational JavaScript framework built from scratch. Implements Virtual DOM, Redux-like state management, and client-side routing - demonstrating how modern frameworks work internally without any dependencies.

Notifications You must be signed in to change notification settings

TanakAiko/mini-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Domino Framework

JavaScript HTML5 CSS3 Node.js

Virtual DOM State Management Routing Zero Dependencies

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.

✨ What's Implemented

  • 🎨 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 mini CLI

πŸ”§ Getting Started

Run the Example Todo App

git clone <your-repo-url>
cd mini-framework
npm start

Then visit http://localhost:3000 to see the todo app in action.

🎯 Quick Start

Creating Your First Component

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;
};

Setting Up State Management

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 });

Configuring Routes

const routes = [
    { path: '/', component: Home },
    { path: '/counter', component: Counter },
    { path: '/about', component: About }
];

const router = new Router(routes);

πŸŽ“ Learning Objectives

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

πŸ’‘ How It Works

Components

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

Virtual DOM

Domino uses a Virtual DOM to:

  1. Represent UI as lightweight JavaScript objects
  2. Calculate minimal changes needed (diffing)
  3. Efficiently update only what changed in the real DOM

State Management

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

Routing

The router handles:

  • URL-to-component mapping
  • Dynamic route parameters
  • Browser history integration
  • Automatic view updates on navigation

πŸ“š Example: Todo Application

A fully-featured todo app is included in the example/ directory demonstrating all framework capabilities.

Todo App Demo

npm start

Then 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

πŸ“– Documentation

For detailed documentation, see:

  • User Guide - Comprehensive guide to building with Domino
  • Examples - Sample applications and components

πŸ“ Project Structure

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

🎯 About This Project

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.

πŸ™ Acknowledgments

  • Inspired by React, Redux, and React Router
  • Built to learn and understand framework internals

🀝 Contributing

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

⭐ Star this repository if you found it helpful! ⭐

Made with ❀️ from πŸ‡ΈπŸ‡³

About

A lightweight educational JavaScript framework built from scratch. Implements Virtual DOM, Redux-like state management, and client-side routing - demonstrating how modern frameworks work internally without any dependencies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •