---
# System prepended metadata

title: PaperTrail/AuditDB

---

# PaperTrail/AuditDB
![](https://i.imgur.com/Aao8yuC.png)

## Explanation
Papertrail/AuditDB will work using Three Segments
- dbwrappersMap [independant]
- maindb [independant]
- singledb [dependant on maindb]

### DbwrappersMap
- Initiated Once
- from dbwrapper package
- signature : map[string]*dbwrapper
- uses db path as key, and dbwrapper is created using path
    - ex : [some-root/001.db] = *dbwrapper{dbpath:some-root/001.db}

### MainAuditDB
- Created like all others (webserver,backup...)
- Has Logics to generate dbwrapper for valid dates,using Config,Current &DateRanges DB
- It Uses Dbwrappers Map to create dbwrapper for single DB

### SingleDB
- Takes MainAuditDB Api as dependency
- Doesn't know which db to use
- Takes Dbwrapper from MainDB Api


## Flow
- MainDBCreated
- SingleDBCreated Using MainDbApi
- SingleDB Calls For Current DBWrapper
- MainDB Detemines If The Current Cached Table is valid, if not then updates, generates the absolute path and gets dbwrapper from calling DbwrappersMap
- DbwrappersMap checks if it already has dbwrapper for the path provided, if not created using path
- Finally the singledb has the dbwrapper
- It can do crud operations

###### Note : We will be using caching strategies to make things faster, already work in progress.