<h1 id="heading-getting-started"><a name="heading-getting-started">Getting Started</a></h1><p>Arrow Project Name: <code><%= objectmodel.metadata.name %></code> <em><%= objectmodel.metadata.description %></em></p>
<p><img id="arrow-logo" src="images/Arrow_logotype-mark-red.png" /></p>
<p>Welcome to Arrow.  Arrow is an opinionated framework for building and running new API endpoints for consumption by any type of client application (e.g., Titanium, Native Objective-C (iOS) or Java (Android), or any desktop or mobile web application).</p>
<p>The core building blocks for an Arrow project are models.  Models represent data stored in some source system (e.g., MySQL, Salesforce, ArrowDB, MongoDB, etc.).  </p>
<h2 id="heading-creating-your-first-model"><a name="heading-creating-your-first-model">Creating Your First Model</a></h2><p>Let’s jump right in and create our first model.  In order to demonstrate the power of Arrow quickly, our first model will be based on ArrowDB.  ArrowDB is an elastically scalable, schema-less data store that runs in the Arrow Cloud.  It allows you to create and instantly deploy new models and APIs.</p>
<p>Go to your <code>models</code> directory and create a file called <code>car.js</code> and copy and paste the following code:</p>
<pre class="highlight javascript"><span class="hljs-keyword">var</span> Arrow = <span class="hljs-built_in">require</span>(<span class="hljs-string">'arrow'</span>);

<span class="hljs-keyword">var</span> car = Arrow.createModel(<span class="hljs-string">'car'</span>, {
    fields: {
        make: { type: <span class="hljs-built_in">String</span>, description: <span class="hljs-string">'the make of a car'</span> },
        model: { type: <span class="hljs-built_in">String</span>, description: <span class="hljs-string">'the model of the car'</span>, required: <span class="hljs-literal">true</span> },
        year: { type: <span class="hljs-built_in">Number</span>, description: <span class="hljs-string">'year the car was made'</span>, required: <span class="hljs-literal">true</span> },
        bluebook: { type: <span class="hljs-built_in">Number</span>, description: <span class="hljs-string">'kelly bluebook value of the car'</span>, required: <span class="hljs-literal">true</span> },
        mileage: { type: <span class="hljs-built_in">Number</span>, description: <span class="hljs-string">'current mileage of the car'</span>, required: <span class="hljs-literal">true</span> }
    },
    connector: <span class="hljs-string">'appc.arrowdb'</span>
});

<span class="hljs-built_in">module</span>.exports = car;</pre><p>As you can see, creating a model is easy.  It has a name (<code>car</code>), and it has some fields.  The <code>connector</code> property specifies the connector to be used by the model.  In Arrow, connectors are responsible for reading and writing from/to a particular data source.  Arrow comes with the following connectors out of the box: MySQL, Salesforce, ArrowDB, MongoDB, and Microsoft Azure MSSQL.  Our model uses the ArrowDB connector.  Arrow also comes with a Connector SDK, which makes it easy for anyone to create a new Connector.</p>
<p>Now that we have a model, let’s re-start our Arrow project.  From your project home directory type</p>
<pre class="highlight shell">appc run</pre><p>By default, Arrow will automatically generate API endpoints for any model you create (this behavior can be turned off at the model level).  Arrow will also automatically generate documentation for your new model and the API endpoints that are generated for it.  To see your newly create <code>car</code> API, go to  <a href="<%=ADMIN_URL%>/docs.html?apis/car">API section of API DOCS</a>.  To see your newly create <code>car</code> model, go to <a href="<%=ADMIN_URL%>/docs.html?models/car">Models section of API DOCS</a></p>
<p>The generated documentation for Arrow also allows you to test your endpoints.  To do this, go back to the <a href="<%=ADMIN_URL%>/docs.html?apis/car">API section of the API DOCS</a> and go to the POST/car section.  The POST endpoint allows you to create a new record.  See the screenshot below:</p>
<p><img class="shadow" src="images/car_post.png" /></p>
<p>Fill out the values and hit the Create button.</p>
<p>Next, you can run the GET/car request to find all cars.  In this case, it should only return the new car we just created.  See the screenshot below:</p>
<p><img class="shadow" src="images/car_get.png" /></p>
<p>This request is returning data from ArrowDB in the Arrow Cloud.  While this is a very simple example, it shows you the power of Arrow especially when used in conjunction with ArrowDB.  We were able to create a new model and a new set of API endpoints and store data in the cloud in just a couple of minutes.</p>
<h2 id="heading-managing-model-data"><a name="heading-managing-model-data">Managing Model Data</a></h2><p>Arrow provides a lightweight Data Manager for managing the underlying data for all of your Arrow models.  This capability is actually built on top of Arrow.  It provides basic create, update, delete functions for all of your model data as well as a nice query interface for finding particular records.  To manage your model data, go to the <a href="<%=ADMIN_URL%>/cms.html">Data</a> tab.  The attached screenshot shows the Data Manager for our model.</p>
<p><img class="shadow" src="images/car_data.png" /></p>
<h2 id="heading-viewing-performance-logs"><a name="heading-viewing-performance-logs">Viewing Performance Logs</a></h2><p>Arrow provides a Performance Log view that allows you to see detail about every step of an API request/response.  The Performance Log is useful for diagnosing both bugs and performance problems.  To view the Performance Logs, go to the <a href="<%=ADMIN_URL%>/logs.html">Logs</a> tab.  The attached screenshot shows the Performance Logs for a request to our car API.</p>
<p><img class="shadow" src="images/car_log.png" /></p>
<h2 id="heading-installing-other-connectors"><a name="heading-installing-other-connectors">Installing Other Connectors</a></h2><p>By default, each Arrow project will automatically install the ArrowDB connector.  In most cases, you will want to install other connectors as well.  To see what connectors are available for installation, go to the <a href="http://software.appcelerator.com">Platform Marketplace</a> tab.</p>
<p>For example, if you want to install the Salesforce connector, you would run the following command from your project root directory:</p>
<pre class="highlight shell">appc install connector/appc.salesforce</pre><p>You can also search the Platform Marketplace using the CLI - just type <code>appc search connector</code> to see a list of available connectors.</p>
<p>The basic format of the command is <code>appc install [component_type]/[component_name]</code>.</p>
<p>One of the powerful aspects of Arrow is that it enables you to easily create a single model/API that is composed of fields from different data sources.  To learn more about Models and what’s possible go to the Model Reference.</p>
<h2 id="heading-publish-your-arrow-project"><a name="heading-publish-your-arrow-project">Publish Your Arrow Project</a></h2><p>Once you are ready to deploy your project to production, you simply type:</p>
<pre class="highlight shell">appc publish</pre><p>from the home directory of your Arrow project, and it will be deployed to the Arrow Cloud. You will be given a production URL for your project.  The screenshot below shows the result of an <code>appc publish</code> command.</p>
<p><img class="shadow" src="images/cloud_deploy.png" /></p>
