mirror of
https://github.com/kalvin0x8d0/classifieds.git
synced 2026-05-04 00:55:47 +08:00
No description
- Go 43.1%
- HTML 35.2%
- CSS 21.3%
- Dockerfile 0.4%
| static | ||
| templates | ||
| .env.example | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| README.md | ||
Classifieds
A lightweight, self-hosted classified ads platform built with Go and MariaDB. No frameworks, minimal dependencies, easy to deploy.
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 |
Go net/smtp |
Quick Start
With Docker (recommended)
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