Skip to content

Conversation

@coolwednesday
Copy link
Member

@coolwednesday coolwednesday commented Sep 11, 2025

Add Store Layer Generator to gofr-cli

Pull Request: Enhanced Store Generator & Documentation Overhaul

Overview

Key deliverables:

  1. generator.go
  2. templates.go – all code-gen templates extracted into constants with trimmed whitespace, improved spacing, and descriptive comments.
  3. example.yaml – end-to-end sample that mixes external and generated models across four stores (user, product, order, category) showcasing every query & return type.
  4. README.md – expanded guide covering:
    • robust appending logic and duplicate prevention in stores/all.go
    • CLI commands (init / generate) and multi-store workflow
    • step-by-step main.go integration, registry usage, DI pattern, env overrides
    • advanced YAML examples, troubleshooting tips, and linter guarantees.
  5. Tested Improvements
    • correct handling of import sections whether absent or present
    • explicit file-close calls inside loops
    • fallback regeneration when registry parsing fails

How to Test

  1. gofr store init -name=user then gofr store init -name=product – check stores/all.go appends without dupes.
  2. gofr store generate -config=example.yaml – generates four stores and a clean registry; go vet ./... and go test succeed.

Backward Compatibility

  • Single-store YAML format is supported.
  • Existing stores/all.go files are preserved—new stores append safely.
  • No breaking API changes to generated interfaces or method signatures.

Next Steps

  • Optional: add integration tests that compile generated code in CI.
  • Consider packaging CLI as a standalone binary for non-GoFr projects.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a comprehensive store layer generator to gofr-cli that generates GoFr-compatible store interfaces and implementations from YAML configuration files. The generator supports multi-store architecture with external model referencing and smart generation features.

  • Adds YAML-driven store layer code generation with CRUD operations support
  • Implements multi-store architecture allowing multiple isolated stores in a single configuration
  • Introduces external model referencing to use existing model files instead of generating new ones

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

File Description
store/generator.go Core generator implementation with YAML parsing, templating, and file generation logic
store/example.yaml Comprehensive example configuration demonstrating multi-store setup with external and generated models
store/README.md Detailed documentation covering features, usage, configuration options, and best practices
main.go Integration of store commands into the CLI application

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Umang01-hash
Copy link
Member

@coolwednesday Looks like your PR has some code quality issues:
https://github.com/gofr-dev/gofr-cli/actions/runs/17641393880/job/50129112308?pr=64

Can we please fix them.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Store layer for GoFr Framework Users

2 participants