https://github.com/jackmisner/botaniclash
A plant-based card battling game with data from Trefle.io API
https://github.com/jackmisner/botaniclash
css gin golang postgresql reactjs restful-api trefle-plants-api
Last synced: 2 months ago
JSON representation
A plant-based card battling game with data from Trefle.io API
- Host: GitHub
- URL: https://github.com/jackmisner/botaniclash
- Owner: jackmisner
- Created: 2025-04-15T09:16:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-25T10:43:31.000Z (about 1 year ago)
- Last Synced: 2026-05-02T11:49:31.838Z (2 months ago)
- Topics: css, gin, golang, postgresql, reactjs, restful-api, trefle-plants-api
- Language: JavaScript
- Homepage:
- Size: 27.4 MB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ฟ BotaniClash
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.
## ๐ฎ About the Game
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
## ๐๏ธ Project Structure
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.
## ๐ Requirements
- Node.js (v20+)
- Go (latest version)
- PostgreSQL
## ๐ Quickstart
### ๐ฅ Install Node.js
If you haven't already, make sure you have node and NVM installed.
1. Install Node Version Manager (NVM)
```
brew install nvm
```
Then follow the instructions to update your `~/.bash_profile`.
2. Open a new terminal
3. Install the latest version of Node.js
```
nvm install 20
```
### ๐ฅ Install Go
Follow the instructions here: https://go.dev/doc/install
### ๐ ๏ธ Set up your project
1. Have one team member fork this repository
2. Every team member clone the fork to their local machine
3. Install dependencies for both the `frontend` and `api` applications:
```
cd frontend
npm install
cd ../api
go get .
```
4. Install an ESLint plugin for your editor, for example
[ESLint for VSCode](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
5. Start PostgreSQL
```
brew services start postgresql
```
6. Create your databases:
```
createdb botaniclash
createdb botaniclash_test
```
### โ๏ธ Setting up environment variables
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)
#### Frontend
Create a file `frontend/.env` with the following contents:
```
VITE_BACKEND_URL="http://localhost:8082"
```
#### Backend
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"
```
#### Backend Test Environment
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.
## ๐ฑ Seeding the Database
Before running the application for the first time, you need to seed the database with plant data:
1. Make sure you're in the `api` directory:
```
cd api
```
2. 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.
## ๐โโ๏ธ Running the Application
1. Start the server application (in the `api` directory):
```
cd api
go run main.go
```
2. 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!
## ๐งช Running Tests
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\]'
```
## ๐ Credits
This project uses data from Trefle, a plants API. See their website here: https://trefle.io/
Thank you Trefle!
## ๐ Card Wall
- [link here](https://trello.com/b/KIUyGIWL/botaniclash-board)
## ๐ฅ Contributors
- [@jackmisner](https://github.com/jackmisner)
- [@lukehoweth](https://github.com/LukeHoweth)
- [@abbiefinlayson1](https://github.com/abbiefinlayson1)
- [@Michal-P-1](https://github.com/Michal-P-1)
- [@AMcGill3](https://github.com/AMcGill3)
- [@I-Lovell](https://github.com/I-Lovell)