Stock Exchange

Getting Started

Install and run the Stock Exchange locally

Prerequisites

Before you begin, ensure you have the following installed:

  • Go (version 1.19 or higher)
  • Docker and Docker Compose
  • Git

Installation

Clone the Repository

git clone https://github.com/bruce-mig/stock-exchange.git
cd stock-exchange

Start Ganache

Start a local Ethereum blockchain using Docker:

docker-compose up -d

This will start Ganache on port 8545.

Run Tests

Verify the installation by running the test suite:

go test ./...

Start the Server

Run the stock exchange server:

go run main.go

The server will start on http://localhost:3000.

Verify Installation

Once the server is running, you should see output similar to:

   ____    __
  / __/___/ /  ___
 / _// __/ _ \/ _ \
/___/\__/_//_/\___/ v4.x.x
High performance, minimalist Go web framework
https://echo.labstack.com
____________________________________O/_______
                                    O\
⇨ http server started on [::]:3000

Congratulations! Your stock exchange is now running.

Next Steps

Troubleshooting

Port Already in Use

If port 3000 is already in use, you can change it in the main.go file or set an environment variable:

PORT=8080 go run main.go

Ganache Connection Issues

Ensure Docker is running and Ganache container is healthy:

docker ps

You should see the Ganache container running. If not, restart it:

docker-compose down
docker-compose up -d

On this page