Now that my iPhone mobile app is working as intented functionally, I need to persist the data of my users using my own backend API and database instead of locally on the iPhone.
Create a Next.js API backend for this iOS mobile app with the following stack and structure:
- Next.js with App Router (API routes only, no frontend pages needed)
- Neon PostgreSQL database
- Drizzle ORM for database access
- NextAuth with Auth0 provider for authentication
- TypeScript with strict mode
- Deploy to Vercel
Auth0 must be configured to protect the API and authenticate users of the iOS mobile app.
Analyse the code of the mobile app and create the database schema required to store the user's data in the database instead of locally on the phone.
/app/api/ # API routes /lib/db/ # Database configuration
- index.ts # Drizzle client setup
- schema.ts # Database schema definitions /lib/auth.ts # NextAuth configuration /lib/permissions.ts # Authorization utilities /drizzle/ # Migration files /types/ # TypeScript type augmentations
- next-auth.d.ts # Extended session types
Generate all the boilerplate files with this structure, ready to customize for my specific data model.