Dev Env Setup
for API and Client Apps
Configuration for your local or codespaces development environment.
Prerequisites
- GitHub account with access to this repository.
Addnl Prereq for Local Dev
- Git
- Docker and Docker Compose
- Visual Studio Code
- Visual Studio Code Remote - Containers extension
- Node.js and npm
Dev Env Setup
Local Development
-
Clone the repository:
git clone https://github.com/Great-Sun-Group/credex-core.git
cd credex-core
-
Create a
.env
file in the root of the project based on
.env.example
and fill in the required environment variables
(see below).
-
git checkout -b new-branch-name
to start local development
Using Devcontainers with VS Code
Devcontainers provide a consistent, reproducible development environment
across different machines. This project is set up to use devcontainers,
which encapsulate the development environment in a Docker container.
To use devcontainers:
-
Ensure you have the "Remote - Containers" extension installed in VS
Code.
- Open the project folder in VS Code.
-
When prompted, click "Reopen in Container" or use the command palette
(F1) and select "Remote-Containers: Reopen in Container".
-
VS Code will build the devcontainer (this may take a few minutes the
first time) and open the project inside the container.
GitHub Codespaces
-
Go to your personal GitHub Settings -> Codespaces and Add New Secret for
each secret listed below, giving it access to the credex-core
repository.
-
Go to the main page of the credex-core repository (dev branch), and
create a new branch from dev, or from the branch of the project you are
contributing to.
-
Within the new branch, click on the "Code" button, select the
"Codespaces" tab, and click "Create codespace on new-branch-name".
-
The Codespace will automatically set up the environment within the
devcontainer.
Benefits of Devcontainers
-
Consistent development environment across team members and hardware
- Easy onboarding for new developers
- Isolation from the host system
- Pre-configured development tools and extensions
Locally, you can use VS Code's "Attach to Running Container" feature to
work within the Docker container, or use docker exec
to
access the container's shell.
Environment Variables
NEO_4J_LEDGER_SPACE_BOLT_URL
NEO_4J_LEDGER_SPACE_PASS
NEO_4J_LEDGER_SPACE_USER
NEO_4J_SEARCH_SPACE_BOLT_URL
NEO_4J_SEARCH_SPACE_PASS
NEO_4J_SEARCH_SPACE_USER
-
To set up Neo4j Aura databases:
-
Go to https://neo4j.com/cloud/aura/ and sign up for two separate
accounts using different email addresses.
-
For each account, create a new database instance. One should be name
ledgerSpace and the other searchSpace.
-
Once the databases are created, you'll be provided with connection
details.
-
Use the Bolt URL, username, and password for each database to fill
in the corresponding environment variables.
-
The LEDGER_SPACE variables correspond to one database, and the
SEARCH_SPACE variables to the other.
OPEN_EXCHANGE_RATES_API
-
To get this secret from Open Exchange Rates:
-
Go to https://openexchangerates.org/ and sign up for an account.
- Once logged in, navigate to your account dashboard.
- Look for your App ID or API Key.
-
Copy this key and use it as the value for OPEN_EXCHANGE_RATES_API.
JWT_SECRET
- Create your own unique random string for signing JWT tokens
- This should be a long, complex string to ensure security
-
Keep this secret secure as it's used to verify authentication tokens
CLIENT_API_KEY
- Create your own unique random string
-
This key is required for accessing the /login and /onboardMember
endpoints
-
In production, this is used to ensure only authorized clients (like the
WhatsApp chatbot) can create and authenticate members
- For development, you can create any random string
For development environments, the NODE_ENV
variable defaults
to 'development'.