The guys at Nettus have written about what goes inside any good social media website. However, they forget to write about the code snippets for each feature but I think you can search for the codes on Google with little fuss.
Here's the list:
1. Activity Stream e.g. Facebook
2. User Authentication and Profiles + access levels
3. Invite a friend an "invite your friend" script that furrows into your user's email address book and does at least one of two things:
4. Recommendation Engine - Many of these content recommendation engines are built on the Slope One Algorithm http://en.wikipedia.org/wiki/Slope_One
5. Private Messaging
6. Status Updates (Like Twitter - get Laconica and build your own Twitter http://laconi.ca/trac/ )
7. Multiple Ways of Viewing the Data
8. An API http://3scale.net/
9. Voting
10. Widgets http://www.widgetbox.com/
