Generative AI Python Flask GCP

Personal finance is one of those areas where the products and options are complex enough that a lot of people just avoid dealing with them. I wanted to see how far a conversational AI interface could go toward closing that gap: something that gives tailored financial guidance in plain language, and gets better at it the more you talk to it. That's what became Finwise.

The stack

I kept the stack deliberately simple so I could focus on the AI integration instead of fighting infrastructure:

  • Python + Flask for a lightweight backend API
  • HTML/CSS with Jinja2 for server-rendered, responsive templates
  • OpenAI / Vertex AI for the underlying generative model
  • Google Cloud Platform for a scalable, production-style deployment

How it works

The core of the backend is a single /chat route: it takes the user's message, forwards it to the model, and returns the response as JSON.

@app.route('/chat', methods=['POST'])
def chat():
    user_input = request.json.get('user_input')
    response = openai.Completion.create(
        engine="text-davinci-003",
        prompt=user_input,
        max_tokens=150
    )
    return jsonify({'response': response.choices[0].text.strip()})

I pulled the actual model call into its own function rather than inlining it in the route. It's a small separation, but it meant I could test and tune the prompt logic independently of the HTTP layer:

def get_financial_advice(user_query):
    response = openai.Completion.create(
        engine="text-davinci-003",
        prompt=user_query,
        max_tokens=150
    )
    return response.choices[0].text.strip()

On the frontend, a minimal Jinja2 template keeps the interaction focused: a title, a chatbox, and the model's response rendered straight into the page. No extra chrome to distract from the conversation.

What it does well

  • Generates context-aware financial advice from a plain-text question
  • Feels like a conversation, not a form
  • Adapts as the conversation history grows
  • Runs on infrastructure that can scale past a demo

What I took away from it

This project touched three areas I wanted to get sharper on at once: prompt engineering and NLP integration, full-stack API design (Flask backend, templated frontend, the client-server contract between them), and deploying something AI-backed on GCP instead of just running it locally. Building something end-to-end, rather than a notebook experiment, is what actually surfaces the rough edges.

What's next

The natural next steps are a real financial dashboard (spending and savings analytics, account tracking), a mobile client, and hooking it up to actual banking data through real APIs so the advice is grounded in a user's real numbers instead of a text prompt alone.

Full source is on GitHub, and the original, longer write-up is on Medium if you want the full deep dive.