liveBook · Manning

Chapter 6: Generating a software backend with Tabnine

What you will learn in chapter 6 of Coding with AI

The introduction connects the existing question database to the need for persistent test sessions that keep a test-taker’s questions available.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction connects the existing question database to the need for persistent test sessions that keep a test-taker’s questions available.

Key terms: session, question set, persist

6.1 Creating a session and our first bug

This section traces a duplicate-ID bug when creating question sets and shows how to test and refine Tabnine’s suggestions until new sessions work.

Key terms: session_id, question_sets, question_set_id, unique constraint, create_question_set, None, null value, SQLite, auto-increment, Tabnine Chat

6.2 Creating an index page

The section turns session creation into a user-controlled button action and adjusts the route and template so the index page also loads before a session starts.

Key terms: index.html, form, submit button, POST request, question session, GET, data, template, referenced before assignment, Tabnine

6.2.1 Persisting the session

The section uses a visible session ID to check session identity, explores cookie-based persistence with Tabnine, and shows why the suggested change needs refactoring.

Key terms: session_id, templates/index.html, run.py, cookie, Session object, session.sid, session ID, session, POST, refactor

6.2.2 Refactoring session creation

The section moves session creation into the index page, uses a cookie to retain the session ID, and shows why retaining that ID does not yet retain the question set.

Key terms: POST, index method, database connection, session ID, cookie, session_id, response.set_cookie, rendered template, question set, refresh

6.2.3 Refactoring our question set method

The section fixes question-set loading so a returning visitor keeps the questions associated with their session instead of receiving a new random set on each visit.

Key terms: session ID, cookie, question set, in-place refactoring

6.2.4 Creating an end session function that ends the test

The section adds a way to end a quiz session by deleting its cookie and refreshing the page, while emphasizing that AI-generated code still needs developer judgment.

Key terms: cookie, end the test, refresh the page, new session, AI as an accelerator, not an autopilot, domain knowledge, architectural goals

6.3 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 5: Using Blackbox AI to generate base code Chapter 7: Building user interfaces with ChatGPT →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.