A plant-based card game where players battle with plant stats! Players collect plant cards and compete by comparing various attributes like soil pH range, light requirements, and nutrient needs.
BotaniClash is a strategic card game using real plant data from the Trefle API. Players:
- Battle with cards representing different plant species
- Choose which plant attribute to compare in each round
- Win cards from opponents when their plant has better stats
- Track their game statistics on the leaderboard
This repo contains two applications:
- 🖥️ A frontend React App - User interface for the game
- 🔌 A backend API server - Go-based server handling game logic and plant data
These two applications communicate through HTTP requests and need to be run separately.
- Node.js (v20+)
- Go (latest version)
- PostgreSQL
If you haven't already, make sure you have node and NVM installed.
- Install Node Version Manager (NVM)
Then follow the instructions to update your
brew install nvm
~/.bash_profile
. - Open a new terminal
- Install the latest version of Node.js
nvm install 20
Follow the instructions here: https://go.dev/doc/install
-
Have one team member fork this repository
-
Every team member clone the fork to their local machine
-
Install dependencies for both the
frontend
andapi
applications:cd frontend npm install cd ../api go get .
-
Install an ESLint plugin for your editor, for example ESLint for VSCode
-
Start PostgreSQL
brew services start postgresql
-
Create your databases:
createdb botaniclash createdb botaniclash_test
We need to create two .env
files, one in the frontend and one in the api (and also a .env.test file for the api)
Create a file frontend/.env
with the following contents:
VITE_BACKEND_URL="http://localhost:8082"
You'll need to sign up for a trefle account to get an API key. You must keep this private. Never put your key in any file outside the .env!
Create a file api/.env
with the following contents:
POSTGRES_URL="postgresql://localhost:5432/botaniclash"
JWT_SECRET="secret"
TREFLE_API_TOKEN="your api token here"
Create a file api/.env.test
with the following contents:
POSTGRES_URL="postgresql://localhost:5432/botaniclash_test"
JWT_SECRET="test_secret"
This separate test database ensures your tests don't interfere with your development data.
Before running the application for the first time, you need to seed the database with plant data:
- Make sure you're in the
api
directory:
cd api
- Seed the database using either method:
go run main.go seed
OR
go build
./api seed
This process will:
- Drop existing tables (if any)
- Create fresh tables
- Populate them with plant data from the Trefle API
Warning: Running this command will erase any existing data in your database. Only use it when setting up for the first time or if you want to reset all data.
- Start the server application (in the
api
directory):
cd api
go run main.go
- Start the front end application (in the
frontend
directory)
In a new terminal session:
cd frontend
npm run dev
You should now be able to open your browser and go to http://localhost:5173/signup
to create a new user.
After signing up, you can log in by going to http://localhost:5173/login
and start playing!
To run the Go backend tests:
cd api
go test ./... | grep -v '\[no test files\]'
For verbose output:
go test -v ./... | grep -v '\[no test files\]'
To force running tests instead of using cached results:
go test -count=1 ./... | grep -v '\[no test files\]'
This project uses data from Trefle, a plants API. See their website here: https://trefle.io/
Thank you Trefle!