Skip to content

Oiha-dev/Faux-Rhum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

banner


๐Ÿ“– Table of contents

  1. ๐Ÿค” What is Faux Rhum ?
  2. โ–ถ๏ธ Demo
  3. ๐Ÿ› ๏ธ How to Install
    3.1 ๐Ÿงฐ Dependencies
  4. ๐Ÿ›œ Run the server
    4.1 ๐ŸŒณ Environment Variables
    4.2 ๐Ÿ”ง Configure OAuth
  5. ๐Ÿ—ƒ๏ธ File Architecture
  6. ๐Ÿ”ฎ Features
    6.1 ๐Ÿชช OAuth
    6.2 ๐Ÿšจ Forum Administration
    6.3 ๐Ÿงฎ Filters
    6.4 ๐Ÿ“จ Notifications
    6.5 ๐Ÿ“ˆ User Activity
  7. ๐Ÿ“‚ Post Management
    7.1 ๐Ÿ“ Post Lifecycle
    7.2 ๐Ÿ’ฌ Comments
    7.3 ๐Ÿ‘ Reactions
  8. ๐Ÿช„Extra Features
    8.1 ๐Ÿ”Ž Search Bar
    8.2 ๐ŸŽจ Theme Changer
    8.3 ๐Ÿ–Œ๏ธ Markdown Rendered
    8.4 โฌ†๏ธ User Ranking
    8.5 โš™๏ธ Profile Settings
    8.6 โŒ SQL Triggers
  9. โœจComing in the future
  10. ๐ŸŒ Credits
  11. ๐Ÿ“Ž Appendix

Faux Rhum is the final school project for our 1st IT/CyberSecurity year.
The theme of the project was to make a complete community forum using Golang, HTML/CSS/JS, MySQL and Docker.

Our team decided to base the forum theme on a pun I made for joke "Faux-Rhum" which mean "Fake Rhum"
but phonetically sounds like "Forum".

The forum role is to allow a community of people who like to talk about alcohol, rum and other drinks to share their opinions, recipes, and experiences.

In this forum, you can create posts, comment on them, react to them, and manage your profile.

demo

To install the app, you will need to have on your machine :

Git Docker Any Web Browser

Other dependencies :

  • ๐Ÿ“šGCC Compiler (for Windows users)
    apt install libwebp (for Linux users)

This library is necessary to handle the webp images and there conversion, the project won't run without it.

Installation with GitBash

git clone https://github.com/Oiha-dev/Faux-Rhum.git
cd Faux-Rhum/

Run the program using Docker with CLI

โ— Make sure you have environment variables set up before running the server โ—

Run Faux-Rhum with the cmd using the following commands
docker compose up --build -d
This command will build the Docker image and run the container in detached mode.
It can take several seconds to build the image.

And then if you want to see the logs of the container, you can use the command
docker logs -f forum

After that, open your web browser and go to http://localhost:8080/ to go on the Home Page.

The server will be hosted on your localhost address on the port 8080

The 'Home Page' is the '/' route

To stop the server, you can use the command
docker compose down


To run the server, you will need to set up some environment variables.
You can use the '.env.public' example file to create your own '.env' file.

Here is the list of environment variables you need to set up:

# .env
DATABASE_IP=db
DATABASE_PORT=3306
DATABASE_NAME=forum
DATABASE_USER=forum
DATABASE_PASSWORD=forum
# OAuth configuration
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URL=http://localhost:8080/auth/google/callback
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
GITHUB_REDIRECT_URL=http://localhost:8080/auth/github/callback
# Session secret key
SESSION_SECRET_KEY=your-session-secret-key

Google OAuth

To configure Google OAuth, you will need to create a project on the Google Developers Console.

  1. Go to the Google Developers Console.
  2. Create a new project.
  3. Go to the "Credentials" tab.
  4. Click on "Create credentials" and select "OAuth client ID".
  5. Select "Web application" as the application type.
  6. Add the following authorized redirect URIs:
    • http://localhost:8080/auth/google/callback
  7. Click on "Create" and copy the Client ID and Client Secret to your .env file.
  8. Click on "Save".

GitHub OAuth

