This project is a web application that integrates with The CatAPI to display cat images and information. The application uses Go channels
for making API calls to The CatAPI. This allows for efficient, non-blocking operations when fetching cat data.
- Browse cat images from The Cat API
- Filter cats by breed
- View detailed information about each cat
- Add cats to favorites
- View all favorite cats
- Vote and unvote for cats
- Responsive design for various screen sizes
Before you begin, ensure you have met the following requirements:
- Go (version 1.16 or later)
- Git
-
Install Dependencies: Ensure you have Go installed, along with the Beego CLI tool (
bee
). If you don't havebee
installed, you can do so with:go install github.com/beego/bee/v2@latest
For Linux:
echo "export PATH=\$PATH:\$(go env GOPATH)/bin" >> ~/.bashrc source ~/.bashrc
make directory
mkdir -p ~/go/src/ "Windows===> mkdir C:\Users\Your_User_Name\go\src\" cd ~/go/src/ "Windows===> cd C:\Users\Your_User_Name\go\src\"
Then, install project dependencies:
go mod tidy
-
Clone the Repository:
git clone https://github.com/aa-nadim/cat-connect.git cd cat-connect
-
Set up your configuration: Create a
conf/app.conf
file in your project root with the following content:appname = cat-connect httpport = PORT ADDRESS runmode = dev cat_api_key = YOUR_CAT_API_KEY_HERE StaticDir = static:static
Replace
YOUR_CAT_API_KEY_HERE
with the API key you received from The Cat API. -
Generating an API Key
To use The Cat API, you need to generate an API key:
- Visit https://thecatapi.com/
- Click on the "GET YOUR API KEY" button
- Fill out the registration form with your email address
- Check your email for a message from The Cat API containing your API key
- Copy this API key and add it to your
conf/app.conf
file
-
Run the Application:
go mod tidy bee run
-
Open your browser and navigate to
http://localhost:8080/
# Run unit tests with coverage
go test ./... -coverprofile=coverage.out
# Display total coverage percentage
go tool cover -func=coverage.out | grep total: | awk '{print $3}'
# Generate an HTML coverage report
go tool cover -html=coverage.out -o coverage.html
open coverage.html