Skip to content

A modern web forum application built with Go featuring user authentication, post creation with image uploads, commenting system, voting mechanism, and category-based organization. Includes session management and SQLite database.

Notifications You must be signed in to change notification settings

TanakAiko/forum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Forum Web Application

Go SQLite HTML5 CSS3 JavaScript Docker

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.

Forum Screenshot

✨ Features

  • 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

🛠 Technology Stack

Backend: Go 1.21.7 | Database: SQLite3 | Frontend: HTML5, CSS3, JavaScript

Key Libraries:

  • go-sqlite3 - SQLite database driver
  • uuid - Session ID generation
  • bcrypt (crypto) - Password hashing

📂 Project Structure

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

🚀 Getting Started

Prerequisites

  • Go 1.21.7 or higher
  • SQLite3
  • GCC (for SQLite driver compilation)

Installation & Running

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:4000

Using Docker:

docker build -t forum .
docker run -p 4000:4000 forum

Custom Port: Modify addr flag in cmd/web/main.go (default: 4000)

🗄 Database Schema

SQLite database with 7 main tables:

  • user - Authentication and profiles
  • post - Forum posts with content
  • comments - Post comments
  • post_categorie - Post-category mappings
  • votes - Post like/dislike votes
  • votecomment - Comment like/dislike votes
  • session - User session management

🔒 Security

  • Bcrypt password hashing
  • Session-based authentication with expiration
  • SQL injection protection via prepared statements
  • Server-side input validation
  • Authentication middleware for protected routes

🤝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

⭐ Star this repository if you found it helpful! ⭐

Made with ❤️ from 🇸🇳

About

A modern web forum application built with Go featuring user authentication, post creation with image uploads, commenting system, voting mechanism, and category-based organization. Includes session management and SQLite database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •