No description
  • Go 43.1%
  • HTML 35.2%
  • CSS 21.3%
  • Dockerfile 0.4%
Find a file
2026-03-29 11:00:36 +08:00
static Resolve merge conflicts by keeping new auth UI 2026-03-20 10:19:47 +08:00
templates Fix security vulnerabilities, bugs, and improve error handling 2026-03-20 03:46:51 +00:00
.env.example Update .env.example 2026-03-29 11:00:16 +08:00
.gitignore Update .gitignore 2026-03-20 00:39:29 +08:00
docker-compose.yml Update docker-compose.yml 2026-03-29 11:00:36 +08:00
Dockerfile Upload files to "/" 2026-03-20 00:38:24 +08:00
go.mod Add user system with SMTP email verification, invite codes, role management, and dark mode 2026-03-20 01:57:17 +00:00
go.sum Add user system with SMTP email verification, invite codes, role management, and dark mode 2026-03-20 01:57:17 +00:00
LICENSE Create LICENSE 2026-03-28 00:03:04 +08:00
main.go Fix security vulnerabilities, bugs, and improve error handling 2026-03-20 03:46:51 +00:00
README.md Update README.md 2026-03-28 00:10:46 +08:00

Classifieds

A lightweight, self-hosted classified ads platform built with Go and MariaDB. No frameworks, minimal dependencies, easy to deploy.

CC0 1.0 Universal (CC0 1.0) Public Domain Dedication

AI Generated Badge

Features

  • Browse & Search — Full-text search across listings with category filtering
  • 9 Categories — Electronics, Vehicles, Jobs, Property, Services, Fashion, Food, Books, Others
  • Ad Approval Workflow — Ads require admin/moderator approval before going public
  • User Roles — Admin, Moderator, and User roles with appropriate permissions
  • Invite System — Support for open, invite-only, or disabled registration modes
  • Email Verification — Optional SMTP-based email verification for new accounts
  • Contact Linkification — Auto-converts phone numbers, emails, and URLs into clickable links (with WhatsApp integration)
  • Multi-Currency — Configurable currencies with custom formatting
  • Dark Mode — Light/dark theme toggle with auto-detection
  • Docker Ready — Multi-stage Dockerfile and Docker Compose included

Tech Stack

Component Technology
Language Go 1.22
Web Server Go net/http (no framework)
Database MariaDB 11 / MySQL
Templates Go html/template
CSS Vanilla (no framework)
Auth bcrypt + cookie-based sessions
Email Go net/smtp

Quick Start

cp .env.example .env
# Edit .env with your configuration
docker-compose up --build

Manual Setup

# 1. Create the database
mysql -u root -p -e "CREATE DATABASE classifieds; \
  CREATE USER 'classifieds'@'localhost' IDENTIFIED BY 'password'; \
  GRANT ALL PRIVILEGES ON classifieds.* TO 'classifieds'@'localhost';"

# 2. Set environment variables
export DB_DSN="classifieds:password@tcp(localhost:3306)/classifieds?parseTime=true&charset=utf8mb4"
export ADMIN_PASSWORD="yourpassword"
export ADMIN_EMAIL="admin@example.com"
export PORT=8080

# 3. Run
go run main.go

The app auto-creates the database schema and seeds an admin user on first run.

Configuration

Copy .env.example and configure the following:

Variable Description
DB_ROOT_PASSWORD MariaDB root password (Docker only)
DB_PASSWORD Application database password
ADMIN_PASSWORD Initial admin account password
ADMIN_EMAIL Initial admin email address
APP_PORT Port to listen on (default: 8080)

SMTP settings (for email verification) can be configured through the admin panel after deployment.

Project Structure

classifieds/
├── main.go              # Entire application (~1200 lines)
├── go.mod / go.sum      # Go dependencies
├── Dockerfile           # Multi-stage build
├── docker-compose.yml   # MariaDB + app
├── .env.example         # Configuration template
├── templates/           # HTML templates
│   ├── _shared.html     # Navbar & theme toggle
│   ├── index.html       # Listings homepage
│   ├── ad.html          # Single ad view
│   ├── post.html        # Submit ad form
│   ├── login.html       # Login page
│   ├── register.html    # Registration page
│   ├── verify.html      # Email verification
│   ├── profile.html     # User profile & invite codes
│   └── admin.html       # Admin dashboard
└── static/
    └── style.css        # All styles

Admin Panel

Accessible at /admin for users with the admin or moderator role. Admins can:

  • Approve or delete submitted ads
  • Manage users and assign roles
  • Configure signup mode (open / invite-only / disabled)
  • Set up SMTP for email verification
  • Manage available currencies