┌──────┐ ┌───────┐ ┌─────┐ ┌────────┐ │Entity│ │Kotlinx│ │Codec│ │Database│ └──────┘ └───────┘ └─────┘ └────────┘ │ │ │ │ │ ╔╧════════════════════════════════════════════╧═════╗ │ ═════════╪════════════════════════════════════════════╣ Sending to Db if @Serialized is missing on entity ╠═══════════════════════════════════════════╪══════════ │ ╚╤════════════════════════════════════════════╤═════╝ │ │ │ │ │ │𝟏 Trying to serialize with kotlinx (missing) │ │ │ │────────────────────────────────────────────>│ │ │ │ │ │ │ │ 𝟐 Trying to serialize with registered codec (found) │ │ │─────────────────────────────────────────────────────────────────────────────────────────>│ │ │ │ │ │ │ │ │𝟑 Bson document sent to db adding _id if missing │ │ │ │────────────────────────────────────────────────>│ │ │ │ │ │ │ │ │ │ ╔═╧════════════════════════════════════════════╧══════╗ │ ═════════╪═══════════════════════════════════════════╣ Retrive from Db if @Serialized is missing on entity ╠══════════════════════════════════════════╪══════════ │ ╚═╤════════════════════════════════════════════╤══════╝ │ │ │ │ │ │ │ 𝟒 Trying to deserialize with kotlinx (missing) │ │ │<─────────────────────────────────────────────────────────────────────────────────────────────│ │ │ │ │ │ │ │ 𝟓 Trying to deserialize with codec (found) │ │ │ │<────────────────────────────────────────────────│ │ │ │ │ │ 𝟔 Bson document is converted to entity │ │ │<─────────────────────────────────────────────────────────────────────────────────────────│ │ │ │ │ │ │ │ │ │ │ ╔═╧════════════════════════════════════════════╧═════╗ │ ═════════╪═══════════════════════════════════════════╣ Sending to Db if @Serialized is attached on entity ╠═══════════════════════════════════════════╪══════════ │ ╚═╤════════════════════════════════════════════╤═════╝ │ │ │ │ │ │ 𝟕 Trying to serialize with kotlinx (found) │ │ │ │────────────────────────────────────────────>│ │ │ │ │ │ │ │ │ 𝟖 Plain json is sent to codec │ │ │ │───────────────────────────────────────────>│ │ │ │ │ │ │ │ │𝟗 Bson document sent to db adding _id if missing │ │ │ │────────────────────────────────────────────────>│ │ │ │ │ │ │ │ │ │ ╔══╧════════════════════════════════════════════╧══════╗ │ ═════════╪══════════════════════════════════════════╣ Retrive from Db if @Serialized is attached on entity ╠══════════════════════════════════════════╪══════════ │ ╚══╤════════════════════════════════════════════╤══════╝ │ │ │ │ │ │ │ 𝟏𝟎 Trying to deserialize with kotlinx (found) │ │ │<─────────────────────────────────────────────────────────────────────────────────────────────│ │ │ │ │ │ │𝟏𝟏 Trying to deserialize with codec (found) │ │ │ │───────────────────────────────────────────>│ │ │ │ │ │ │ 𝟏𝟐 Bson document is converted to entity │ │ │<─────────────────────────────────────────────────────────────────────────────────────────│ │ ┌──────┐ ┌───────┐ ┌─────┐ ┌────────┐ │Entity│ │Kotlinx│ │Codec│ │Database│ └──────┘ └───────┘ └─────┘ └────────┘