I read that onion proxy adds a layer of abstraction for each onion router in a route,and each onion router just removes a layer of encryption then does onion proxy knows about all onion routers in the route? and does onion routers just decrypts the data and not encrypt them?
directory server periodically uploads the list of nodes that are available for relaying data. client selects three nodes from this list and gets their public key using which it encrypt data multiple times and sends data to first node of the circuit. each node in the circuit decrypts one layer using their private key. and exit node send data to the destination.
Let's imagine you want to reach a website. Your tor client gets 3 relays out of list of available ones. After that it shares different decryption/encryption keys with each relay. Then it encrypts the packets 3 times and sends them. Each relay decrypts one layer and exit one can see all data going to the website decrypted as plain text. When your data reaches the website the website sends data back to the exit node again in plain text. Then RELAYS share encryption/decryption keys with you. Exit node encrypts the first time, middle second and entry third time. Then you get the data and you decrypt each layer.
So yeah... relays encrypt and decrypt data. Also when the website sends data back to exit node it has some way to link it to middle and middle to entry and entry to you. I don't know how but I hope none of them knows the whole path.