Code Monkey home page Code Monkey logo

treeify's Introduction

๐ŸŒณ Treeify ๐ŸŒณ

Introduction

This web app fetches any website's DOM and displays it in visual form - as a tree!


Usage

Demo

Visit https://treeify-app.herokuapp.com/ for a working demo of the app. Some suggestions for good-looking URLs:

Warning: if a website has too large of a DOM, tree rendering may slow down significantly, or it may try to render on a canvas larger than your browser will allow. If this happens, reload the tab (or close and reopen) and try again with a different URL.

Run Locally

  1. Clone or download the code into a directory of your choosing
  2. In the project's root directory, run yarn start to start the Express server and verify CLI prints App listening at port: 3001
  3. In the project's client directory (cd client), run yarn start to start the React app

Under the Hood

How It Works

  1. User inputs a URL and clicks treeify
  2. React app sends URL to Express server in a POST request
  3. Server makes a GET request to the external site and fetches its DOM
  4. Server parses the data with a tree traversal, adding drawing information to each node
  5. React app receives data from the server
  6. React app renders the tree on screen

Technologies Applied & Skills Learned

  • Express backend (asynchronous logic, error handling)
  • React frontend (form validation, POST request to server, UI gracefully handles loading & error states)
  • Depth-first and breadth-first tree traversal algorithms to build the DOM object and draw the tree
  • p5.js embedded in React through useRef & useEffect hooks

Known Issues & Bugs

Issues can be found in this repo's Issues tab.

Challenge/Discussion Section

Drawing a balanced, good-looking tree is harder than it sounds. Credit to Bill Mill for this extensive article discussing methods and key principles.

Tl;dr:

Principle 1: The edges of the tree should not cross each other.

Principle 2: All nodes at the same depth should be drawn on the same horizontal line. This helps make clear the structure of the tree.

Principle 3: Trees should be drawn as narrowly as possible.

Principle 4: A parent should be centered over its children.


Screenshots

treeify screenshot

treeify's People

Contributors

ezeyaniv avatar

Stargazers

Donghun Kim avatar

Watchers

 avatar

treeify's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.