# Complete the example · Your first Rell app on Chromia · Learn Chromia

> Next, you finish the client so you can exercise the remaining functions.

Source: https://chromia.com/learn/book-review/build-client/complete-example/

Your first Rell app on ChromiaLesson 25 of 26

1. [01Your first Rell app on Chromia](https://chromia.com/learn/book-review/introduction/)
2. [02Set up your project](https://chromia.com/learn/book-review/setup/)
3. [03Rell project structure](https://chromia.com/learn/book-review/rell-structure/)

Part 1: Define your first entity

1. [04Overview](https://chromia.com/learn/book-review/book-entity/)
2. [05Create your first entity](https://chromia.com/learn/book-review/book-entity/tables/)
3. [06Add your first operation](https://chromia.com/learn/book-review/book-entity/basic-operations/)
4. [07Query every book](https://chromia.com/learn/book-review/book-entity/write-queries/)

Part 2: Add a related entity

1. [08Overview](https://chromia.com/learn/book-review/book-review-entity/)
2. [09Define the book review entity](https://chromia.com/learn/book-review/book-review-entity/tables/)
3. [10Add an operation for creating book reviews](https://chromia.com/learn/book-review/book-review-entity/basic-operations/)
4. [11Query all reviews for a book](https://chromia.com/learn/book-review/book-review-entity/write-queries/)

Part 3: Checking and validating inputs

1. [12Overview](https://chromia.com/learn/book-review/input-verification/)
2. [13Verify inputs](https://chromia.com/learn/book-review/input-verification/input-verification/)
3. [14Return structured results from queries](https://chromia.com/learn/book-review/input-verification/structure/)

Part 4: Signing transactions and filtering queries

1. [15Overview](https://chromia.com/learn/book-review/sign-transaction/)
2. [16Sign a transaction](https://chromia.com/learn/book-review/sign-transaction/sign-transaction/)
3. [17Filter and sort query results](https://chromia.com/learn/book-review/sign-transaction/structure/)

Part 5: Blockchain state and transactions explained

1. [18Overview](https://chromia.com/learn/book-review/blockchain-transactions/)
2. [19How blockchain state and transactions work](https://chromia.com/learn/book-review/blockchain-transactions/query-transaction/)
3. [20Walking through an example](https://chromia.com/learn/book-review/blockchain-transactions/example/)

Part 6: Create the client

1. [21Overview](https://chromia.com/learn/book-review/build-client/)
2. [22Prerequisites](https://chromia.com/learn/book-review/build-client/prerequisites/)
3. [23Establishing a connection to Chromia](https://chromia.com/learn/book-review/build-client/sign-transaction/)
4. [24Query the blockchain using postchain-client](https://chromia.com/learn/book-review/build-client/query-blockchain/)
5. [25Complete the example](https://chromia.com/learn/book-review/build-client/complete-example/)

1. [26What’s next?](https://chromia.com/learn/book-review/what-next/)

[Learn](https://chromia.com/learn/)[Your first Rell app on Chromia](https://chromia.com/learn/book-review/)

25 / 26Part 6: Create the clientBeginner

# Complete the example

Next, you finish the client so you can exercise the remaining functions.

First, declare the last type required to query book reviews:

typescript

```
type BookReview = {
  book: Book;
  reviewer_name: string;
};
```

Then add the functions that query entities, along with a few helpers that read user input:

typescript

```
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

function getInput(query: string): Promise<string> {
  return new Promise((resolve) => {
    rl.question(query, (answer) => {
      resolve(answer);
    });
  });
}

const getReviewsForBook = async (isbn: string) => {
  const bookList = await client.query<BookReview[]>("get_all_reviews_for_book", { isbn: isbn });
  console.log("Book review list\n", bookList);
};

const getAllTransactions = async () => {
  const transactions = await client.query("get_transactions", {});

  console.dir(transactions, {
    depth: null,
    customInspect: true, // This forces Buffer to use hex string output
  });
};
```

Finally, here is the complete `main` function. It adds the calls that create books and reviews and retrieve data:

typescript

```
async function main() {
  client = await createClient({
    nodeUrlPool: "http://localhost:7740",
    blockchainRid: blockchainRID,
  });

  console.log("Creating a new book transaction");
  await client.signAndSendUniqueTransaction(
    { name: "create_book", args: ["ISBN1", "Chromia 101", "John Doe"] },
    bookKeeperSignatureProvider
  );
  await getInput("Transaction committed!\nPress any key to continue...");

  console.log("Let's fetch and view all books currently in the node");
  await getAllBooks();
  await getInput("Press any key to continue...");

  console.log("We can now add a second book");
  await client.signAndSendUniqueTransaction(
    { name: "create_book", args: ["ISBN2", "Rell 101", "Jane Doe"] },
    bookKeeperSignatureProvider
  );
  await getInput("Transaction committed, press any key to continue...");

  console.log("Let's fetch and view all books currently in the node");
  await getAllBooks();
  await getInput("Press any key to continue...");

  console.log("We can now add two reviews for the book with ISBN = ISBN2");

  await client.signAndSendUniqueTransaction(
    {
      name: "create_book_review",
      args: ["ISBN2", "Bob Doe", "This is a great book!", 5],
    },
    bookKeeperSignatureProvider
  );
  await client.signAndSendUniqueTransaction(
    {
      name: "create_book_review",
      args: ["ISBN2", "Charlie Doe", "It was ok!", 3],
    },
    bookKeeperSignatureProvider
  );
  await getInput("Transaction committed, press any key to continue...");

  console.log("Let's fetch and view all reviews for ISBN2");
  await getReviewsForBook("ISBN2");
  await getInput("Press any key to continue...");

  console.log("Now let's look at all transactions that have been committed to the blockchain");
  await getAllTransactions();
  await getInput("Press any key to continue...");
  rl.close();
}
```

You now have a working example of a front-end client built with Chromia and `postchain-client`.

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**Query the blockchain using postchain-client**](https://chromia.com/learn/book-review/build-client/query-blockchain/)[Next →**What’s next?**](https://chromia.com/learn/book-review/what-next/)
