A modern web-based forum application built with Go, featuring user authentication, post management, comments, and a like/reaction system.
- 🔐 User Authentication - Secure login and registration system
- 📝 Create Posts - Users can create forum posts with categories
- 💬 Comments - Add and manage comments on posts
- 👍 Likes & Reactions - React to posts and comments
- 🏷️ Categories - Organize posts by categories
- 👤 User Profiles - View posts created by specific users
- 🎨 Responsive UI - Clean and intuitive user interface with CSS styling
- 🐳 Docker Support - Easy deployment with Docker
Before you begin, ensure you have the following installed:
- Go 1.23.0 or higher (Download Go)
- SQLite3 (usually comes with most systems)
- Git (optional, for cloning the repository)
- Docker - If you want to run the application in a container
git clone <repository-url>
cd forumgo mod downloadThis will download all required Go modules:
google/uuid- For generating unique identifiersmattn/go-sqlite3- SQLite database drivergolang.org/x/crypto- For password hashing
- Start the application:
go run ./cmd/main.go- Access the application:
Open your browser and navigate to:
http://localhost:8080/
-
Create an account:
- Click on "Register"
- Fill in your username and password
- Submit the form
-
Start using the forum:
- Create new posts
- Add comments to existing posts
- Like posts and comments
- Filter posts by categories or your own posts
To build a standalone executable:
go build -o main ./cmd/main.go
./main- Build the Docker image:
docker build -t forum:latest .- Run the container:
docker run -p 8080:8080 forum:latest- Access the application:
Open your browser and navigate to:
http://localhost:8080/
forum/
├── cmd/
│ └── main.go # Application entry point
├── handlers/ # HTTP request handlers
│ ├── HomeHandler.go # Home page handler
│ ├── LoginHandler.go # Login logic
│ ├── LoginShowHandler.go # Login page display
│ ├── RegisterHandler.go # Registration logic
│ ├── RegisterShowHandler.go # Registration page display
│ ├── CreatePost.go # Create post handler
│ ├── DeletePost.go # Delete post handler
│ ├── Comment.go # Comment handler
│ ├── CommentsLikeHandler.go # Like comments handler
│ ├── Reaction.go # Post reaction handler
│ ├── Filter_By_Categorie.go # Filter by category
│ ├── Filter_By_My_Posts.go # Filter user's posts
│ ├── Filter_by_Liked_Posts.go # Filter liked posts
│ ├── UploadHandler.go # File upload handler
│ ├── LogOutHandler.go # Logout handler
│ ├── StyleHandler.go # CSS/static file handler
│ └── Reaction.go # Post reactions
├── middleware/ # Middleware functions
│ ├── Auth.go # Authentication middleware
│ ├── login.go # Login middleware
│ ├── Posts.go # Posts middleware
│ ├── Likes.go # Likes middleware
│ ├── comments.go # Comments middleware
│ └── structures.go # Data structures
├── helpers/ # Helper functions
│ ├── db.go # Database connection
│ ├── AllCategories.go # Fetch all categories
│ ├── fetchCategoy.go # Fetch category info
│ ├── fetchComments.go # Fetch comments
│ ├── GetUsernameFromSession.go # Session management
│ ├── RanderTemplate.go # Template rendering
│ ├── Sessionchecked.go # Session validation
│ ├── formatDuration.go # Date/time formatting
│ └── PageDeleted.go # Deleted page handler
├── routes/
│ └── route.go # Route definitions
├── utils/
│ └── Utils.go # Utility functions
├── template/ # HTML templates
│ ├── home.html # Home page template
│ ├── login.html # Login page template
│ ├── register.html # Registration template
│ └── statusPage.html # Status page template
├── static/ # Static assets
│ ├── home.css # Home page styling
│ ├── login.css # Login page styling
│ ├── navbar.css # Navigation styling
│ ├── register.css # Registration styling
│ ├── status_Page.css # Status page styling
│ └── images/ # Image assets
├── db/
│ └── query.sql # Database schema and queries
├── Dockerfile # Docker configuration
├── go.mod # Go module definition
└── README.md # This file
- Backend: Go 1.23.0
- Database: SQLite3
- Frontend: HTML5, CSS3
- Authentication: Session-based with bcrypt password hashing
- Containerization: Docker
- Utilities: UUID for unique identifiers
The forum provides the following main routes:
| Route | Method | Description |
|---|---|---|
/ |
GET | Home page |
/register |
GET/POST | User registration |
/login |
GET/POST | User login |
/logout |
GET | User logout |
/create-post |
GET/POST | Create new post |
/delete-post |
POST | Delete post |
/comment |
POST | Add comment |
/like |
POST | Like/unlike post |
/reaction |
POST | React to post |
/filter |
GET | Filter posts by category |
/my-posts |
GET | View user's posts |
/liked-posts |
GET | View liked posts |
The application uses SQLite3 as its database. The database schema is defined in db/query.sql.
- User accounts with password hashing
- Posts with categories and timestamps
- Comments with author tracking
- Like/reaction tracking
- Session management
- User sessions are tracked after successful login
- Sessions are validated on each request requiring authentication
- Logout clears the user session
If port 8080 is already in use, modify the port in cmd/main.go:
err = http.ListenAndServe(":YOUR_PORT", nil)If you encounter database errors:
- Ensure SQLite3 is installed
- Delete the existing database file and restart the application
- Check db/query.sql for schema requirements
Ensure all HTML template files are in the template/ directory:
home.htmllogin.htmlregister.htmlstatusPage.html
go build -o forum ./cmd/main.goCurrently, no test suite is configured. Consider adding tests in the future.
To contribute to this project:
- Fork the repository
- Create a feature branch
- Make your changes
- Test your changes thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
- mennaas
- abalouri
- abaid
- ranniz
- ychatoua
For issues or questions, please create an issue in the repository or contact the maintainers.
Happy Forumming! 🎉