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
Authenticate, Validate and Accept user (Government, Programme Developer/Certifier) API requests related to the following functionalities,
@@ -58,20 +58,42 @@ Uses the Carbon Credit Calculator and Serial Number Generator node modules to es
58
58
Uses Ledger interface to persist programme and credit life cycles.
59
59
60
60
#### *Analytics Service*
61
-
Serve all the system analytics. Generate all the statistic using the operational database.
61
+
Serve all the system analytics. Generate all the statistics using the operational database.
62
62
Horizontally scalable.
63
63
64
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.
65
+
Asynchronously replicate ledger database events in to the operational database. During the replication process it injects additional information to the data for query purposes (Eg: Location information).
66
+
Currently implemented for QLDB and PostgresSQL ledgers. By implementing [replicator interface](./backend/services/src/ledger-replicator/replicator-interface.service.ts) can support more ledger replicators.
67
+
Replicator select based on the `LEDGER_TYPE` environment variable. Support types `QLDB`, `PGSQL(Default)`.
68
+
69
+
### **Deployment**
70
+
System services can deploy in 2 ways.
71
+
-**As a Container** - Each service boundary containerized in to a docker container and can deploy on any container orchestration service. [Please refer Docker Compose file](./docker-compose.yml)
72
+
-**As a Function** - Each service boundary packaged as a function (Serverless) and host on any Function As A Service (FaaS) stack. [Please refer Serverless configuration file](./backend/services/serverless.yml)
73
+
74
+
75
+
### **External Service Providers**
76
+
All the external services access through a generic interface. It will decouple the system implementation from the external services and enable extendability to multiple services.
77
+
78
+
**Geo Location Service**
67
79
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.
80
+
Currently implemented for 2 options.
81
+
1. File based approach. User has to manually add the regions with the geo coordinates. [Sample File](./backend/services/regions.csv). To apply new file changes, replicator service needs to restart.
82
+
2.[Mapbox](https://mapbox.com). Dynamically query geo coordinates from the Mapbox API.
73
83
74
-
Internal service. Cannot be invoked by external sources.
84
+
Can add more options by implementing [location interface](./backend/services/src/shared/location/location.interface.ts)
85
+
86
+
Change by environment variable `LOCATION_SERVICE`. Supported types `MAPBOX`, `FILE(Default)`
87
+
88
+
**File Service**
89
+
90
+
Implemented 2 options for static file hosting.
91
+
1. NestJS static file hosting using the local storage and container volumes.
92
+
2. AWS S3 file storage.
93
+
94
+
Can add more options by implementing [file handler interface](./backend/services/src/shared/file-handler/filehandler.interface.ts)
95
+
96
+
Change by environment variable `FILE_SERVICE`. Supported types `S3`, `LOCAL(Default)`
75
97
76
98
### **Database Architecture**
77
99
Primary/secondary database architecture used to store carbon programme and account balances.
@@ -91,8 +113,9 @@ Operational Database is the secondary database. Eventually replicated to this fr
91
113
92
114
**Ledger Database Interface**
93
115
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.
116
+
This enables the capability to add any blockchain or ledger database support to the carbon registry without functionality module changes. Currently implemented for PostgresSQL and AWS QLDB.
95
117
118
+
**PostgresSQL Ledger Implementation** storage all the carbon programme and credit events in a separate event database with the sequence number. Support all the ledger functionalities except immutability.
96
119
97
120
98
121
Single database approach used for user and company management.
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
131
109
-

132
+

110
133
111
134
### **Authentication**
112
135
- JWT Authentication - All endpoints based on role permissions.
@@ -118,13 +141,11 @@ The below diagram demonstrates the the ledger behavior of programme create, auth
118
141
.
119
142
├── .github # CI/CD [Github Actions files]
120
143
├── deployment # Declarative configuration files for initial resource creation and setup [AWS Cloudformation]
121
-
├── lambda # System service implementation [NestJS applications, Serverless + AWS Lambda]
122
-
├── layer # Service dependency layer [AWS Lambda Layers]
- Update [docker compose file](./docker-compose.yml) env variables as required.
163
+
- Run `docker-compose up -d`. This will build and start containers for following services,
164
+
- PostgresDB container
165
+
- National service
166
+
- Analytics service
167
+
- Replicator service
168
+
- React web server with Nginx.
169
+
138
170
<aname="local"></a>
139
171
## Run Services Locally
140
172
- Setup postgreSQL locally and create a new database.
@@ -144,7 +176,7 @@ The below diagram demonstrates the the ledger behavior of programme create, auth
144
176
- DB_USER (Default root)
145
177
- DB_PASSWORD
146
178
- DB_NAME (Default carbondbdev)
147
-
- Move to folder `cd lambda/service`
179
+
- Move to folder `cd backend/service`
148
180
- Run `yarn run sls:install `
149
181
- 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>"}'`
150
182
- Start all the services by executing `sls offline --stage=local`
0 commit comments