Skip to content

Conversation

@lucat1
Copy link
Contributor

@lucat1 lucat1 commented Sep 6, 2025

While scanning through the code I saw that API response types where defined in models, which should hold the DB structures. I think defining the API types in there is bad practice, we want to have separation between the internal data structures and what's exposed in the API.

This PR does some refactoring and moves all structures defined in models that belong to the API interface in the api package.
I have a feeling (but didn't check) the types in model are also being directly JSON serialized (I get this feeling from the inlining of the gorm.Model struct). This should also be avoided for the same reason as before.
I think that kind of refactoring can probably be done by claude code/gemini without human intervention, but I didn't bother for this PR.

As a side note: What is the purpose of AnswerVersions? why is the name plural? I assume the Answer field is a reference to the Answer ID column. Shouldn't it be marked as such in SQL through gorm annotations?

This is just me raising what are clearly nits. If code quality is not a priority right now, just ignore them and feel free to close this PR :)

@leonardo3130
Copy link
Collaborator

leonardo3130 commented Sep 6, 2025

Changes on models seem good to me. I initially moved them all inside models.go thinking it was a good thing, but separation between API structs and internal data structures is more important, as you said.

The purpose of AnswerVersions is to keep track of the history of an answer (#27 ).
The name is plural because I made a mistake.
You are also right on the missing gorm annotation.

As I said before, these changes can be merged in my opinion. Let's see what @samuelemusiani has to say.

@samuelemusiani
Copy link
Member

Thanks Luca!

@samuelemusiani samuelemusiani merged commit 5ad52d9 into main Sep 7, 2025
2 checks passed
@samuelemusiani samuelemusiani deleted the lucat1/response-writing branch September 12, 2025 11:28
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.

4 participants