The path mapping is nearly mechanical. Users, activity, /user/<name> and /profiles/<slug> are the same path with /forte in front, so one helper can add or strip the prefix in either direction.
Threads are the only exception: /threads/<id> becomes /forte?selected=<id>, and a reply adds &created_post_id=<id>#post-<id>, the same form paned_thread_reply_tree.php already builds for its permalinks. Going back, the helper reads selected and created_post_id from the query.