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-exchangeStart Ganache
Start a local Ethereum blockchain using Docker:
docker-compose up -dThis 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.goThe 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 [::]:3000Congratulations! Your stock exchange is now running.
Next Steps
API Reference
Explore the available API endpoints
Examples
See practical examples of trading operations
Architecture
Learn about the system architecture
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.goGanache Connection Issues
Ensure Docker is running and Ganache container is healthy:
docker psYou should see the Ganache container running. If not, restart it:
docker-compose down
docker-compose up -d