Welcome to Dream Project, a web-based application built with OCaml and the Dream framework to demonstrate Binary Search Tree (BST) operations and list zipping functionality. This project provides an interactive interface for creating, visualizing, and manipulating BSTs, as well as zipping two lists into pairs. It's perfect for learning about data structures and functional programming while exploring modern web development with OCaml.
Dream Project is an educational and interactive web application designed to showcase two core functionalities:
- Binary Search Tree Operations: Create a BST from a list of numbers, visualize it, add or delete nodes, and view metrics like tree size and depth.
- List Zipping: Combine two comma-separated lists into a list of pairs, displayed in a clean and user-friendly format.
Built with OCaml, Dream (a web framework), and Dune (a build system), this project combines functional programming with web development. The frontend includes a JavaScript-based BST visualization and a responsive design powered by CSS.
The project is organized as follows:
dream-project/
│ ├── bstree.ml # Binary Search Tree
│ ├── zip.ml # List zipping implementation
│ └── main.ml # Main application logic with
├── static/ # Static assets
│ ├── style.css # CSS styles for the frontend
│ └── tree.js # BST visualization
├── dune # Dune build configuration
├── dune-project # Dune project metadata
├── README.md # This file
└── LICENSE # License file (to be added)
To run Dream Project on Ubuntu, ensure you have the following installed:
- OCaml (version 5.0 or higher)
- Dune (version 3.0 or higher)
- OPAM (OCaml package manager, version 2.1 or higher)
- Ubuntu (20.04 LTS or later recommended)
Follow these steps to set up the project:
-
Install OPAM:
bash -c "sh <(curl -fsSL https://opam.ocaml.org/install.sh)" -
Initialize OPAM:
opam init eval $(opam env)
-
Install OCaml and Dune:
opam switch create 5.3.0 opam install dune
-
Install Dream and Lwt:
opam install dream lwt lwt_ppx
To run the project with Dune:
-
Build the project:
dune build
-
Run the application:
dune exec ./main.exe -
Access the web interface:
- Open your browser and navigate to
http://localhost:8080. - The homepage offers two options: BST operations or list zipping.
- Open your browser and navigate to
- Navigate to
/bstfrom the homepage. - Enter comma-separated numbers (e.g.,
5,2,8,1,9) in the form and submit. - View the BST visualization, size, and depth.
- Use the "Add Node" or "Delete Node" buttons to modify the tree:
- Enter a number and click "Add Node" to insert it.
- Enter a number and click "Delete Node" to remove it.
- Errors (e.g., invalid input) are displayed with a "Back" link to retry.
- Navigate to
/zipfrom the homepage. - Enter two comma-separated lists (e.g.,
a,b,cand1,2,3) in the form and submit. - View the zipped result as a list of pairs (e.g.,
(a,1), (b,2), (c,3)). - Click "Back" to try another pair of lists.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -m 'Add YourFeature'). - Push to the branch (
git push origin feature/YourFeature). - Open a Pull Request.
Please ensure your code follows the project's coding style and includes appropriate tests.
Your Name
- GitHub: https://github.com/kamalkdolikay
- Email: kamaldolikay@gmail.com
This project is licensed under the MIT License. See the LICENSE file for details.