Basic project structure for api/frontend
I've a small project I wanna build, but it'll need a frontend and a backend.
I'd like to learn some Blazor, so I'll use that as Frontend and normal asp.net w/controllers for backend.
I'm kinda stuck on project naming and organization though, do I use something like clean architecture, even if my project is way too small for that or do I just use like a
*.Api
, *.Blazor
and *.Common
?
What should be the recommended there to keep it simple as much as possible?22 Replies
Don't worry about that stuff for now.
Just build it first
After you finish building it is when you look back on it and make it better.
Yeah just go through the very basic tutorials of blazor and asp.net Just enough to build the very basics of what you want.
until you end up with a legacy codebase nobody wants to touch because its too much while also holding back implementing new features :SCgetoutofmyhead:
That is because they skipped the "make it better" part
It's like writing a book. The first draft is always shitty.
Especially when you haven't built it before
Even better re-build it from scratch better than the previous one. If you run out of ideas on how to make it better, ask someone really good how they would make it better. I guarantee they would have some ideas.
wdym?
I have "2 projects" to build though
and there is stuff like models and such that should be in both projects
no time for that in the moment, sry
Are you using visual studio?
vscode
I like my memory, kinda
If you are, just make a solution with three projects. One is the blazor project, one is an asp.net webapi project, and the last one is a shared class library project.
Then reference the shared library in both of the other two
You can do all of this with the dotnet cli
Wdm?
vs needs too much memory for anything
but like, what should I name those too
I'm mostly having naming problems
Idk what you are building but I name them like this: <project_name>Frontend, <projectname>API, <project_name>Shared
Simple as
ah ok
should the blazor server do any db calls?
that's a problem I've been having too, as it kinda makes sense, but not really
Do you need a db for what you are building?
@Sun「無用」 ?
If it is, read up on a "code first database" in "entity framework core."
yea
ik about those, I'm just thinking about architecture rn
Blazor server is not the same thing as blazor.
I just did
dotnet new blazor
and hoped for the bestYeah that is just blazor you are good
If you have a separate API, you would not do database queries in your blazor app
Yeah db queries happen at your api
Not your frontend
Your frontend shouldn't know what a database is
@Sun「無用」
welp
lemme get 100 spinner animations then
Why is that?
for when stuff are loading, my apis are always bad
How many records were you trying to load?
@Sun「無用」
wdym?
sry, was coding
and changing themes yet again