Skip to content

Latest commit

 

History

History
201 lines (145 loc) · 4.06 KB

File metadata and controls

201 lines (145 loc) · 4.06 KB

DefiFundr Setup Guide

This guide will help you set up your development environment for contributing to DefiFundr.

Prerequisites

Before you begin, make sure you have the following installed:

Initial Setup

  1. Clone the repository:

    git clone https://github.com/your-org/defifundr.git
    cd defifundr
  2. Install required development tools:

    make install-tools

    This command installs:

    • air - Live reload for Go applications
    • goose - Database migration tool
    • sqlc - SQL compiler for Go
    • mockgen - Mock generation for testing
    • golangci-lint - Linting tool for Go
  3. Set up environment variables:

    cp .env.example .env

    Edit the .env file to configure your development environment. At minimum, set:

    • DB_SOURCE - Database connection string
    • JWT_SECRET - Secret key for JWT tokens
    • ETHEREUM_RPC_URL - Ethereum node URL

Database Setup

  1. Start a PostgreSQL container:

    make postgres
  2. Create the database:

    make createdb
  3. Run migrations to set up the schema:

    make migrate-up
  4. (Optional) Seed the database with test data:

    make seed

Smart Contract Setup

  1. Generate Go bindings for smart contracts:

    make gencontract

    This compiles the Solidity contracts and generates Go interfaces.

Running the Application

  1. Start all required Docker containers:

    make docker-up
  2. Generate SQL code:

    make sqlc
  3. Start the API server:

    # Option 1: Standard mode
    make server
    
    # Option 2: Hot reload mode (recommended for development)
    make air
  4. Generate API documentation:

    make swagger

    Access the Swagger UI at http://localhost:8080/swagger/index.html

Verifying Your Setup

  1. Check that the database is running:

    make docker-ps
  2. Verify database migrations are applied:

    make migrate-status
  3. Run tests to ensure everything is working:

    make test

Development Workflow

Once your environment is set up, follow this workflow for development:

  1. Create a feature branch:

    git checkout -b feat/your-feature-name
  2. Make your changes and write tests.

  3. Run linting:

    make lint
  4. Run tests:

    make test
  5. Generate any updated documentation:

    make swagger
  6. Commit your changes using conventional commits format.

  7. Submit a pull request following the guidelines in CONTRIBUTING.md.

Troubleshooting

Database Connection Issues

If you encounter database connection errors:

# Check if PostgreSQL container is running
make docker-ps

# View PostgreSQL logs
make dockerlogs

# Restart the PostgreSQL container
make docker-restart

Smart Contract Compilation Errors

If smart contract generation fails:

  1. Ensure solc (Solidity Compiler) is correctly installed
  2. Check contract syntax for errors
  3. Verify the correct paths in the Makefile

Go Module Issues

If you encounter Go module issues:

# Clear Go module cache
go clean -modcache

# Update dependencies
go mod tidy

Additional Resources

Getting Help

If you need further assistance, refer to:

  • Project-specific documentation in the docs directory
  • Open an issue on GitHub
  • Contact the project maintainers