A simple web application that allows you to fetch and display random dog facts and pictures. The backend is written in Go using the Gin framework, while the frontend is a minimalist page based on pure HTML and JavaScript. The application fetches data asynchronously from two external public APIs.
- Backend: Go (Golang) 1.25, Gin Web Framework
- Frontend: HTML, JavaScript (Fetch API)
- External APIs:
- Dog pictures: Dog API
- Dog facts: Dog Facts API
- Deployment: Docker (Multi-stage build)
The backend has two main endpoints:
GET /- Returns the main page (main.html).GET /api/dog- API endpoint that concurrently (using goroutines and channels) queries external services for a dog picture and a dog fact, and then returns them in JSON format.
You can run the application in two ways: using Docker or directly locally using the Go environment.
Make sure you have Docker installed.
-
Build the image based on the Dockerfile in the main project directory: docker build -t dog-app .
-
Run the container, mapping port 8080: docker run -p 8080:8080 dog-app
-
Open your browser and go to:
http://localhost:8080
Requires the Go environment to be installed.
-
Navigate to the backend directory: cd backend
-
Download dependencies: go mod download
-
Run the application: go run main.go
-
Open your browser and go to:
http://localhost:8080
(Note: Because the Gin server loads views from ../frontend/*, running the program must be done from within the backend folder so that relative paths work correctly).