P
Prismaβ€’4mo ago
zane

Issues deploying Flask + Prisma-Client-Py backend to Vercel

Hello, I have this fullstack website project (https://github.com/mmamdouh4370/bouquet.gen) that uses a nextjs frontend with a flask backend using prisma as an orm for postgres. Whenever I try to host my project on vercel I run into issues with "prisma generate". Whether I include prisma generate, npx prisma generate, or python3 -m prisma generate in either my postinstall or build script I see in my build logs βœ” Generated Prisma Client Python (v0.13.1) to ./prisma/generated/client in 173ms, however if I try to access my api route in deployment I get a 500 and in my logs I get the error [ERROR] RuntimeError: The Client hasn't been generated yet, you must run prisma generate before you can use the client.. Any thoughts?
GitHub
GitHub - mmamdouh4370/bouquet.gen: Website that recommends flowers ...
Website that recommends flowers for a bouqet based on a user's prompt - mmamdouh4370/bouquet.gen
33 Replies
zane
zaneβ€’4mo ago
This is most likely not the right place to ask, but I have not found much help anywhere yet
JTB
JTBβ€’4mo ago
"build": "next build && npx prisma generate", in your Package...... 1. prisma generate 2. next build πŸ™‚ you need the client fΓΌr next build πŸ˜„ But why you use NextJS and Py? NextJS is Backend (NodeJS backend with React Frontend) ?
zane
zaneβ€’4mo ago
my build script needs to be npx prisma generate && next build but also i am running into problems with npx prisma generate, prisma client py needs prisma ver 5.11 while vercel node modules only has ver 5.15, so I have to run my generate via python3 -m prisma generate I also have to make my generator provider python3 -m prisma instead of prisma-client-py i read online prisma-client-py = python -m prisma but vercel only seems to work with python3
JTB
JTBβ€’4mo ago
But why Python ? Just use nextjs?
zane
zaneβ€’4mo ago
i am very new and silly :cowboy:
JTB
JTBβ€’4mo ago
You don’t need python
zane
zaneβ€’4mo ago
but also I do want to use ai for this project down the line and was recommended to use a python backend
JTB
JTBβ€’4mo ago
Than split it in two applications , but not like this And you can use ai with langchain in nextjs, too Build one service for ai and one application with nextjs. Nextjs use that service and finish
zane
zaneβ€’4mo ago
mmm i see can i still host both for free?
JTB
JTBβ€’4mo ago
The question is, what are you planning to do? Do you want to develop your own AI? Then the Free-Horster won't be enough. If you just want to use an AI, I would only use nextjs with langchain.
zane
zaneβ€’4mo ago
Develop my own, for now my projects using open ais api but I want to develop my own small scale nlp model for this also tried running with
"build": "python3 -m prisma generate && next build",
"postinstall": "pip3 install -r requirements.txt"
"build": "python3 -m prisma generate && next build",
"postinstall": "pip3 install -r requirements.txt"
and I still get the issue in logs for the client not being generated
JTB
JTBβ€’4mo ago
You won't be able to develop your own AI that way. You need a lot of resources and knowledge. Do you want a classification, neural network, aggregatio You won't be able to do what you want to do.
zane
zaneβ€’4mo ago
ah unfortunate :(
JTB
JTBβ€’4mo ago
Introduction | πŸ¦œοΈπŸ”— Langchain
LangChain is a framework for developing applications powered by large language models (LLMs).
zane
zaneβ€’4mo ago
I had some friends say it is possible though? the purpose of the ai was to take in a 1-4 word prompt and return a list of flowers that relate to it
JTB
JTBβ€’4mo ago
Maybe you should learn the basics first?
zane
zaneβ€’4mo ago
that is very true 😭 i am going completely off what they say I know next to nothing about ml/ai lol but for now especially if what I had wanted to do is not possible, how can I go about properly deploying what I have? I sent the msg a lil up but I redeployed with your suggested build command and got the same result and also didnt see anything in the build logs this time around for making the prisma client
JTB
JTBβ€’4mo ago
This is not possible in the way you intend.
zane
zaneβ€’4mo ago
Deploying Flask + Prisma-client-py with Nextjs?
JTB
JTBβ€’4mo ago
Try to make a Basis Template with NextJs (+Tailwind), Prisma, Postgress and than dont use npm again .-D Deploying Flask + Prisma-client-py with Nextjs? That dont make Sence is like you say, i need a Farrari, Opel, Ford and all with one Controller It's not even the same language
zane
zaneβ€’4mo ago
Like what I originally wanted to do, for now my program simply makes api calls to openai and google imgs through my flask backend that connects to my nextjs frontend. Ive seen other projects do this perfectly fine including the vercel example page. The problem I'm having is with using prisma as the generate client stuff works weirld with vercel and prismas python client. If I just comment out my db api routes and get rid of anything related to prisma I can do everything else my backend wants to do
JTB
JTBβ€’4mo ago
But NextJS is not a frontend
zane
zaneβ€’4mo ago
It's fullstack yes but can I not use it as a frontend only?
JTB
JTBβ€’4mo ago
nope that where react
zane
zaneβ€’4mo ago
https://vercel.com/templates/next.js/nextjs-flask-starter https://codevoweb.com/how-to-integrate-flask-framework-with-nextjs/#comments Two tutorials one official one not that go over how to do what my project does. I can do what they do but again it is just using prisma
JTB
JTBβ€’4mo ago
Sorry, but you should learn the basics first. They use NEXTJS and Python as a serverless function. So as a separate service.
zane
zaneβ€’4mo ago
I'm using flask for serverless functions no ? Im sorry but im really confused (I of course really appreciate and respect your input and time please do not take my confusion as disrespect)
JTB
JTBβ€’4mo ago
You should rather ask yourself what you intend to do. Python is good for data analysis and everything that has to do with data manipulation. Flask is a framework for Python. You want to use a full-stack framework (NextJs) in JS that is intended for web applications. In other words, you have 2 different programming languages and 2 frameworks in one go, plus you want to make a database connection via an ORM and and and.... That's way too much for a beginner and I don't think it's feasible the way you envision it. If you really want to go through with it, you should look into micro services and their pros and cons beforehand. No programmer would actually build it the way you are trying to do it. These are only problems in maintainability, scaling and and and....
zane
zaneβ€’4mo ago
This does sound like a whole lot and I get you
JTB
JTBβ€’4mo ago
From the architectur alone, you should separate the applications. You use NextJs (Fullstack) for everything web related, if you really need Python, you can use that as a separate service to manipulate data. I work a lot with AI myself at work, currently langchainJS makes Python superfluous for me. (I'm not talking about analytics, but purely about the web application). If you want to work with AI and make it available to users, you can do everything in NextJS and forget python.
zane
zaneβ€’4mo ago
I don't know if I should refactor my whole project now though as if I'm not gonna be able to do the whole personal ai thing then the projects mostly completed and deployments the next thing If deployment means switching off an orm to just raw queries I think that's my best option and I should keep your wisdom in mind for the future I never knew nextjs had good compatibility with ai development that's cool to know
JTB
JTBβ€’4mo ago
Good Luck πŸ™‚
zane
zaneβ€’4mo ago
Thank you!
Want results from more Discord servers?
Add your server