Folder/File Naming/Structure Ideas
I want some ideas on how to organize a larger convex project. What file/folder naming conventions make sense?
Where have people put internal mutations, queries, actions, typescript functions, http layer stuff, etc? In a way that makes sense to them, and isnt overly complicated.
5 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
I usually do the following: convex folder => table related folder => 1 file per api function => export default
Example:
convex -> users -> getMe.ts -> export default query(...)
I put internal function where they are called, but if they are shared a lot, I put it in a dedicated folderI typically do something like this as well, but one layer deeper, and exporting helpers instead of Convex functions. Basically forms a "db layer".
Then I organize what I call the "api layer" by feature, this is where actual product development happens and things are more fast and loose. Not many rules here.
For node functions where needed I make a node suffixed file.
@erquhart curious to know, I suspect with that following layer it means your don't rely much on "triggers" which sort of magically adds extra behavior to the "write" command? If yes, is there any reason why?
This: https://stack.convex.dev/triggers#consider-explicit-function-calls-instead
first best practice of using triggers is don't use triggers lol