To configure GitHub OAuth, you will need to create a new OAuth application on the GitHub Developer Settings.

  1. Go to the GitHub Developer Settings.
  2. Click on "New OAuth App".
  3. Fill in the application name, homepage URL, and description.
  4. In the "Authorization callback URL" field, enter http://localhost:8080/auth/github/callback.
  5. Click on "Register application".
  6. Copy the Client ID and Client Secret to your .env file.
  7. Click on "Save".

forum/
โ”œโ”€โ”€ auth/
โ”‚   โ”œโ”€โ”€ google_oauth.go
โ”‚   โ”œโ”€โ”€ middleware.go
โ”‚   โ”œโ”€โ”€ session.go
โ”‚   โ””โ”€ ...
โ”œโ”€โ”€ cmd/
โ”‚   โ””โ”€โ”€ main.go
โ”œโ”€โ”€ db/
โ”‚   โ”œโ”€โ”€ CRUD/
โ”‚   โ”‚   โ”œโ”€โ”€ notificationCRUD.go
โ”‚   โ”‚   โ”œโ”€โ”€ postCRUD.go
โ”‚   โ”‚   โ”œโ”€โ”€ userCRUD.go
โ”‚   โ”‚   โ””โ”€ ...
โ”‚   โ”œโ”€โ”€ dbConnection.go
โ”‚   โ””โ”€โ”€ dbQueries.go
โ”œโ”€โ”€ docker/
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ””โ”€โ”€ init
โ”‚       โ””โ”€โ”€ forum.sql
โ”œโ”€โ”€ post/
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ render/
โ”‚   โ””โ”€โ”€ render.go
โ”‚
โ”œโ”€โ”€ handlers/
โ”‚   โ”œโ”€โ”€ modifyPostHandler.go
โ”‚   โ”œโ”€โ”€ LoginHandler.go
โ”‚   โ”œโ”€โ”€ postCreationHandler.go
โ”‚   โ”œโ”€โ”€ postDeleteHandler.go
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ server/
โ”‚   โ”œโ”€โ”€ routes.go
โ”‚   โ””โ”€โ”€ startServer.go
โ”‚
โ”œโ”€โ”€ structures/
โ”‚   โ””โ”€โ”€ webTemplatesStructures.go
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ environmentVariable.go
โ”‚   โ”œโ”€โ”€ password.go
โ”‚   โ””โ”€โ”€ ...
โ””โ”€โ”€ web/
โ”‚    โ”œโ”€โ”€ static/
โ”‚    โ”‚   โ””โ”€โ”€ ...
โ”‚    โ”‚ 
โ”‚    โ””โ”€โ”€ templates/
โ”‚        โ”œโ”€โ”€ layouts/
โ”‚        โ”‚   โ”œโ”€โ”€ headerLayout.gohtml
โ”‚        โ”‚   โ””โ”€โ”€ ...
โ”‚        โ”œโ”€โ”€ login.gohtml
โ”‚        โ”œโ”€โ”€ panelAdmin.gohtml
โ”‚        โ””โ”€โ”€ ...
โ”œโ”€โ”€ go.mod
โ”œโ”€โ”€ .dockerignore
โ”œโ”€โ”€ Dockerfile
โ””โ”€โ”€ docker-compose.yml

In this section you will see more of the feature that our Faux-Rhum has to offer.


We implemented OAuth to allow users to log in with their Google or GitHub accounts.
This allows users to easily create an account and log in without having to remember another password.
To use OAuth, you need to set up the environment variables as explained in the "Run the server" section.

If the user has never logged in before, he will be redirected to the OAuth provider (Google or GitHub) to log in.
and then redirected back to the forum with a token that will be used to authenticate the user.

If the user has already logged in, he will be redirected to the forum directly without having to log in again.

When the user want to log in with Github OAuth even if his account has a Google Oauth linked, if the email is the same, the user will be logged in with the same account.


The forum administration is a feature that allows the administrator to manage the forum.
There is 3 type of administrators :

  • Founder : The creator of the forum, he has all the rights on the forum.
  • Administrator : The administrator, he has most of the rights on the forum.
  • Moderator : The moderator, he can only manage posts and comments.

The administration team can access the administration panel by clicking on the "Admin Panel" button in the header.

In the administration panel, the administrator can manage :

  • Users (change their roles, see their status, ban them, etc...)
  • Posts (see the posts to approve, delete them, etc...)
  • Categories (see the categories, add new categories, delete them, etc...)

