The backend uses a small, focused set of Python models for domain objects (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.
Obstacle, Node, Car) and response wrappers (BaseFlaskResponse, ReturnModels, ResponseSocket). Understanding these shapes makes it straightforward to parse API responses and interpret Socket.IO payloads.
BaseFlaskResponse
Used as the envelope for every HTTP REST response. All fields are serialized byto_dict().
HTTP status code.
200 on success, 400 on validation or not-found errors, 500 on server exceptions.true when the operation succeeded, false on any error.Human-readable description of the result.
The operation payload. For node add this is the inserted obstacle ID string; for bulk configs it is an array of IDs; otherwise an empty object
{}.Error details when
ok is false. null on success.ReturnModels
Internal return type produced byAVLTree methods such as insert, delete, search, and the traversals. Not sent directly over the wire — controllers extract fields from it to build a BaseFlaskResponse.
Describes the outcome, e.g.
"Node found, see data!" or "Tree is empty!".true when the operation succeeded.The result payload. For
insert this is the new obstacle’s id string; for search it is the Node object; for traversals it is a list of Obstacle objects.Error details on failure,
null otherwise.ResponseSocket
Used for all Socket.IO event emissions. Thedata field is auto-serialized if the value has a to_dict() method.
true when the event was handled successfully.The raw message received from the client — echoed back for debugging.
Human-readable status message (default
"OK").Payload for the event. For tree events this is the serialized tree dict; for traversal stream events it is a single obstacle ID string emitted per step.
Error details if
ok is false, otherwise null.If
data is an object with a to_dict() method, it is called automatically before serialization. String values (such as obstacle IDs) are returned as-is.Obstacle
The core value stored in every AVL tree node. Represents a road hazard at a specific(x, y) position.
Auto-generated 8-character random string. Even-indexed positions are digits, odd-indexed positions are capital letters (e.g.
"0A2B4C6D"). Generated by RandomsUtils.random_id(8, 2).Horizontal position on the road. Used as the primary sort key in the AVL tree.
Vertical position / height of the obstacle on the road.
Numeric obstacle type. Maps to one of 10 types defined in
obstacles_types.json (1 = Cone, 2 = Rock, … 10 = Chair).Two obstacles with the same
(x, y) coordinates are considered duplicates. The AVL tree will reject the second insert with a 400 error.Node
Wraps anObstacle as an AVL tree node, adding structural pointers and a height counter used for balancing.
The obstacle stored at this node position.
Left child node (contains obstacles with smaller
x than this node).Right child node (contains obstacles with larger
x than this node).Height of this node in the tree. Leaf nodes have height
1. Updated after every insert and delete.Node also carries a parent reference (Node | null) used internally during rotations and rebalancing. This field is not included in the to_dict() output — it exists only on the Python object.Node.to_dict() recursively serializes the subtree into value, left, right, and height only:
Car
A lightweight backend model representing the car entity. Primary simulation logic runs in the frontend; the backendCar class is a stub.
Car speed in units per tick. Default
5.Current battery level. Default
0.Whether the car is currently colliding with an obstacle. Default
false. Note: the source spells this field collition_with_obstacle (without the second s).Horizontal position of the car. Default
100.Vertical position of the car. Initialized to
road_size[1] // 2.The
Car class on the backend does not implement movement logic — run(), up(), and down() are stubs. All animation and collision detection are handled by the ATC Frontend.AVLTree serialization
CallingAVLTree.to_dict() produces a compact nested structure using only obstacle id values and a children array. This is the format emitted by Socket.IO tree events (avl_tree_balanced, avl_reseted).