Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oadultradeepfield/keepactive-backend
KeepActive is a service that helps keep free-tier hosted websites active by sending periodic GET requests. This prevents them from going dormant due to inactivity.
https://github.com/oadultradeepfield/keepactive-backend
Last synced: 4 days ago
JSON representation
KeepActive is a service that helps keep free-tier hosted websites active by sending periodic GET requests. This prevents them from going dormant due to inactivity.
- Host: GitHub
- URL: https://github.com/oadultradeepfield/keepactive-backend
- Owner: oadultradeepfield
- Created: 2024-11-06T06:52:35.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-07T22:57:22.000Z (3 months ago)
- Last Synced: 2024-11-17T05:31:01.116Z (3 months ago)
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# đ KeepActive Backend đ
KeepActive is a service that helps keep free-tier hosted websites active by sending periodic GET requests. This prevents them from going dormant due to inactivity.
## ⨠Features
- đ User authentication with JWT
- đ Website monitoring management
- đšī¸ Automated GET request scheduling
- đĄ RESTful API design
- đŗ Docker containerization
- đ ī¸ Production-ready configuration## âī¸ Tech Stack
- ![Go Badge](https://img.shields.io/badge/Go-1.23-00ADD8?logo=go&logoColor=white)
- ![Gin Badge](https://img.shields.io/badge/Gin-Framework-3E921D?logo=go&logoColor=white)
- ![GORM Badge](https://img.shields.io/badge/GORM-PostgreSQL-4E5F55?logo=postgresql&logoColor=white)
- ![JWT Badge](https://img.shields.io/badge/JWT-Authentication-FFB700?logo=json-web-tokens&logoColor=white)
- ![Docker Badge](https://img.shields.io/badge/Docker-Containerization-2496ED?logo=docker&logoColor=white)
- ![Supabase Badge](https://img.shields.io/badge/Supabase-Database-2F7B2B?logo=supabase&logoColor=white)
- ![Render Badge](https://img.shields.io/badge/Render-Deployment-10A0F0?logo=render&logoColor=white)## đ ī¸ Local Development Setup
### đ Prerequisites
- Go 1.23 or higher
- Docker
- PostgreSQL or Supabase account
- Git### ⥠Installation
1. Clone the repository
```bash
git clone https://github.com/oadultradeepfield/keepactive-backend.git
cd keepactive-backend
```2. Install dependencies
```bash
go mod tidy
```3. Create `.env` file in the root directory
```env
DATABASE_URL=your_supabase_postgres_connection_string
JWT_SECRET=your_secure_jwt_secret
ALLOWED_ORIGINS=https://your-frontend-domain.com
GO_ENV=development
PORT=8080
```4. Run the application
```bash
go run main.go
```### đ Docker Local Development
1. Build the Docker image
```bash
docker build -t keepactive-backend .
```2. Run the container
```bash
docker run -p 8080:8080 --env-file .env keepactive-backend
```## đĄ API Endpoints
### đ Authentication Endpoints
- `POST /api/register` - Register new user
```json
{
"email": "[email protected]",
"password": "securepassword"
}
```- `POST /api/login` - Login user
```json
{
"email": "[email protected]",
"password": "securepassword"
}
```### đ Website Management Endpoints
All these endpoints require JWT Authentication header: `Authorization: Bearer `
- `POST /api/websites` - Create new website
```json
{
"name": "My Website",
"url": "https://mywebsite.com",
"duration": 7
}
```- `GET /api/websites` - List all websites
- `DELETE /api/websites/:id` - Delete website
## đ Deployment to Render
### đ Prerequisites
1. Create a [Render](https://render.com) account
2. Create a [Supabase](https://supabase.com) account and database
3. Have your code pushed to GitHub### âī¸ Deployment Steps
1. **Create New Web Service**
- Go to Render Dashboard
- Click "New +" and select "Web Service"
- Connect your GitHub repository2. **Configure Web Service**
- Name: `keepactive-backend` (or your preferred name)
- Region: Choose the nearest to your target audience
- Runtime: Docker
- Instance Type: Free
- Health Check Path: `/health`3. **Environment Variables**
Add the following environment variables in Render dashboard:```
DATABASE_URL=your_supabase_postgres_connection_string
JWT_SECRET=your_secure_jwt_secret
ALLOWED_ORIGINS=https://your-frontend-domain.com
GO_ENV=production
PORT=8080
```4. **Deploy**
- Click "Create Web Service"
- Render will automatically build and deploy your application### đ Checking Deployment
1. Your app will be available at `https://your-service-name.onrender.com`
2. Test the health check endpoint: `https://your-service-name.onrender.com/health`
3. Try registering a user using the `/api/register` endpoint## đ Project Structure
```
keepactive-backend/
âââ config/
â âââ config.go # Configuration management
â âââ database.go # Database initialization
âââ handlers/
â âââ auth.go # Authentication handlers
â âââ website.go # Website management handlers
âââ middleware/
â âââ auth.go # JWT authentication middleware
â âââ cors.go # CORS middleware
âââ models/
â âââ models.go # Data models
âââ services/
â âââ pinger.go # Website pinger service
âââ main.go # Application entry point
âââ Dockerfile # Docker configuration
âââ go.mod # Go modules file
âââ go.sum # Go modules checksum
âââ .env # Environment variables (local only)
```