Note: The project directory and artifact names still use the legacy "user-reporting" naming from a previous iteration. The more accurate name reflecting the current project scope is str-reporting.
- STR Reporting Application
MONGO_ROOT_USERNAME=root
MONGO_ROOT_PASSWORD=examplepassword
MONGO_DATABASE=strTxnDB
MONGO_CONNECTION_STRING=mongodb://${MONGO_ROOT_USERNAME}:${MONGO_ROOT_PASSWORD}@mongodb:27017/${MONGO_DATABASE}?authSource=adminNote: More env variables may be configured in docker compose
-
Build and run the api and mongodb containers
docker-compose up --build -d
This container automatically runs the initialization script to load mock data.
-
Navigate to the Angular app directory and run:
pnpm start
The angular dev server is configured to proxy requests to the api
- MongoDB Atlas cluster created and accessible.
- Configure MongoDB Atlas to use your certificate authority to issue/verify certificates
- X.509 client certificate (
./certs/client.pem) provisioned and mapped to a MongoDB$externaluser with at leastreadWriteonstrTxnDB. - MongoDB Shell (
mongosh) and mongoimport tool installed.
mongosh "mongodb+srv://sandbox.tuank.mongodb.net/strTxnDB?authSource=%24external&authMechanism=MONGODB-X509" --apiVersion 1 --tls --tlsCertificateKeyFile .\certs\client.pemmongoimport --uri "mongodb+srv://sandbox.tuank.mongodb.net/strTxnDB"
--authenticationDatabase="$external" --authenticationMechanism=MONGODB-X509
--ssl --sslPEMKeyFile=./certs/client.pem
--collection strTxns --file data/MOCK_DATA_cashDepositComplete.json
--jsonArraymongoimport --uri "mongodb+srv://sandbox.tuank.mongodb.net/strTxnDB"
--authenticationDatabase="$external" --authenticationMechanism=MONGODB-X509
--ssl --sslPEMKeyFile=./certs/client.pem
--collection strTxns --file data/MOCK_DATA_cashWithdrawalComplete.json
--jsonArrayBefore running the production containers, you need to generate and configure TLS certificates:
-
Generate Server (mongodb) Certificate
openssl genrsa -out server.key 4096 openssl req -new -key server.key -out server.csr -config ./server.cnf -extensions req_ext openssl x509 -req -in server.csr -CA certs/ca.pem -CAkey certs/ca.key -CAcreateserial -out server.crt -days 365 -extfile ./server.cnf -extensions req_ext cat server.crt server.key > mongodb.pem mv mongodb.pem certs/ -
Generate Client (dotnetapi) Certificate
openssl genrsa -out client.key 4096 openssl req -new -key client.key -out client.csr -config ./client.cnf -extensions req_ext openssl x509 -req -in ./client.csr -CA ./certs/ca.pem -CAkey ./certs/ca.key -CAcreateserial -out client.crt -days 365 -extfile ./client.cnf -extensions req_ext cat client.key client.crt > client.pem mv client.pem certs/
These certificate files are used to enable TLS in MongoDB and secure client-server communication.
A Certificate Authority (CA) is required to sign/verify server and client certificates. Production deployments should use a dedicated CA.
-
Generate CA Private Key
openssl genrsa -out ca.key 4096 mv ca.key certs/
-
Generate CA Certificate
openssl req -x509 -new -key ca.key -out ca.pem -days 3650 -subj "/CN=MongoRootCA" mv ca.pem certs/
Use Docker Compose to build and deploy the full stack:
docker-compose -f docker-compose.prod.yml up --build -dYou can manually verify the MongoDB TLS setup using mongosh:
mongosh strTxnDB --tls \
--tlsCertificateKeyFile certs/client.pem \
--tlsCAFile certs/ca.pem \
--host localhost --port 27018 \
-u root -p examplepassword \
--authenticationDatabase admin-
ENV Variables
MONGO_ROOT_USERNAME=sandbox.tuank.mongodb.net MONGO_DATABASE=strTxnDB MONGO_CONNECTION_STRING=mongodb+srv://${MONGO_ROOT_USERNAME}/${MONGO_DATABASE}?authSource=%24external&authMechanism=MONGODB-X509 CLIENT_PEM_BASE64=asdf=
-
Pass your client PEM certificate as a base64-encoded environment variable (CLIENT_PEM_BASE64) into the Docker container.
base64 certs/client.pem | tr -d '\n' > certs/client.pem.base64
-
The container's entrypoint.sh script will:
- Decode the base64 string.
- Write the PEM file to /etc/ssl/client.pem during container startup.
- Apply strict file permissions (chmod 600) to enhance security.
- MongoDB Initialization
- Preloaded with sample transaction data
- Automatic schema initialization
- Angular Frontend
- Edit forms with custom directives
- Data table components
- Cross-tab editing prevention
- .NET API
- Session management
- STR transaction operations
- Production-Ready
- Containerized deployment
- Environment-based configuration
clear-field- Clears input fieldscontrol-toggle- Toggles form controlstransaction-date- Date formattingtransaction-time- Time formatting