Online forum for MMORPG fans and friends!
The web application can be accessed at the following URLs:
This is a Web Application written in Golang, utilizing only standard Go libraries and the following external packages:
github.com/google/uuid v1.4.0
github.com/mattn/go-sqlite3 v1.14.18
- To run locally use
go run ./cmd/web .
- How to use Docker
- User Registration: Users can create new accounts.
- Guest Registration: Allows guest users to access limited features or explore the platform without registration.
- Login System: Users can log in using their email and password credentials.
- The registered user can have types: user, moderator.
- To change the user type, registered users should use a Special Code in their personal cabinet.
- Moderator: Has special rights, including the ability to see all messages and change the classification for messages.
- Topic Creation: Users can create new discussion topics.
- Topic Creation with Image: Option to include images when creating topics.
- Post Creation: Users can contribute to discussions by creating posts.
- Post Creation with Image: Ability to attach images to posts.
- Forum messages have classifications: unsorted, obscene, illegal, insulting, approved.
- Users without moderator rights can create unsorted messages.
- Users without moderator rights can see all their own messages and approved messages from other users.
- Like/Dislike System: Users can like or dislike posts.
- User Post Reactions: Each user can react (like/dislike) to a post only once.
- Post and Topic Management:
- Edit Permissions: Authors can edit their posts and topics.
- Deletion Permissions: Post authors can delete their posts.
- Search Bar: Includes a search bar to find topics or content.
- Sorting by Category: Dropdown menu and quick links for sorting topics by category.
- User Personal Cabinet: Provides a personal space for each user.
- Sorting Options:
- Liked Posts: Users can view posts they've liked.
- Created Posts: View a list of posts authored by the user.
- Created Topics: Access topics authored by the user.
- Sorting Options:
The session feature in this project is implemented using the github.com/google/uuid
package. A unique UUID (Universally Unique Identifier) token is generated and stored in cookies. On the server side, this token is associated with the user's ID in the SQL database.
- UUID Generation: The
github.com/google/uuid
package is utilized to generate a universally unique identifier for each session. - Cookie Storage: The generated UUID token is stored in cookies. Cookies provide a convenient and secure way to manage session data on the client side.
- We are using the SQLite driver. However, our application implements The Repository pattern, and to switch databases, the
DatabaseInt
interface (located in therepository
package) should be implemented for database systems. - To compile this go-sqlite3 package on Windows, you must have the gcc compiler installed.
- For example the TDM-GCC Toolchain can be found here
- Sets up the SQLite database by creating tables and ensuring a connection.
- Initializes the database and performs checks to ensure connectivity.
- We are using in-memory cache to parse HTML templates
- To turn on caching change AppConfig UseCache to
true
- sets up a basic HTTP server with route handlers for static files and various application endpoints, using the http.ServeMux as the multiplexer.
- The handlers are defined in the handler package, and the
routes
function is responsible for configuring the routing logic for the application.
- Sets up the server on a specified port.
- Calls the
run()
function for initial setup tasks. - Configures the HTTP server to listen on the specified port and handle requests using the
routes()
function.
- Initializes the application configuration (
config.AppConfig
) and initial data. - Registers custom types for serialization with the
encoding/gob
package. - Sets up database tables using
repository.MakeDBTables()
. - Sets up the repository (
handler.Repo
) and initializes the template cache for HTML rendering.
- Defines routes and their respective handlers using
http.HandleFunc
. - Handles serving static files (CSS, logos, avatars) using
http.FileServer
andhttp.StripPrefix
.
Repository
holds application configuration and database connections.AppConfig
stores application-specific settings like cache configurations, loggers, and environment flags.
LoginHandler
,RegisterHandler
,HomeHandler
, etc., manage specific HTTP endpoints.- Examples:
LoginHandler
handles login logic and redirects;RegisterHandler
manages user registration and interactions with the database;HomeHandler
deals with displaying home page content and thread creation.
- Contains functions for validating form data (e.g., email formats, password lengths).
- Implements methods to interact with the SQLite database.
- Provides functions for user existence checks, fetching user details, creating threads, and handling thread/post queries.
- Utilizes Go's
html/template
package for rendering HTML templates. RendererTemplate
handles template rendering based on provided data.CreateTemplateCache
sets up and caches HTML templates for efficient rendering.
- Includes helper functions for error handling, template data setup, and managing HTTP responses.
- Defined structs like
User
,Thread
,Post
, etc., represent data models used throughout the application.
- Not optimized requests to the Database. Sometimes there are several requests per function or method.
- No Middleware.
- User's passwords are stored as strings in the Database.
- No pagination