# Software Architecture: Transaction

+ Implement `client-side` logics of transaction
  + On **`Begin`**: Generate a logical **`"snapshot"`** by specified **`"start-ts"`**
  + On **`Get/BatchGet/Iter/IterReverse`**
    + Acquire data from `TiKV` on **`"start-ts"`** and save in local memory buffer
    + Resolve locks when facing locked keys
  + On **`Set/Delete`**: Mutate local memory buffer
  + On **`Commit`**:
    + Try **`1PC`** ***[if all keys in one region]***
    + Try **`Async Commit`** ***[if `len(keys) <= 256 && size(keys) <= 4KB`]***
    + Perform **`2PC`**
    + Refer to ***Transaction*** training module for more details

![`smart`](TiVKClientInterfaces_aa_001_20221027.png)

------------------------------------------------------------

