\section{Architecture}
\label{sec:architecture}

Based on the extensive list of functional requirements defined by the
Brazilian Federal Government, we selected some FOSS systems to form our
solution. We looked for system that together could provide the largest
subset possible of the requirements, and were fully aware that we would
need to improve those systems in order to provide the rest. We were also
convinced that it would be impossible to provide all of those
requirements with a single tool.

From the point of view of the architecture, two main requirements was
brought by the Brazilian Federal Government for the new platform:

\begin{enumerate}
  \item \textit{Integrate existing FOSS systems}, with minimal differences from
    their original versions;
  \item \textit{Provide a consistent user interface} across the different
    systems, as well as centralized authentication.
\end{enumerate}

Adopting existing FOSS systems and minimizing locally-made changes had
the objective of being able to upgrade to newer versions of the original
software, benefiting from improvements and maintenance done by the
existing project communities. Providing a consistent user interface on
top of those different tools was needed to make the transition between
the different systems seamless from the point of view of users, which
would be confused by jumping through completely different interfaces
while interacting with the portal.

For the first requirement, we identified four main systems that required
specialized teams for work in the integration process. The teams learned
how to develop for their assigned systems and contributed to the
original communities, so that the version we used were not significantly
different from the original.

At the end of the project, the SPB portal was composed of more than ten
systems, such as Colab, Noosfero, Mezuro, Gitlab, Mailman, Postfix, and
Munin. The remainder of this section describes the most relevant of
them, as well as how they were integrated into the platform.

\subsection{Colab}

Colab\footnote{\url{https://github.com/colab}} is a systems integration
platform for web applications. One of its goals is allowing different
applications to be combined in such a way that an user does not notice
the change between applications. For that, Colab provides facilities
for:

\begin{itemize}
  \item \textit{Centralized authentication}: Users are automatically 
identified for each application without having to enter login
credentials on each of them;
  \item \textit{Visual consistency}: Colab is able to change the HTML
code produced by the integrated applications, such as defining default
template or reusing common HTML pages, in order to provide a unified
interface;
  \item \textit{Relaying of events between applications}: The
integrated applications or Colab itself are able to trigger an action
on another application;
  \item \textit{Integrated search engine}: It is possible to set up
exactly which data needs to be indexed from each application and how
users are directed to this information on correspondent application;
\end{itemize}

Colab implements this integration by working as a reverse proxy for the
integration applications, that is, all external requests pass through
Colab before reaching them. 

Initially, Colab had support for a small set of applications (Trac, GNU
Mailman, and Apache Lucene) and support for them was hard-coded. Our
team evolved Colab so that it can now receive plugins that add support
new applications without the need of changes to the Colab core.

\subsection{Noosfero}

Noosfero\footnote{\url{http://noosfero.org}} is a software for building
social and collaboration networks. Besides the classical social
networking features, it also provides publication features such as blogs
and a general-purpose CMS (Content Management System). Most of the user
interactions with SPB is through Noosfero: user registration, project
home pages and documentation, and contact forms.

\subsection{Gitlab}

GitLab\footnote{\url{http://gitlab.com}} is a web-based Git repository
manager with wiki pages and issue tracking features. Gitlab is a FOSS
platform and focuses on delivering a holistic solution that will see
developers from idea to production seamlessly and on a single platform.

Gitlab has several unique features, such as built-in continuous
integration and continuous deployment, flexible permissions, tracking of
Work-in-Progress work, moving issues between projects, group-level
milestones, creating new branches from issues, issues board, and time
tracking.

\subsection{Mezuro}

Mezuro\footnote{\url{http://mezuro.org/}} \cite{mezuro_oss} is a platform to
collect source code metrics to monitor the internal quality of software written
in C, C++, Java, Python, Ruby, and PHP.

In general, source code metrics tools also do not present a friendly way
to interpret its results and, even more, do not follow a standardization
between them. Mezuro collects and presents these results to the end
user, specially, by analyzing source code metric history during its life
cycle.

The Mezuro platform provides a single interface grouping available
tools, allows selection and composition of metrics in a flexible manner,
stores the metrics evolution history, presents results in a friendly
way, as well as, allows users to customize the given interpretation
accordingly to their own context.

\subsection{System unification}

\begin{figure}[hbt]
  \centering
    \includegraphics[width=\linewidth]{figures/arch.png}
  \caption{SPB architecture overview.}
  \label{fig:architecture}
\end{figure}

The conceptual architecture of the platform is presented in Figure
\ref{fig:architecture}. Colab initially handles all user interaction,
directing requests to one of the integrated applications. It
post-processes responses from the applications to apply a consistent
visual appearance, manages authentication, and provides a unified search
functionality: instead of using the redundant restricted search
functionality of each application, a search o	n the SPB portal might
return content from any of the applications, be it web pages, mailing
list posts, or source code.

% Falar do devops
\subsection{Deploy}

The SPB platform was deployed in 7 virtual machines with different functions,
as we can see in Figure \ref{fig:architecture2}.

\begin{figure*}[hbt]
  \centering
    \includegraphics[width=.8\linewidth]{figures/arch3.png}
  \caption{Instanciation view of the SPB architecture.}
  \label{fig:architecture2}
\end{figure*}

The \textit{reverseproxy} handles the HTTP requests and redirects them to the
\textit{integration}, the \textit{email} sends and receives e-mails on behalf
of the platform and the \textit{monitor} keeps the entire environment tracked.
These three \textit{VMs} mentioned - \textit{reverseproxy}, \textit{email} and
\textit{monitor} - are accessible via Internet and the other ones are only
available in the local network created between them.

\textit{Integration} works as a second layer of proxy beneath
\textit{reverseproxy}, any request to the platform will be handled by it. The
Colab service provides interface, authentication and search engine integration
among all the services. When a request is received to a specific service,
Colab authenticates the user in the target tool, sends the request and makes a
visual transformation in the HTML page which is the content of the response.
Another user-oriented feature is the integrated search engine, when the user
want to find something in the platform Colab will perform the search in the
whole databases. Colab itself provides a web interface for GNU Mailman and we
have two others integrated tools in \textit{integration}: Gitlab and Prezento.
Gitlab provides web interface for Git repositories and issues tracker, and
Prezento is a front-end for source code static analysis.

The source code static analysis is performed by \textit{mezuro}. It runs some
static analysis tools on source code stored in repository and provide this data
to Prezento. A social network and CMS (Content Manager System) is provided by
Noosfero in \textit{social}, and the databases of all tools with a cache
service are in \textit{database}.
