goforms

command module
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 20 Imported by: 0

README

GoFormX

A modern Go web application for form management with MariaDB backend.

Features

  • Email subscription system with validation
  • RESTful API using Echo framework
  • PostgreSQL database with migrations
  • Dependency injection using Uber FX
  • Structured logging with Zap
  • Rate limiting and CORS support
  • Comprehensive test coverage
  • Docker-based development environment
  • Health check monitoring

Tech Stack

  • Go 1.24
  • PostgreSQL 17
  • Echo v4 web framework
  • Uber FX for dependency injection
  • Zap for structured logging
  • Testify for testing
  • Task for automation

Quick Start

  1. Prerequisites:

    • Docker
    • VS Code with Dev Containers
    • Git
  2. Clone and Setup:

    git clone https://github.com/goformx/goforms.git
    cd goforms
    
  3. Start Development:

    • Click "Reopen in Container" when prompted
    • Copy environment file: cp .env.example .env
    • Install dependencies: task install
    • Start server: task dev
  4. View the application at http://localhost:8090

Documentation

Documentation is available in the docs directory:

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Development Setup

CSRF Configuration for Development

When running the frontend (localhost:5173) and backend (localhost:8090) on different ports, you need to configure CSRF properly for cross-origin requests:

  1. Set CSRF Cookie SameSite to Lax: This allows cookies to be sent in cross-origin requests
  2. Disable Secure Flag: In development, cookies don't need to be HTTPS-only
  3. Include CSRF Headers in CORS: Allow the X-Csrf-Token header

The application automatically configures these settings in development mode, but you can override them with environment variables:

# CSRF Configuration for Development
GOFORMS_SECURITY_CSRF_COOKIE_SAME_SITE=Lax
GOFORMS_SECURITY_SECURE_COOKIE=false

# CORS Configuration
GOFORMS_SECURITY_CORS_ENABLED=true
GOFORMS_SECURITY_CORS_ORIGINS=http://localhost:5173
GOFORMS_SECURITY_CORS_CREDENTIALS=true
Troubleshooting CSRF Issues

If you encounter 403 Forbidden errors with CSRF token mismatch:

  1. Clear Browser Cookies: Old CSRF cookies may be invalid
  2. Restart the Backend: Ensure new CSRF configuration is loaded
  3. Check Browser Console: Verify CSRF token is being sent in headers
  4. Check Network Tab: Ensure cookies are being sent with requests

The frontend automatically includes CSRF tokens in the X-Csrf-Token header for all non-GET requests.

Documentation

Overview

Package main is the entry point for the GoForms application. It sets up the application using the fx dependency injection framework and manages the application lifecycle including startup and graceful shutdown.

Directories

