Cook the spaghetti in salted water until it is firm to the bite. Then let it cool down (must not stick! Possibly add a little olive oil).
Cut tomatoes and mozzarella into small cubes, place in a large bowl with finely diced onions and crushed garlic. Add the cooled spaghetti and season with balsamic vinegar, olive oil, salt, pepper and basil to taste.