ruby/cross_service_examples/item_tracker/README.md
This example code comprises a "real-world" reference application showcasing an Amazon Aurora Serverless database using the AWS SDK for Ruby.
This code is written to be browsed in an exploratory manner. For a more hands-on experience, you can run the application by invoking this example code using the following instructions.
The code comprises an application designed to manage fictitious work items using three key components.
The centerpiece of this example is an API written exclusively in Ruby. It features the following gems:
This Ruby API consists of the following API routes:
| method | route | action | client | function |
|---|---|---|---|---|
| GET | /api/items | List items | RDSDataService | execute_statement(SQL) |
| POST | /api/items | Add item | RDSDataService | execute_statement(SQL) |
| PUT | /api/items:archive | Archive item | RDSDataService | execute_statement(SQL) |
| GET | /api/items/{item_id} | Get item | RDSDataService | execute_statement(SQL) |
| POST | /api/items:report | Create report | RDSDataService | execute_statement(SQL) |
The frontend code is written in JavaScript and implemented using the React framework. For more information, see the React Elwing Client README.
This example relies on a MySQL 5.7 database implemented using Amazon Aurora, a serverless relational database management system (RDBMS). The Aurora DB cluster is deployed using the AWS Cloud Development Kit (AWS CDK). For more information, see the Aurora Serverless App CDK script README.md.
To explore this example, you must first do the following:
Set up the AWS resources needed to run this example as follows:
env/config.yml file: CLUSTER_ARN, SECRET_ARN, and DATABASE.cd ruby/cross_service_examples/item-tracker/helpers
ruby create_table.rb # Checks for database and creates a new table.
ruby populate_data.rb # Creates a table with 10 records.
sender_email and recipient_email fields in your env/config.yml file.To view this example in its entirety, you must do the following:
cd resources/clients/elwing # Located within Resources sub-directory.
npm install # First time only.
npm start # Launches a browser session on localhost:3000.
cd ruby/cross_service_examples/item-tracker
ruby app.rb # Starts REST API listening on port 8080.
Now, visit http://localhost:3000/item_tracker to view your working application.
Test this application manually via the frontend or automatically via the RSpec tests.
After the app starts, manually validate the following behaviors on the frontend:
As you interact with the React app, logs will appear in the command line tab where you started the REST API.
Validate the internal logic within this example by running the following commands:
cd spec
rspec db_wrapper_spec.rb
To avoid charges, delete all the resources that you created for this tutorial. Follow the instructions in the Destroying resources section of the README for the Aurora Serverless sample application.