The evolution of my ChatGPT prompts
Prompt Attempt #1
Produced a bunch of disparate parts, without unity and with a lot of redundancy
Create an openapi-2.0 specification for an API used for end-user notifications. This API should allow the developer to fetch one or more notifications to be shown inside a web or mobile applications to users. the notifications are either always sent or sent according to a calendar controlled by the site operator. When notification data is requested by the application it can also pass a unique user id, and the service will not return a notification previously sent to that user and dismissed by that user. the application can make an API call to inform the API that a user dismissed the notification so that it is not returned by the API on future calls.
Then I asked the AI to drill down:
now write typescript code that can support the above specification, using postgres as a data store and nestjs as the ORM.
Prompt Attempt #2
Produced a much more unified whole system with multiple parts.
Create an API that can serve end-user notification text strings to client applications for display by the client applications to end users. The notification text strings must be stored in a postgres database. Each notification includes a text string, and an optional start and end date when the notification should be served, as well as a page ID identifying which client application pages should receive the notification text. Notifications include a “canceled” boolean flag in case they have been configured but then should no longer be served to client applications. In creating this API, write the OpenAPI specification and all the code needed to run the service both on a laptop and in Google Compute Platform. The code should be written in modern typescript, and it should use nestjs to serve API requests. Please also write a nestjs migration file to create the appropriate schema in postgres and connect it to the API’s implementation. Client applications can pass in an optional page ID and user ID. If the client application passes a page ID, then only the notifications with a matching page ID will be served to that request. If the client application passes a user Id, then the API will check if any notifications that should be served at the time of the request were already served when this user ID passed in, and if so, the API should not serve that notification; if the user ID was never previously passed in for a given notification then the API should serve the notification (when appropriate if the notification includes the optional timeframe limits), and the API should store that user ID and notification ID combination to prevent serving that notification on subsequent client application requests by the same end-user of the client application. The API will need to be deployed in CloudRun containers, so you must create terraform scripts to allocate appropriate infrastructure in GCP to implement the API, for both staging and production environments. The terraform scripts should also configure a load balancer and app armor to protect the API. You should include full instructions on how to stand up the entire API on a laptop as well as on GCP. Also, create an openapi-2.0 specification for an API used for end-user notifications. this API should allow the developer to fetch one or more notifications to be shown inside a web or mobile applications to users. the notifications are either always sent or sent according to a calendar controlled by the site operator. when notification data is requested by the application it can also pass a unique user id, and the service will not return a notification previously sent to that user and dismissed by that user. the application can make an API call to inform the API that a user dismissed the notification so that it is not returned by the API on future calls.
Later, more successful prompts
Creating a backend:
Create a backend-oriented SDK written in typescript, that can connect to my API and fetch data from it. This backend SDK will authenticate to my API by providing an API key on a `Authentication: Bearer` header. There are only two endpoints in my API that matter to application builders: GET /notifications, which allows clients of my API to fetch all active notifications for a given context (the context parameters are sent as part of the GET query string), and `GET /notifications/user/:userId/reset` , which allows the client to reset all notifications that have been served for a given end user of that enterprise client site or mobile app, so that the notifications will be served again the next time `GET /notifications` is called. Enterprise customers will integrate the typescript SDK in their backend, but they will display notifications to their users in their front-ends, which may be built be react or nextjs or react-native. For these frontend applications, enterprise customers will need a second SDK that can pull the notification from the enterprise’s backend server, and display the notification to end users in a number of ways, including as Popups, Toast messages, and Banners. Explain how these two SDKs are built, how they’re deployed by my API’s clients, and how to put them into the npm repository (and update them there). Alternatively, if there is a way to securely implement the entire dataflow with a single front-end SDK without publishing an API key in the frontend source code, then that would be preferred.
Creating Pricing Support:
Write a Typorm migration file that adds full support for a users table along with several related tables to my current nestjs schema. User table records should contain a unique primary key uuid, a primary email address, one or more additional email addresses (up to 5 maximum), the user’s clerk.com id ( a string) , the date this user signed up, the last time the user logged in, and an ID (string) for their payment subscription at Stripe. Every user belongs to at least one organization but may belong to more than one. An organization record comprises a unique primary key uuid, the organization’s name (optional), and the date the organization was created. Users can belong to zero or more organizations. The user record should also store a single, optional, pricing model choice (foreign key to a pricing model record). Pricing model records contain a primary key uuid, a date the pricing model record was created, a name , a price per month, a price per year, a maximum number of notifications served per month, and a cost for any notifications over the maximum, in fractional dollars. Initially, there are just three pricing models: “Beginner”, “Pro”, “Enterprise”, at a price per month of $5, $20, and $50 respectively, with maximum notifications of 1000, 10000, and 100000 respectively, and finally with an overage price per notification of $0.05, $0.01, $0.005 respectively.
Extending the schema for user accounts & organizations 2/1/24
Write a Typorm migration file that adds full support for a users table along with several related tables to my current nestjs schema. User table records should contain a unique primary key uuid, a primary email address, one or more additional email addresses (up to 5 maximum), the user’s clerk.com id ( a string) , the date this user signed up, the last time the user logged in, and an ID (string) for their payment subscription at Stripe. Every user belongs to at least one organization but may belong to more than one. An organization record comprises a unique primary key uuid, the organization’s name (optional), and the date the organization was created. Users can belong to zero or more organizations. The user record should also store a single, optional, pricing model choice (foreign key to a pricing model record). Pricing model records contain a primary key uuid, a date the pricing model record was created, a name , a price per month, a price per year, a maximum number of notifications served per month, and a cost for any notifications over the maximum, in fractional dollars. Initially, there are just three pricing models: “Beginner”, “Pro”, “Enterprise”, at a price per month of $5, $20, and $50 respectively, with maximum notifications of 1000, 10000, and 100000 respectively, and finally with an overage price per notification of $0.05, $0.01, $0.005 respectively.
Creating an OpenAPI Spec and docs
Create an openapi-2.0 specification for an API used for end-user notifications. this API should allow the developer to fetch one or more notifications to be shown inside a web or mobile applications to users. the notifications are either always sent or sent according to a calendar controlled by the site operator. when notification data is requested by the application it can also pass a unique user id, and the service will not return a notification previously sent to that user and dismissed by that user. the application can make an API call to inform the API that a user dismissed the notification so that it is not returned by the API on future calls. Write typescript code that can support the above specification, using postgres as a data store and nestjs as the ORM. Show how developer documentation can be generated automatically for this spec.
Want to learn more about This Is Not A Drill! ? Just head on over to our home page.
Comments ()