Skip to content

Simple payment application utilizing Monorepo codebase architecture and Microservice deployment architecture.

License

Notifications You must be signed in to change notification settings

pesfahanian/django-monorepo-microservice

Repository files navigation

Django Monorepo Microservice

Simple payment application utilizing Monorepo codebase architecture and Microservice deployment architecture.

The Monorepo codebase architecture was achieved without using any of the traditional build tools (e.g. Bazel, Pants).


Services

Wallet:

  • Simple CRUD operations
  • Deposit and withdraw features
  • Functionalities:
    • Database
    • REST API
    • Admin panel
    • Async events
    • gRPC communication

Ledger:

  • Double-entry ledger
  • Simple transaction journal
  • Functionalities:
    • Database
    • Admin panel
    • Async events

PG (Payment-Gateway):

  • Bank API proxy middleman.
  • Functionalities:
    • Ephemeral
    • gRPC communication

Glossary

Service Admin Swagger
rabbitmq 0.0.0.0:15672 -
ledger 0.0.0.0:8201/admin/ -
wallet 0.0.0.0:8200/admin/ 0.0.0.0:8200/swagger/

Usage

Before anything, generate a JWT RS256 key-pair:

./scripts/keygen.sh

Deployment

Make sure you have Docker and Docker Compose installed.

Build and start the services:

docker compose up

If any of the service builds fail, try manually building with docker build -t dmm/<SERVICE> -f docker/<SERVICE>.Dockerfile .


Development

Make sure you have Python 3.11.2 installed.

You also need to have PostgreSQL and RabbitMQ installed and running on your system.

Make all the .sh files executable:

find . -type f -iname "*.sh" -exec chmod +x {} \;

Create and activate a virtual environment:

python -m venv .venv
source .venv/bin/activate

Install all the requirements:

./scripts/install.sh --all

To also additionally install the development requirements, use the --develop or -D flag.

To install the requirements of only one service, run ./scripts/install.sh <SERVICE NAME>

Generate gRPC codes:

./scripts/codegen.sh

Run migrations for all services:

./scripts/manage.sh --all migrate

This will perform migrations for the wallet and ledger services.

To run migrations for only one service, run ./scripts/manage.sh <SERVICE NAME> migrate


Testing

- Wallet Creation

Get a valid UUID for userID from uuidgenerator.net.

Either run the following command:

./scripts/manage.sh wallet createwallet <userID>

or go to 0.0.0.0:8200/admin/wallet/wallet/add/ and manually create a wallet record.

In deployment, you need to inspect into the dmm-wallet container for running the command.

- Token Generation

With the userID of an existing Wallet, run the following command:

./scripts/manage.sh wallet generatetoken <userID>

You also need to inspect into the dmm-wallet container for running this command in deployment.

API

Import the collection at docs/dmm.postman_collection.json into Postman.

Providing the success of Wallet Creation and using the token obtained from Token Generation, you can now test the APIs.

About

Simple payment application utilizing Monorepo codebase architecture and Microservice deployment architecture.

Resources

License

Stars

Watchers

Forks