You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82-7Lines changed: 82 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@
16
16
# Carbon Registry
17
17
The National Carbon Registry enables carbon credit trading in order to reduce greenhouse gas emissions.
18
18
19
-
As an online database, the National Carbon Registry uses standards national and international standards for quantifying and verifying greenhouse gas emissions reductions of programmes, tracking issued carbon credits and enabling credit transfers in an efficient and transparent manner. The Registry functions by receiving, processing, recording and storing data on mitigations projects, the issuance, holding, transfer, acquisition, cancellation, and retirement of emission reduction credits. This information is publicly accessible to increase public confidence in the emissions reduction agenda.
19
+
As an online database, the National Carbon Registry uses national and international standards for quantifying and verifying greenhouse gas emissions reductions by programmes, tracking issued carbon credits and enabling credit transfers in an efficient and transparent manner. The Registry functions by receiving, processing, recording and storing data on mitigations projects, the issuance, holding, transfer, acquisition, cancellation, and retirement of emission reduction credits. This information is publicly accessible to increase public confidence in the emissions reduction agenda.
20
20
21
21
The National Carbon Registry enables carbon credit tracking transactions from mitigation activities, as the digital implementation of the Paris Agreement. Any country can customize and deploy a local version of the registry then connect it to other national & international registries, MRV systems, and more.
22
22
@@ -34,8 +34,83 @@ https://digitalprinciples.org/
34
34
35
35
<aname="architecture"></a>
36
36
## System Architecture
37
-
UNDP Carbon Registry based on Serverless Architecture. It can be ported and hosted on any Function As A Service (FaaS) stack.
As per the above diagram, system contains 4 main services.
41
+
42
+
<aname="services"></a>
43
+
### **Services**
44
+
#### *National Service*
45
+
46
+
Authenticate, Validate and Accept user (Government, Programme Developer/Certifier) API requests related to the following functionalities,
47
+
- User and company CRUD operations.
48
+
- User authentication.
49
+
- Programme life cycle management.
50
+
- Credit life cycle management.
51
+
52
+
Service is horizontally scalable and state maintained in the following locations,
53
+
- File storage.
54
+
- Operational Database.
55
+
- Ledger Database.
56
+
57
+
Uses the Carbon Credit Calculator and Serial Number Generator node modules to estimate the programme carbon credit amount and issue a serial number.
58
+
Uses Ledger interface to persist programme and credit life cycles.
59
+
60
+
#### *Analytics Service*
61
+
Serve all the system analytics. Generate all the statistic using the operational database.
62
+
Horizontally scalable.
63
+
64
+
#### *Replicator Service*
65
+
Replicate ledger database new items to a operational database asynchronously. During the replication process it injects additional query information to the data.
66
+
The current setup uses AWS QLDB as the ledger database. When it creates or updates data, the change is added to a AWS Kinesis Data Stream and the Replicator service consumes the stream.
67
+
68
+
#### *Operational Service*
69
+
Service that use to do following system operations,
70
+
1. Data migrations.
71
+
2. User data creation and update.
72
+
3. Resource creation.
73
+
74
+
Internal service. Cannot be invoked by external sources.
75
+
76
+
### **Database Architecture**
77
+
Primary/secondary database architecture used to store carbon programme and account balances.
78
+
Ledger database is the primary database. Add/update programmes and update account balances in a single transaction. Currently implemented only for AWS QLDB
79
+
80
+
Operational Database is the secondary database. Eventually replicated to this from primary database via data stream. Implemented based on PostgresSQL
81
+
82
+
**Why Two Database Approach?**
83
+
1. Cost and Query capabilities - Ledger database (blockchain) read capabilities can be limited and costly. To support rich statistics and minimize the cost, data is replicated in to a cheap query database.
84
+
2. Disaster recovery
85
+
3. Scalability - Primary/secondary database architecture is scalable since additional secondary databases can be added as needed to handle more read operations.
86
+
87
+
**Why Ledger Database?**
88
+
1. Immutable and Transparent - Track and maintain a sequenced history of every carbon programme and credit change.
89
+
2. Data Integrity (Cryptographic verification by third party).
90
+
3. Reconcile carbon credits and company account balance.
91
+
92
+
**Ledger Database Interface**
93
+
94
+
This enables the capability to add any blockchain or ledger database support to the carbon registry without functionality module changes. Currently the production system interface is implemented for AWS QLDB. For testing purposes the interface is implemented for PostgresSQL as well.
95
+
96
+
97
+
98
+
Single database approach used for user and company management.
99
+
100
+
101
+
### **Ledger Layout**
102
+
Carbon Registry contains 3 ledger tables.
103
+
1. Programme ledger - Contains all the programme and credit transactions.
104
+
2. Company Account Ledger (Credit) - Contains company accounts credit transactions.
105
+
3. Country Account Ledger (Credit) - Contains country credit transactions.
106
+
107
+
The below diagram demonstrates the the ledger behavior of programme create, authorise, issue and transfer processes. Blue color document icon denotes a single data block in a ledger.
108
+
109
+

110
+
111
+
### **Authentication**
112
+
- JWT Authentication - All endpoints based on role permissions.
113
+
- API Key Authentication - MRV System connectivity.
39
114
40
115
<aname="structure"></a>
41
116
## Project Structure
@@ -63,7 +138,7 @@ UNDP Carbon Registry based on Serverless Architecture. It can be ported and host
63
138
<aname="local"></a>
64
139
## Run Services Locally
65
140
- Setup postgreSQL locally and create a new database.
66
-
- Update following DB configurations in the .env.local file (If file does not exist please create a new .env.local)
141
+
- Update following DB configurations in the .env.local file (If the file does not exist please create a new .env.local)
67
142
- DB_HOST (Default localhost)
68
143
- DB_PORT (Default 5432)
69
144
- DB_USER (Default root)
@@ -73,7 +148,7 @@ UNDP Carbon Registry based on Serverless Architecture. It can be ported and host
73
148
- Run `yarn run sls:install `
74
149
- Initial user data setup `serverless invoke local --stage=local --function setup --data '{"rootEmail": "<Root user email>","systemCountryCode": "<System country Alpha 2 code>", "name": "<System country name>", "logoBase64": "<System country logo base64>"}'`
75
150
- Start all the services by executing `sls offline --stage=local`
76
-
- Now all the system services are up and running. Swagger documentation will be available on `http://localhost:3000/local/api/national/docs#/`
151
+
- Now all the system services are up and running. Swagger documentation will be available on `http://localhost:3000/local/national`
77
152
78
153
<aname="cloud"></a>
79
154
## Deploy System on the AWS Cloud
@@ -108,7 +183,7 @@ Serial Number generation implemented in a separate node module. [Please refer th
108
183
## User Onboarding and Permissions Model
109
184
110
185
### User Roles
111
-
System pre-defined user roles as follows,
186
+
System pre-defined user roles are as follows,
112
187
- Root
113
188
- Company Level (National Government, Programme and Certification Company come under this level)
114
189
- Admin
@@ -125,7 +200,7 @@ System pre-defined user roles as follows,
125
200
126
201
### User Management
127
202
128
-
All the CRUD operations can perform as per the following table,
203
+
All the CRUD operations can be performed as per the following table,
129
204
130
205
| Company Role | New User Role | Authorized User Roles (Company) |
0 commit comments