Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tutosrive/avl_tree_car/llms.txt

Use this file to discover all available pages before exploring further.

By the end of this guide you’ll have the AVL Tree Car Backend running on localhost:4500, have confirmed the root endpoint responds correctly, and have inserted your first obstacle node into the AVL tree — everything the ATC Frontend needs to connect and render a live simulation.

Prerequisites

  • Python 3 installed and available on your PATH (python --version or py --version on Windows)
  • pip available for installing packages
  • git for cloning the repository

Setup

1

Clone the repository

Clone the project from GitHub and move into the new directory.
git clone https://github.com/tutosrive/avl_tree_car.git
cd avl_tree_car
2

Create a virtual environment (optional but recommended)

Isolating dependencies in a virtual environment prevents version conflicts with other Python projects on your machine.
python -m venv .venv
source .venv/bin/activate
Your prompt will change to show (.venv) when the environment is active.
3

Install dependencies

Install the four required packages from requirements.txt.
pip install -r requirements.txt
This installs Flask 3.1.2, flask-cors 6.0.1, Flask-SocketIO 5.5.1, and chromologger 0.1.9.post2.
4

Start the server

Run the entry-point script to start the Flask + Socket.IO server.
python run.py
The server starts on localhost:4500. You should see Socket.IO and Flask startup output in your terminal confirming the server is ready to accept connections.
The server runs with debug=True by default (set in run.py). This enables Flask’s auto-reloader and detailed tracebacks. Do not expose this server publicly or use debug=True in any production-like environment.
5

Verify the server is running

Open a new terminal and send a GET request to the root endpoint.
curl http://localhost:4500/
You should receive:
{
  "status": 200,
  "ok": true,
  "message": "Hello From Flask!",
  "data": {},
  "error": null
}
A 200 ok: true response confirms Flask is serving requests correctly.

Your first API call

With the server running, insert an obstacle node into the AVL tree by posting to POST /avl/node/add. The request body requires the obstacle’s road position (x), height (y), and a numeric type identifier (type_id 1–10).
curl -X POST http://localhost:4500/avl/node/add \
  -H "Content-Type: application/json" \
  -d '{"x": 100, "y": 20, "type_id": 1}'
A successful insert returns the generated obstacle ID in data:
{
  "status": 200,
  "ok": true,
  "message": "The node with coordinates (100, 20) has been added successfully!",
  "data": "a3Bf9z1Q",
  "error": null
}
If you attempt to insert a second obstacle at the same x position, the AVL tree rejects it with ok: false and a 400 status — duplicate x coordinates are not allowed because the tree is keyed on road position.

Bulk-loading with configs.json

Rather than inserting obstacles one by one, you can POST a full configs.json to POST /avl/add/configs to seed the tree with a set of obstacles and simulation parameters in one request. Download the sample file from the README to get a pre-built configuration with eight obstacles spanning the road.Sample: configs.json
curl -X POST http://localhost:4500/avl/add/configs \
  -H "Content-Type: application/json" \
  -d @configs.json

Next steps

  • Review the full HTTP and Socket.IO endpoint reference in the API Overview.
  • Understand how modules are wired together in Project Structure.
  • Connect the ATC Frontend to this backend and watch the obstacle simulation run in the browser.

Build docs developers (and LLMs) love