Skip to content

Development

MichaΕ‚ SzaΕ‚owski edited this page Feb 19, 2025 · 1 revision

GovTool Documentation

Development Stack Setup

To set up the development environment for GovTool, ensure you have the following dependencies installed:

Required Tools and Versions

  • GHC (Glasgow Haskell Compilation System): 9.4.8
  • Cabal (Haskell package manager): 3.10.3.0
  • Node.js: 20.18.1
  • NPM: 11.0.0
  • PostgreSQL (psql client): 17.2

Backend Setup

Building and Running the Backend

To build and run the backend, execute the following commands:

cabal build
cabal run vva-be -- config config.json start-app

Explanation of the Command:

  • cabal run vva-be – Runs the Haskell backend application named vva-be.
  • config config.json – Specifies the configuration file to be used (config.json).
  • start-app – Instructs the application to start the backend server.

Configuration File

The config.json file should be based on example-config.json in the same directory and should include the following fields:

{
  "dbsyncconfig": {
    "host": "localhost",
    "dbname": "cexplorer",
    "user": "postgres",
    "password": "postgres",
    "port": 5432
  },
  "port": 9999,
  "host": "localhost",
  "cachedurationseconds": 20,
  "sentrydsn": "https://username:[email protected]/id",
  "sentryenv": "dev"
}

Configuration Parameters:

  • dbsyncconfig – PostgreSQL connection settings used by the backend:
    • host – Database server hostname (default: localhost)
    • dbname – Database name (default: cexplorer)
    • user – Database username (default: postgres)
    • password – Database password (default: postgres)
    • port – Database port (default: 5432)
  • port – Port on which the backend server runs (default: 9999).
  • host – Host address for the backend (default: localhost).
  • cachedurationseconds – Time duration for caching data (default: 20 seconds).
  • sentrydsn – Sentry DSN URL for error tracking.
  • sentryenv – Environment label for Sentry (dev for development, prod for production).

Frontend Setup

Installing Dependencies and Running the Frontend

To set up the frontend, execute the following commands:

npm install
npm run dev

Environment Variables

Before running the frontend, ensure the appropriate environment variables are set based on an environment file:

VITE_APP_ENV="development"
VITE_BASE_URL=""
VITE_METADATA_API_URL=""
VITE_NETWORK_FLAG=0
VITE_SENTRY_DSN=""
VITE_GTM_ID=""
VITE_IS_DEV=true
VITE_USERSNAP_SPACE_API_KEY=""
VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED='true'
VITE_IS_GOVERNANCE_OUTCOMES_PILLAR_ENABLED='true'
VITE_PDF_API_URL=""
VITE_IPFS_GATEWAY=""
VITE_IPFS_PROJECT_ID=""

Explanation of Environment Variables:

  • VITE_APP_ENV – Defines the environment for Sentry reporting (e.g., development, production).
  • VITE_BASE_URL – API URL for the core Haskell backend.
  • VITE_METADATA_API_URL – API URL for the validation service.
  • VITE_NETWORK_FLAG – Determines network type:
    • 0 – Testnets
    • 1 – Mainnet
  • VITE_SENTRY_DSN – DSN for Sentry error tracking.
  • VITE_GTM_ID – Google Tag Manager ID.
  • VITE_IS_DEV – Enables/disables development-specific features (true for development mode).
  • VITE_USERSNAP_SPACE_API_KEY – API key for Usersnap (bug reporting and feedback tool).
  • VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED – Feature flag for enabling/disabling the proposal discussion forum.
  • VITE_IS_GOVERNANCE_OUTCOMES_PILLAR_ENABLED – Feature flag for enabling/disabling the governance outcomes pillar.
  • VITE_PDF_API_URL – API URL for the proposal discussion pillar.
  • VITE_IPFS_GATEWAY – URL for the IPFS gateway.
  • VITE_IPFS_PROJECT_ID – Project ID for IPFS.

Metadata Validation Service Setup

Installing Dependencies and Running the Service

To set up the metadata validation service, execute the following commands:

npm install
npm run start:dev

Environment Variables

Before running the metadata validation service, set the following environment variables:

PORT=3000
IPFS_GATEWAY=https://ipfs.some.gateway
IPFS_PROJECT_ID=ipfsprojectid

Explanation of Environment Variables:

  • PORT – Port on which the metadata validation service runs (default: 3000).
  • IPFS_GATEWAY – URL of the IPFS gateway used for fetching metadata.
  • IPFS_PROJECT_ID – Project ID required to authenticate with the IPFS gateway.

Running the Full System

With all three services running:

  • Frontend should set VITE_BASE_URL to the running Haskell backend API URL.
  • Frontend should set VITE_METADATA_API_URL to the running metadata validation service API URL.