Key Takeaways
- Diaspora* is a decentralized, open-source social networking engine, which allows users to build their own social networks while maintaining data on their own servers. It is built using Ruby on Rails and the UI uses Backbone.
- Setting up Diaspora* requires installation of Ruby, Rails, MySQL, and Git. The article provides a detailed guide on how to install these dependencies and get the Diaspora* source to work with. After configuration, users can create an account and assign admin privileges if needed.
- The Diaspora* codebase consists of several key objects such as User, Person, Profile, Contact, Aspect, Post, and Comment, and the directory structure is well-organized into controllers, helpers, mailers, models, presenters, uploaders, and views. Users are encouraged to familiarize themselves with the codebase and customize Diaspora* to build their own social network with specific features.
What’s Diaspora*?
Diaspora can be viewed from two different perspectives: first, from an end user’s, who could find Diaspora much similar to other social networks like Google+, Facebook, or even Twitter. I used to think that Diaspora was different, having some unique features until Google+ came and included many of these features. The other angle sees Diaspora is from a developer’s perspective, as a Social Networking Engine. It is possible to build a social network with sophisticated features and a very simple and elegant UI in few weeks, or even days, depending on your experience.Why Diaspora?
Diaspora is open source and distributed which means you could connect your deployed instance with other deployed instances and make a huge social network fully connected, all while maintaining your data on your servers. Also, it’s written in Ruby on Rails and the UI uses Backbone.Installation
With the introduction out of the day, let’s see Diaspora in action. First, you need to install some dependencies: Ruby: you can find all you need in this tutorial Installing Ruby with RVM on Ubuntu Rails: these two tutorials are helpful for installing rails Rails Intro, Deep Dive: Installing Rails, Part One, and this one Loccasions: Installing Rails Part 2 MySQL: at least for development purposes, you will need MySQL so this commands will install it for you and to run MySQL server [gist id=”1975336″] Git: you need git to clone the diaspora repository, despite that you can download it from the repository page but you will need git anyway, so you have to install it, and if want to setup git to work with your github account, you should read this also from github help pages for linux [gist id=”2017154″] Diaspora: now you need to get diaspora source to work with, so we going to clone it from the project git repository and switch to the diaspora directory [gist id=”2017174″] You almost now have a working environment to run Diaspora, but we have just a few steps before running the server. Run the following command from the root directory of diaspora project itself. For example, if your project was in your home directory, the root directory of the project will be at ~/diaspora/ [gist id=”1975392″] Now, go to theconfig/
folder and remove the [.example]
from the following files:
- database.yml.example
- application.yml.example
database.yml
, you need to configure MySQL server entries to match your environment.
Last commands to start the project are
[gist id=”1975425″]
Open your broser and go to [ localhost:3000 ]
and follow the directions to create a user. If you want this new user to have admin privileges, you can edit that in config/application.yml
by adding the username to the admins
section. You can actually do a lot of configuration in this file, which we will discuss in the next tutorial.
Diaspora Codebase
The typical Disapora code directory structure is below. Take a moment to familiarize yourself with the code base. Let’s start our familiarization with the Diaspora object model. You can find the source for these objects in theapp/models
folder.
User
A User object represents the private information and capabilities of a user on that server. The user object is able to friend people, post updates, and update his profile. A User has a Person.Person
A Person is a User viewed from the outside. When a user friends another user, they friend that user’s Person object. Person objects are replicated across servers, and they are where a User’s public key lives. A Person has many Posts. A Person has a Profile.Profile
This contains information about the person. Currently, a profile looks the same to anyone looking at it.Contact
A Contact is a “proxy” object for every person a User is friends with, means that to initialize any relationship with any other user you need a contact object to make the link.Aspect
This contains a list of people and posts which are for that aspect. Aspects are private to Users, and we might embed the Aspect documents in the User document.Post
A Post belongs to a Person. This is a parent class for different types of posts, it contains comment ids and a few other attributes common to all Posts.Comment
A comment belongs to a PostDirectory Structure
Here is what the code base for our Diaspora* app looks like:├── app │ ├── controllers │ │ ├── activity_streams │ │ │ └── photos_controller.rb │ │ ├── admins_controller.rb │ │ ├── apis_controller.rb │ │ ├──────────── │ │ ├── people_controller.rb │ │ ├── photos_controller.rb │ ├── helpers │ │ ├── application_helper.rb │ │ ├── aspect_global_helper.rb │ │ ├──────────── │ │ ├── error_messages_helper.rb │ │ ├── getting_started_helper.rb │ ├── mailers │ │ ├── diaspora_devise_mailer.rb │ │ ├── notification_mailers │ │ │ ├── also_commented.rb │ │ │ ├── base.rb │ │ ├──────────── │ │ │ ├── reshared.rb │ │ │ └── started_sharing.rb │ │ └── notifier.rb │ ├── models │ │ ├── account_deleter.rb │ │ ├── account_deletion.rb │ │ ├── tag_following.rb │ │ ├──────────── │ │ ├── user_preference.rb │ │ └── user.rb │ ├── presenters │ │ └── user_presenter.rb │ ├── uploaders │ │ ├── processed_image.rb │ │ └── unprocessed_image.rb │ └── views │ ├── admins │ │ ├── _admin_bar.haml │ │ ├── correlations.haml │ │ ├── stats.html.haml │ │ ├── user_search.html.haml │ │ └── weekly_user_stats.haml │ ├──────────── │ ├── apps │ │ └── show.html.haml │ └── users │ ├── edit.html.haml │ ├── getting_started.haml │ ├── logged_out.haml │ └── privacy_settings.html.haml ├── AUTHORS ├── Capfile ├── config ├── db ├── lib ├── log ├── public │ ├── images │ ├── javascripts │ │ ├── app │ │ │ ├── collections │ │ │ ├── helpers │ │ │ ├── models │ │ │ ├── templates │ │ │ └── views │ │ ├── helpers │ │ ├── pages │ │ ├── vendor │ │ └── widgets │ ├── stylesheets │ └── uploads ├── script ├── spec └── tmp
Okay, what’s next?
We only covered the very basic of Diaspora. There are many more pieces to the puzzle, like Controllers, Views and the Backbone part of the UI which you can find in thepublic/javascript/app
. It will your mission, should you choose to accept it, to take a look over them until the next tutorial, where we will customize Diaspora to build our social network with some specific features.
Frequently Asked Questions (FAQs) about Building Your Own Social Network with Diaspora
What is Diaspora and how does it differ from other social networks?
Diaspora is a decentralized social network that allows users to host their data on their own servers, or “pods”. Unlike centralized social networks like Facebook or Twitter, where all user data is stored on the company’s servers, Diaspora’s decentralized nature gives users more control over their data and privacy. This unique feature sets Diaspora apart from other social networks.
How can I start building my own social network with Diaspora?
To start building your own social network with Diaspora, you need to set up your own pod. This involves downloading the Diaspora software, installing it on a server, and configuring it to your liking. Once your pod is set up, you can invite others to join and start building your social network.
What are the technical requirements for setting up a Diaspora pod?
Setting up a Diaspora pod requires a server with a Unix-like operating system, such as Linux or BSD. You’ll also need Ruby, Rails, and a database system like MySQL or PostgreSQL. Additionally, you’ll need a domain name and an SSL certificate for secure communication.
How can I join an existing Diaspora pod?
Joining an existing Diaspora pod is as simple as visiting the pod’s website and signing up for an account. Once you’ve created an account, you can start posting status updates, photos, and more.
Can I switch between Diaspora pods?
Yes, Diaspora allows users to switch between pods. This is possible because all Diaspora pods are interconnected, forming a network of pods. When you switch pods, your data is transferred to the new pod.
How secure is Diaspora?
Diaspora is designed with privacy and security in mind. All communication between pods is encrypted, and users have fine-grained control over who can see their posts. However, like any online service, it’s important to use strong, unique passwords and be cautious of phishing attempts.
Can I use Diaspora on my mobile device?
Yes, Diaspora is mobile-friendly and can be accessed from any web browser. There are also several third-party apps available for iOS and Android.
How can I contribute to the Diaspora project?
Diaspora is an open-source project, which means anyone can contribute to its development. You can contribute by writing code, reporting bugs, translating the software into other languages, or donating to the project.
What kind of content can I share on Diaspora?
You can share a wide range of content on Diaspora, including text posts, photos, and links. You can also use hashtags to categorize your posts and make them discoverable by others.
How can I find people to connect with on Diaspora?
You can find people to connect with on Diaspora by searching for hashtags that interest you, joining discussions, and following other users. You can also invite your friends to join your pod.
I'm enthusiastic for Open Web, Open Source, Linux, writing code, and I do love Ruby on Rails, and JavaScript, and I am member of the Ubuntu-EG LoCo team.