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
This is most likely not the right place to ask, but I have not found much help anywhere yet
"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) ?
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
But why Python ? Just use nextjs?
i am very new and silly :cowboy:
You donβt need python
but also I do want to use ai for this project down the line
and was recommended to use a python backend
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
mmm
i see
can i still host both for free?
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.
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 and I still get the issue in logs for the client not being generated
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.
ah unfortunate :(
https://js.langchain.com/v0.2/docs/introduction/
Look that for JS
and NextJS
Introduction | π¦οΈπ Langchain
LangChain is a framework for developing applications powered by large language models (LLMs).
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
Maybe you should learn the basics first?
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
This is not possible in the way you intend.
Deploying Flask + Prisma-client-py with Nextjs?
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
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
But NextJS is not a frontend
It's fullstack yes but can I not use it as a frontend only?
nope
that where react
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
Sorry, but you should learn the basics first.
They use NEXTJS and Python as a serverless function. So as a separate service.
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)
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....
This does sound like a whole lot and I get you
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.
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
Good Luck π
Thank you!