- User registration and authentication 🔐
- Session management with Gorilla Sessions 🍪
- JWT-based authentication middleware 🔑
- Post creation, listing, and detail views 📝
- Commenting system 💬
- Real-time updates with HTMX ⚡
- Responsive design with Bootstrap 📱
- TinyMCE advanced WYSIWYG HTML editor 🖋️
- Database management with Hasura using GraphQL with PostgreSQL 🗄️
- Containerization with Docker 🐳
- Backend: Go, GraphQL, PostgreSQL, Hasura
- Frontend: HTMX, Templ, Bootstrap, TinyMCE WYSIWYG HTML editor
- Containerization: Docker
- Go (version 1.18 or later) 🐹
- HTMX
- Templ
- Docker 🐳
- Hasura Account
- Air for live reloading
-
Clone the repository
git clone https://github.com/yourusername/blogflex.git cd blogflex
-
Register a Hasura Account
Register for an account at Hasura.
-
Install Go dependencies
go mod tidy
-
Set Up Environment Variables
Create a .env file in the root directory and add the necessary environment variables. For example: HASURA_ENDPOINT= HASURA_ADMIN_SECRET=
blogflex/
├── .vscode/
│ └── launch.json
├── internal/
│ ├── auth/
│ │ └── auth.go
│ ├── database/
│ │ └── database.go
│ ├── handlers/
│ │ ├── blog_handlers.go
│ │ ├── comment_handlers.go
│ │ ├── post_handlers.go
│ │ └── user_handlers.go
│ ├── helpers/
│ │ ├── format_time.go
│ │ ├── graphql.go
│ │ ├── logged_in.go
│ │ └── respond_error.go
│ │ └── truncate_words.go
│ └── middleware/
│ │ └── auth.go
│ └── models/
│ └── structs.go
├── router/
│ └── router.go
├── views/
│ ├── blog_list.templ
│ │ └── blog_list_templ.go
│ ├── blog_page.templ
│ │ └── blog_page_templ.go
│ ├── create.templ
│ │ └── create_templ.go
│ ├── detail.templ
│ │ └── detail_templ.go
│ ├── edit.templ
│ │ └── edit_templ.go
│ ├── index.templ
│ │ └── index_templ.go
│ ├── navbar_components.templ
│ │ └── navbar_components_templ.go
│ ├── navbar.templ
│ │ └── navbar_templ.go
│ └── post_list.templ
│ └── post_list_templ.go
├── .air.toml
├── .env
├── docker-compose.yml
├── go.mod
├── go.sum
├── main.go
└── README.md
To run the project locally, you have 3 options:
-
Launch Debugger:
- Open your project in Visual Studio Code.
- Set breakpoints as needed.
- Launch the debugger by pressing
F5
or by selectingRun > Start Debugging
from the menu.
-
Run Air:
-
Ensure you have Air installed for live reloading.
-
Start Air by running the following command in your terminal:
air
-
-
Run
go run main.go
Command:-
Open your terminal.
-
Navigate to the project directory.
-
Run the following command to start the application:
go run main.go
-
Note: Before running your project, make sure to generate the Templ files in the terminal to get the most updated UI. You can do this by running:
templ generate
To test the API endpoints, use the GraphQL queries in Hasura. Follow these steps:
-
Access Hasura Console:
- Log in to your Hasura account at Hasura.
- Navigate to your project's Hasura Console.
-
Navigate to the API Tab:
- In the Hasura Console, go to the "API" tab.
-
Run GraphQL Queries:
- Use the GraphQL query editor to write and execute your queries.
- You can test various API endpoints by constructing appropriate GraphQL queries and mutations.
-
Inspect Responses:
- Check the responses returned by the server to ensure your API is functioning correctly.
For more advanced testing, you can also use tools like Postman or Insomnia to send GraphQL requests to your Hasura endpoints.
This project is licensed under the MIT License - see the LICENSE file for details.
We welcome contributions! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (git checkout -b feature/your-feature-name).
- Make your changes.
- Commit your changes (git commit -m 'Add some feature').
- Push to the branch (git push origin feature/your-feature-name).
- Open a pull request.
Enjoy using BlogFlex! If you encounter any issues, please feel free to open an issue or submit a pull request.