A modern web forum application built with Go (Golang) that enables users to create accounts, share posts, engage through comments, and interact via a voting system. Features include post categorization, image uploads, and secure session-based authentication.
- User Authentication: Secure registration, login/logout with session management
- Post Creation: Write posts with titles, content, and optional images
- Categories: Organize and filter posts by predefined categories
- Voting System: Like/dislike both posts and comments
- Comments: Engage in discussions with nested comment threads
- Activity Tracking: View your created posts and liked content
- Real-time Counters: Display votes and comment counts
- Responsive Design: Mobile-friendly interface
Backend: Go 1.21.7 | Database: SQLite3 | Frontend: HTML5, CSS3, JavaScript
Key Libraries:
go-sqlite3- SQLite database driveruuid- Session ID generationbcrypt(crypto) - Password hashing
forum/
├── cmd/web/ # Web application entry point
│ ├── main.go # Application initialization
│ ├── handlers.go # HTTP request handlers
│ ├── routes.go # URL routing configuration
│ ├── middleware.go # Authentication & session middleware
│ ├── templates.go # Template rendering logic
│ └── helper.go # Utility functions
├── internal/
│ ├── models/ # Data models and database operations
│ │ ├── user.go # User model and operations
│ │ ├── posts.go # Post model and operations
│ │ ├── comments.go # Comment model and operations
│ │ ├── like_dislike.go # Post voting system
│ │ ├── like_dislike_comments.go # Comment voting system
│ │ ├── post_categories.go # Category management
│ │ ├── session_manager.go # Session handling
│ │ └── erros.go # Error definitions
│ ├── validator/ # Input validation
│ │ └── validator.go
│ ├── database.db # SQLite database file
│ └── database.sql # Database schema
├── ui/
│ ├── static/ # Static assets
│ │ ├── style.css # Main stylesheet
│ │ ├── style_authen.css # Authentication styles
│ │ ├── style_error.css # Error page styles
│ │ ├── images/ # UI icons and images
│ │ └── upload/ # User uploaded images
│ └── templates/pages/ # HTML templates
│ ├── home.html # Homepage
│ ├── create.html # Post creation form
│ ├── viewpost.html # Individual post view
│ ├── viewpostcategorie.html # Category view
│ ├── userposts.html # User's posts
│ ├── userlikedpost.html # User's liked posts
│ ├── login.html # Login form
│ ├── signup.html # Registration form
│ └── error.html # Error pages
├── dockerfile # Docker configuration
├── go.mod # Go module definition
└── go.sum # Dependency checksums
- Go 1.21.7 or higher
- SQLite3
- GCC (for SQLite driver compilation)
Local Development:
# Clone and navigate to project
git clone <repository-url>
cd forum
# Install dependencies
go mod download
# Run the application (database auto-created on first run)
go run ./cmd/web
# Access at http://localhost:4000Using Docker:
docker build -t forum .
docker run -p 4000:4000 forumCustom Port: Modify addr flag in cmd/web/main.go (default: 4000)
SQLite database with 7 main tables:
user- Authentication and profilespost- Forum posts with contentcomments- Post commentspost_categorie- Post-category mappingsvotes- Post like/dislike votesvotecomment- Comment like/dislike votessession- User session management
- Bcrypt password hashing
- Session-based authentication with expiration
- SQL injection protection via prepared statements
- Server-side input validation
- Authentication middleware for protected routes
We welcome contributions! Here's how you can help:
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
⭐ Star this repository if you found it helpful! ⭐
Made with ❤️ from 🇸🇳