โ—For now you can't delete categories, you can only add themโ—

When a post is created, it is not visible to the public until it is approved by an administrator.


The forum has a filter system that allows users to filter posts :

  • By category
  • By Posts Liked
  • By Posts Created

Also, the Home Page has a pagination system that allows users to navigate through the posts.


The forum has a notification system that allows users to receive notifications when :

  • One of their posts is liked/disliked
  • One of their posts is commented
  • One of their comments is liked/disliked

When the user clicks on a notification, it's marked as read
and when you click on the details of it, it will redirect to the post that concern the notification.

Good to know : When a post is deleted, comment deleted etc... The notifications related to this post/comment are also deleted.


The forum has a user activity system that allows users to see their activity on the forum.
By accessing to '/profile' route, the user can see :

  • The number of posts created
  • The number of comments created

And a list of the last 20 activities of the user, like :

  • Posts created
  • Comments created
  • Posts liked/disliked
  • Comments liked/disliked

You can also see the activity of other users by going to their profile page.




To create a post, the user need to be logged in.

When the user create a post he can choose min 1 category and max 3 categories, enter a title and a content.
He can also add an image to the post (max 20Mb), the image will be converted to webp format to reduce the size of the image.

When the post is created, it is not visible to the public until it is approved by an administrator.

The user can edit his post, when editing a post, the user can change the title, content, categories and image of the post.

โ— When the post is deleted, all the comments, reactions, user activity and notifications related to this post are also deleted. โ—


Users can comment on posts, to do so, the user need to be logged in.
When the user comment on a post, the Author get a notification and the user activity now contain his comment.

A comment author can delete his comment, when the comment is deleted, all the reactions, notifications related to this comment are also deleted.

โ—A staff can delete any comment, even if he is not the author of the comment. โ—


Users can react (like/dislike) to posts and comments, to do so, the user need to be logged in.
When the user react to a post/comment, the author of the post/comment get a notification and the user activity now contain his reaction.

If a not logged user try to react to a post/comment, he will be redirected to the login page.




The forum has a search bar that allows users to search for posts by title or content.
When the user enters a search query, the forum will display the posts that match the query with pagination.

In the future, we will add a search bar that allows users to search for posts by author, category, etc...


The forum has a theme changer that allows users to change the theme of the forum. The user can choose between 7 themes :

  • Champagne (default light theme)
  • Jรคgermeister (orange dark theme)
  • Vodka (blue light theme)
  • Mojito (green light theme)
  • Wine (red light theme)
  • Rhum (brown light-dark theme)
  • Beer (yellow light theme)

The theme is saved in the local host, so when the user refresh the page, the theme is still applied.


The forum has a markdown renderer that allows users to write posts markdown format.
When the user writes a post, he can use markdown syntax to format his post.
The markdown renderer will convert the markdown syntax to HTML and display it in the post.

In the post editor, there are some buttons that allow the user to format his post easily :

  • Bold
  • Italic
  • Strikethrough
  • Heading +
  • Heading -

The forum has a user ranking system that allows users to see their rank on the forum.
The user rank is based on a calculation that take the number of posts created, comments created

The user rank is displayed on the user profile page and on the user activity page.
There is 5 ranks :

  • Curieux
  • Degustateur
  • Connaisseur
  • Initiรฉ
  • Oenologue

The forum has a profile settings page that allows users to change their profile settings. The user can change :

  • Their username
  • Their password (with password confirmation)
  • Their profile picture
  • Their email address (only if they aren't registered by OAuth)
  • Their bio

The forum has some SQL triggers that update/delete data in the database when certain actions are performed. Here's an example list of the SQL triggers implemented in the forum :

  • When a post attachment is changed, the old attachment is deleted from the database.
  • When a user change is profile picture, the old profile picture is deleted from the database.

Here's a list of features that we plan to implement in the future :

  • ๐Ÿ“ฉ Verification email : When a user registers, he will receive a verification email to confirm his email address.
  • ๐Ÿค” Password reset : When a user forgets his password, he can reset it by receiving a password reset email.
  • ๐Ÿ—ฃ๏ธ Private Messages : Users can send private messages to each other.
  • ๐Ÿ“ก REST API: A REST API that allows third-party applications to interact with the forum.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages