how to structure fullstack nextjs project
Unanswered
American Chinchilla posted this in #help-forum
American ChinchillaOP
so im trying to create a discord bot dashboard in nextjs which would have an api controlling discord oauth2 and a nice react app displaying servers user is in etc what i dont understand what folders i should use to achieve that i have seen pages folder or app folder and im kinda lost
57 Replies
American ChinchillaOP
for reference i started this project quite a while ago but i made it in react frontend + nestjs backend https://github.com/DownDev/DiscordBotDashboard
now i wanted to come back to it but rewrite it to next
now i wanted to come back to it but rewrite it to next
there are tools like: https://github.com/t3-oss/create-t3-app that can make a good template (but it can be overwhelming because of all things it creates)
American ChinchillaOP
let me check it out
i can't say what the best one is, but this does seem decent
American ChinchillaOP
yeah its quite a lot of boilerplate
@American Chinchilla yeah its quite a lot of boilerplate
Atlantic menhaden
hey i want to do similar thing but dont exactly know how. you run discord bot with python or how does it work?
@Atlantic menhaden hey i want to do similar thing but dont exactly know how. you run discord bot with python or how does it work?
American ChinchillaOP
Yeah my bot is written in python
@American Chinchilla Yeah my bot is written in python
Atlantic menhaden
so you have frontend i nreact and then make api calls to discord bot? is that right?
and where is the bot runing?
tbh i would say do it both in js so you can share code...
American ChinchillaOP
Nope my bot doesnt have any api its just a python code interacting with discord api
so... what will the "discord bot dashboard" do?
American ChinchillaOP
Now i want to create a website for it and somehow connect them so they use the same database
@riský so... what will the "discord bot dashboard" do?
American ChinchillaOP
You will be able to set some configurations for your guild
Etc
yeah, and if you use TS, you can share types and such
if JS, you can still have helper functions for both
but imo doing the same language I would say, provides better dx
@American Chinchilla Nope my bot doesnt have any api its just a python code interacting with discord api
Atlantic menhaden
but the python code is runing where? in server, docker or on the same thing as frontend?
American ChinchillaOP
its other project running in docker
Atlantic menhaden
and you are able to interact with it from frontend?
American ChinchillaOP
I thought about making the dashboard project also a Docker image and then implementing it in bot as dependency
@Atlantic menhaden and you are able to interact with it from frontend?
American ChinchillaOP
?
@American Chinchilla ?
Atlantic menhaden
sorry
i want to explain what i want to do and how it might be similar to your project
i would like to have next app dashboard like you, and run some long runing script or bot, same as you
i would like to have python bot runing and checking some data from db, but i want to be able to start and stop and perhaps edit from my next.js frontend
i am not sure if that is possible to do in serverles, like vercel
bc now i can run python in docker no problem
American ChinchillaOP
hm i dont know how to approach it too
@Atlantic menhaden i am not sure if that is possible to do in serverles, like vercel
if you are doing normal bot, it uses websocketss, so that won't work
if you use http interactions, it would work, but i doubt you would use them (as you loose access to all events but interactions)
Atlantic menhaden
and you cant even run python on vercel via child-process right?
how can i access that "hello world" text in my next.js dashboard?
they only last 10sec
Atlantic menhaden
so what is the alternative?
make it in javascript and run at the same time as next.js?
American ChinchillaOP
i would say use webhook but i know nothin
use a vps...
@Atlantic menhaden make it in javascript and run at the same time as next.js?
if you don't use serverless this works i believe
Atlantic menhaden
aha okay great
and the webhook thing? i also know nothing, so is that good or bad?
websoket just means that it is a always open connection - discord can sent you updates anytime
@American Chinchilla i would say use webhook but i know nothin
American ChinchillaOP
i meant websocket 💀
@American Chinchilla i meant websocket 💀
Atlantic menhaden
how would i do that?
i asumed you meant that
American ChinchillaOP
just noticed i wrote webhook
@Atlantic menhaden how would i do that?
American ChinchillaOP
you would set up a websocket connection between those 2
and send messages between
if doing that, make sure neither is serverless
but it is prob a good idea if they are running in a normal server
Atlantic menhaden
okay nice
@riský but it is prob a good idea if they are running in a normal server
Atlantic menhaden
what do you mean? will it work on serverless?
@American Chinchilla for reference i started this project quite a while ago but i made it in react frontend + nestjs backend https://github.com/DownDev/DiscordBotDashboard
now i wanted to come back to it but rewrite it to next
American ChinchillaOP
can you help me in process of rewriting this to next?
American ChinchillaOP
@riský ?
you know nestjs?