This is a simple Hacker News clone built with Gin and PostgreSQL. The purpose of this project is to educate users on how to deploy database-dependent applications on Leapcell.
- Gin web framework for backend
- PostgreSQL database integration
- HTML templating for rendering views
- Static files support
.
├── main.go # Main application entry point
├── go.mod # Go module file
├── go.sum # Go dependencies file
├── static/ # Directory for static assets (CSS, JavaScript, images)
└── templates/ # HTML templates for rendering views
├── index.html # Homepage displaying posts
├── post_detail.html # Template for displaying post details
└── missing-pg.html # PG missing
This guide will walk you through setting up and deploying the project on Leapcell.
Ensure you have the following:
- A Leapcell account
- PostgreSQL database instance
- Go installed (recommended: Go 1.18+)
This project requires a PostgreSQL connection string, which should be set using the following environment variable:
PG_DSN=<your_postgresql_connection_string>- Clone the repository:
git clone https://github.com/leapcell/gin-hackernews-clone cd gin-hackernews-clone - Install dependencies:
go mod tidy
To start the project locally, ensure your PostgreSQL instance is running and execute:
go run main.goThe application will be accessible at http://localhost:8080.
- Push your code to a GitHub repository.
- Log in to Leapcell and connect your repository.
- Configure the
PG_DSNenvironment variable in the Leapcell deployment settings. - Deploy your application.
Once deployed, your application will be accessible via the Leapcell-generated domain.
Feel free to submit issues or pull requests to improve this project.
For support, reach out via the Leapcell Discord community or email support@leapcell.io.