Void-HTML is a lightweight microblogging and social networking platform built with Go, Fiber, and server-rendered HTML. Inspired by the "Laravel Bootcamp" approach, Void-HTML takes a deep dive into building robust web applications using Go's performance and simplicity while adhering to clean architecture principles.
This repository is the HTML version of the Void platform. A separate repository (e.g., Void-Inertia or Void-Vue) is planned for a more dynamic, client-driven front-end using Inertia/Vue.
Void-HTML is designed to be a minimalistic yet fully functional microblogging platform. Its primary focus is to:
- 🏠 Allow users to register, login, and manage their profiles.
- 📝 Enable users to post "shouts" (short messages) and view a global feed.
- 🔔 Provide a robust notification system using RabbitMQ for real-time interactions.
- 🏗 Serve as a learning ground for modern web development patterns, inspired by frameworks like Laravel but leveraging the speed of Go.
-
🔒 User Authentication & Session Management
Secure registration, login, and logout functionality. Sessions are managed via custom middleware to ensure that user credentials and sessions are managed reliably. -
🖥 Server-Rendered HTML
Uses Fiber's HTML templating engine to render pages on the server side, making it a great starting point for projects that rely on traditional multi-page application (MPA) patterns. -
🔔 Real-Time Notifications
Leverages RabbitMQ to implement an asynchronous notification system that informs users about new shouts and interactions. -
💬 Microblogging Capabilities
Users can post shouts, view a global feed, and interact through "echoes" (replies), all managed via RESTful endpoints and rendered templates. -
🎨 Profile Customization
Each user has a customizable profile complete with a bio and avatar upload functionality. Images are processed using the imaging library for resizing. -
🗄 ORM-Based Data Management
Built on GORM and SQLite for efficient data storage and retrieval with minimal configuration.
Void-HTML is structured into clearly defined modules:
- 📁 cmd/server: Contains the main application entry point.
- 📁 internal: Houses the core business logic including:
- 🗄 db: Database initialization and migrations.
- ⚡ events: Event definitions and publisher.
- 🌐 handlers: HTTP route handlers for different functionalities (authentication, user management, shouts, notifications).
- 🔐 middleware: Custom middleware for session management and authentication checks.
- 📝 models: GORM models for Users, Shouts, Echoes, and Notifications.
- 📢 services/notifications: Logic for processing and sending notifications.
- 📁 pkg: Contains reusable packages like RabbitMQ integration and session management.
- 📁 web: Contains static assets and HTML templates.
User authentication is managed using middleware:
- 🔑 GetUserFromSession: Retrieves the user ID from the session (using a custom session package) and stores it in the request context under
c.Locals("UserID")
. - 🚪 RequireLogin: Ensures that endpoints requiring authentication have a valid user ID. If not, it redirects to the login page.
This flow ensures that all route handlers can safely rely on the presence of a valid user ID without directly handling session logic.
When a new shout is created:
- 📝 The shout is saved to the database.
- 📡 An event is generated (conforming to the
ShoutEvent
interface). - 📨 The event is marshaled to JSON and published via RabbitMQ.
- 🔔 A separate service consumes these notifications and sends real-time alerts to users (excluding the shout's author).
This decoupled, event-driven architecture allows for scalability and a responsive user experience.
- 🔵 Go: The primary programming language, offering simplicity and performance.
- 🚀 Fiber: A fast, Express-inspired web framework for Go.
- 🗄 GORM: An ORM library that simplifies database interactions.
- 🛢 SQLite: A lightweight and self-contained SQL database engine.
- 📨 RabbitMQ: A robust message broker used for asynchronous event handling and notifications.
- 🖥 HTML Templating: Server-side rendering using HTML templates for dynamic content delivery.
- 🖼 Imaging: A Go package for image processing (resizing avatars).
- 🟢 Go 1.23.1 or later installed.
- 📡 RabbitMQ: Running locally or accessible via network.
- 💡 Basic familiarity with Go modules and command-line operations.
-
Clone the repository:
git clone https://github.com/yourusername/Void-HTML.git cd Void-HTML
-
Download dependencies:
go mod download
-
Configuration:
Update the RabbitMQ connection string in
cmd/server/main.go
if needed:if err := rabbitmq.Init("amqp://guest:guest@localhost:5672/"); err != nil { ... }
-
Running the Application
You can run the application using Air for live reloading during development:
air
Or build and run manually:
go build -o void ./cmd/server
./void
Then open your browser and navigate to http://localhost:3000
.
Contributions are welcome! To get started:
- 🍴 Fork the repository.
- 🌱 Create a new branch for your feature or bug fix.
- ✅ Ensure your changes follow the project's coding standards and pass all tests.
- 🔄 Open a pull request with a detailed description of your changes.
For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License. See the LICENSE file for details.
-
🚀 Inspired by Laravel Bootcamp:
The project draws inspiration from the Laravel Bootcamp series, translating many of its best practices and architectural decisions into the Go ecosystem. -
🎯 Future Plans:
A version using Inertia/Vue is planned, which will provide a more dynamic, SPA-like front end while keeping a unified backend API. -
💡 Feedback & Support:
Feel free to open issues if you encounter any bugs or have suggestions for improvements. Your feedback is valuable!