Path Synopsis
internal
application
Package application provides the application layer components and their dependency injection setup.
Package application provides the application layer components and their dependency injection setup.
application/constants
Package constants provides application-wide constants for HTTP status codes, paths, timeouts, headers, content types, and other configuration values.
Package constants provides application-wide constants for HTTP status codes, paths, timeouts, headers, content types, and other configuration values.
application/handlers/web
Package web provides HTTP handlers for web-based functionality including authentication, form management, and user interface components.
Package web provides HTTP handlers for web-based functionality including authentication, form management, and user interface components.
application/middleware
Package middleware provides framework-agnostic middleware interfaces and abstractions for the GoForms application.
Package middleware provides framework-agnostic middleware interfaces and abstractions for the GoForms application.
application/middleware/access
Package access provides access control middleware and utilities for the application.
Package access provides access control middleware and utilities for the application.
application/middleware/auth
Package auth provides authentication middleware and utilities for protecting routes and managing user authentication state.
Package auth provides authentication middleware and utilities for protecting routes and managing user authentication state.
application/middleware/chain
Package chain provides chain building logic for middleware orchestration.
Package chain provides chain building logic for middleware orchestration.
application/middleware/context
Package context provides middleware utilities for managing request context and user authentication state.
Package context provides middleware utilities for managing request context and user authentication state.
application/middleware/core
Package core provides the core interfaces and types for middleware functionality.
Package core provides the core interfaces and types for middleware functionality.
application/middleware/request
Package request provides utilities for HTTP request parsing and validation middleware.
Package request provides utilities for HTTP request parsing and validation middleware.
application/middleware/session
Package session provides session management middleware and utilities for the application.
Package session provides session management middleware and utilities for the application.
application/response
Package response provides HTTP response handling utilities including error handling, response building, and standardized response formats.
Package response provides HTTP response handling utilities including error handling, response building, and standardized response formats.
application/validation
Package validation provides comprehensive form validation utilities for validating form schemas, submissions, and generating client-side rules.
Package validation provides comprehensive form validation utilities for validating form schemas, submissions, and generating client-side rules.
domain
Package domain provides domain services and their dependency injection setup.
Package domain provides domain services and their dependency injection setup.
domain/common/errors
Package errors provides domain-specific error types and utilities for consistent error handling across the application.
Package errors provides domain-specific error types and utilities for consistent error handling across the application.
domain/common/events
Package events provides event handling infrastructure for the domain layer.
Package events provides event handling infrastructure for the domain layer.
domain/common/interfaces
Package interfaces provides common interfaces used throughout the domain layer for validation, repositories, and other cross-cutting concerns.
Package interfaces provides common interfaces used throughout the domain layer for validation, repositories, and other cross-cutting concerns.
domain/common/repository
Package repository provides common repository interfaces and utilities for data access patterns used throughout the domain layer.
Package repository provides common repository interfaces and utilities for data access patterns used throughout the domain layer.
domain/entities
Package entities provides domain entities that represent the core business objects in the application, including users, forms, and other domain models.
Package entities provides domain entities that represent the core business objects in the application, including users, forms, and other domain models.
domain/form
Package form provides form-related domain services and business logic.
Package form provides form-related domain services and business logic.
domain/form/event
Package event defines domain events and event interfaces for form-related actions.
Package event defines domain events and event interfaces for form-related actions.
domain/form/events
Package form provides form-related domain events and event handling functionality for managing form lifecycle and state changes.
Package form provides form-related domain events and event handling functionality for managing form lifecycle and state changes.
domain/form/model
Package model contains domain models and error definitions for forms.
Package model contains domain models and error definitions for forms.
domain/user
Package user provides user repository interfaces for domain persistence.
Package user provides user repository interfaces for domain persistence.
infrastructure
Package infrastructure provides core infrastructure components and their dependency injection setup.
Package infrastructure provides core infrastructure components and their dependency injection setup.
infrastructure/config
Package config provides configuration management for the GoForms application.
Package config provides configuration management for the GoForms application.
infrastructure/database
Package database provides database connection and ORM utilities for the application.
Package database provides database connection and ORM utilities for the application.
infrastructure/event
Package event provides in-memory event bus and publisher implementations.
Package event provides in-memory event bus and publisher implementations.
infrastructure/logging
Package logging provides a unified logging interface
Package logging provides a unified logging interface
infrastructure/metrics
Package metrics provides application metrics collection and reporting functionality for monitoring application performance and health.
Package metrics provides application metrics collection and reporting functionality for monitoring application performance and health.
infrastructure/middleware
Package middleware provides infrastructure layer middleware adapters for integrating framework-agnostic middleware with specific HTTP frameworks.
Package middleware provides infrastructure layer middleware adapters for integrating framework-agnostic middleware with specific HTTP frameworks.
infrastructure/repository/common
Package common provides shared utilities and types for repository implementations including error handling, pagination, and common data structures.
Package common provides shared utilities and types for repository implementations including error handling, pagination, and common data structures.
infrastructure/repository/form
Package repository provides the form repository implementation
Package repository provides the form repository implementation
infrastructure/repository/form/submission
Package repository provides the form submission repository implementation
Package repository provides the form submission repository implementation
infrastructure/repository/user
Package repository provides the user repository implementation
Package repository provides the user repository implementation
infrastructure/sanitization
Package sanitization provides utilities for cleaning and validating user input to prevent XSS attacks, injection attacks, and other security vulnerabilities.
Package sanitization provides utilities for cleaning and validating user input to prevent XSS attacks, injection attacks, and other security vulnerabilities.
infrastructure/server
Package server provides HTTP server setup and lifecycle management for the application.
Package server provides HTTP server setup and lifecycle management for the application.
infrastructure/validation
Package validation provides infrastructure-level validation utilities and interfaces.
Package validation provides infrastructure-level validation utilities and interfaces.
infrastructure/version
Package version provides version information for the application.
Package version provides version information for the application.
infrastructure/web
Package web provides utilities for handling web assets in the application.
Package web provides utilities for handling web assets in the application.
presentation
Package presentation provides the presentation layer components and their dependency injection setup.
Package presentation provides the presentation layer components and their dependency injection setup.
presentation/templates/pages
Package pages provides page-level template components.
Package pages provides page-level template components.
presentation/templates/shared
Package shared provides common utilities and helper functions for use across template components and presentation layer.
Package shared provides common utilities and helper functions for use across template components and presentation layer.
presentation/view
Package view provides types and utilities for rendering page data and templates.
Package view provides types and utilities for rendering page data and templates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL