# FTL Demo In the demo we write a distributed invoicing service from scratch. It will utilise the following FTL features: 1. Verbs 2. Finite State Machines 3. PubSub 4. Cron jobs The goal is to illustrate just how simple it is to build a moderately complex distributed system with FTL. ## Design The invoicing system will consist of two main systems: 1. The FSM 2. The public API used to interact with the FSM The FSM will be: ```mermaid stateDiagram-v2 [*] --> InvoiceCreated: Invoice [*] --> InvoicePaid: Receipt InvoiceCreated --> InvoicePaid: Receipt InvoiceCreated --> InvoiceDefaulted: InvoiceTimeout ``` The public API will consist of the following functions: 1. `CreateInvoice()` - take an `Invoice` and deliver it to the FSM 2. `PayInvoice()` - take a `Receipt` and deliver it to the FSM There will also be a cron job, `TimeoutInvoice()`, that periodically checks for invoices that haven't been paid by the due date, and sends a `Defaulted` event to the FSM.