Build Simple Task Web App with ProjectIDX, GO, GIN, HTMX, & Firebase
Simple To-Do List Application
This project is created to learn and explore various web development technologies including HTMX, Gin, Temple, Firebase Authentication, and Firestore. The aim is to build a web application that showcases these technologies in action.
Project Overview
A simple web application to manage to-do tasks, built with Golang, Gin framework, htmx for interactions, and Firebase for authentication and data storage.
Link to the repository: go-gin-htmx repository
Features
- User Authentication (Sign Up and Login)
- Task Management (Create, Read, Update, Delete tasks)
- Updates with htmx
Technology Stack
- Go 1.16+
- Gin Web Framework
- HTMX
- Templ
- Firebase Authentication & Firestore
- TailwindCSS & DaisyUI
- Dev Environment: Project IDX with Air (Live Reload)
Development Tools
- Air for live reloading
- Make for build automation
- TailwindCSS for styling
- Templ for type-safe templates
Prerequisites
- Go (version 1.16 or higher)
- Firebase Account
- Node.js and npm (for frontend dependencies)
Setup Instructions
Firebase Configuration
- Go to the Firebase Console and create a new project.
- Enable Authentication (Email/Password) in the Firebase project settings.
- Create a Firestore database in the Firebase project.
- Download the google-services.json file and place it in the root of your backend project.
IDX Configuration
If you're using Project IDX, create a .idx/idx.nix file in your project root:
This configuration:
- Sets up the development environment with necessary tools (Go, Node.js, Air, Make)
- Configures the Go extension for IDX
- Enables live preview with nodemon watching for changes in Go and HTML files
- Automatically rebuilds and restarts the application when files change
Backend Setup
- Clone the repository:
Project Structure
Features
Task Management
- Create, Read, Update, Delete (CRUD) operations for tasks
- Task status management (Done/Pending)
- Batch operations (Done all)
- Date-based task filtering
UI Components
The application uses Templ for type-safe HTML templates and HTMX for dynamic interactions:
Task Card Component
Task Navigation Component
Technical Features
HTMX Integration
- Optimistic UI updates
- Form validation
- Modal dialogs for task operations
Task Operations
-
Create Task
- Modal form with title and description
- Date selection
-
Update Task
- In-place editing
- Status updates
- Optimistic UI updates
-
Delete Task
- Confirmation modal
-
Batch Operations
- Mark all tasks as done
- Date-based filtering
UI Components
- DaisyUI components
- TailwindCSS for styling
- Responsive design
- Modal dialogs for operations
- Loading indicators
- Dropdown menus
Development Setup
Project Build Commands
The project uses a Makefile to automate common development tasks. Here's our Makefile with detailed explanations:
Make Commands Explained
-
make run
- Compiles TailwindCSS
- Builds the application using Nix
- Runs the compiled binary
-
make install
- Installs the Templ template engine
- Gets all Go dependencies
- Creates a vendor directory
- Ensures Go modules are tidy
- Downloads all Go dependencies
- Installs Node.js development dependencies
-
make tailwind
- Compiles TailwindCSS from styles/input.css to public/globals.css
-
make templ
- Watches for changes in Templ templates
- Automatically regenerates when changes are detected
- Provides hot reload via proxy to localhost:8080
-
make build
- Standard build process
- Generates Templ templates
- Compiles the Go application
-
make nix-templ
- Runs Templ generator in Nix environment
- Includes hot reload functionality
-
make build-in-nix
- Specialized build for Nix environment
- Uses Nix to run Templ generator
- Compiles the Go application
Key Features in Detail
Task Model
Modal Dialogs
Three types of modals are implemented:
- Create Task Modal (my_modal_1)
- Edit Task Modal (my_modal_2)
- Delete Confirmation Modal (confirm_delete_modal)
Date Management
- Date picker for filtering tasks
- Hidden date inputs for form submissions
- JavaScript functions for date synchronization:
Conclusion
This project demonstrates how to build a modern web application with minimal JavaScript using Go, HTMX, and Firebase. The combination of server-side rendering with Templ and dynamic updates via HTMX creates a smooth user experience while maintaining simplicity in the codebase.
Link to the repository: go-gin-htmx repository