This guide will help you set up your Neon database for the Malify email client.
- Go to Neon Console
- Sign up or log in to your account
- Click "Create Project"
- Choose a project name (e.g., "malify")
- Select a region close to your users
- Click "Create Project"
- In your Neon project dashboard, click on "Connection Details"
- Copy the connection string that looks like:
postgresql://username:password@ep-xxx-xxx.region.aws.neon.tech/dbname?sslmode=require
-
Create a
.env.localfile in your project root:touch .env.local
-
Add your environment variables to
.env.local:# Neon Database DATABASE_URL="your_neon_connection_string_here" # JWT Secret for authentication (generate a random string) JWT_SECRET="your_super_secret_jwt_key_here_make_it_long_and_random" # Next.js NEXTAUTH_URL="http://localhost:3000" NEXTAUTH_SECRET="your_nextauth_secret_here"
Important: Replace the placeholder values with your actual values:
DATABASE_URL: Your Neon connection stringJWT_SECRET: A long, random string (at least 32 characters)NEXTAUTH_SECRET: Another random string for NextAuth
npm install-
Generate the database migration:
npm run db:generate
-
Push the schema to your Neon database:
npm run db:push
npm run dev- Open http://localhost:3000
- Click "create a new account"
- Fill in your details and register
- You'll be automatically logged in to your Gmail clone!
The application uses the following main tables:
- Stores user account information
- Handles authentication
- System folders (Inbox, Sent, Drafts, etc.)
- Custom user-created folders
- All email data including content, metadata, and status
- Supports threading, attachments, and labels
- Custom labels for organizing emails
- File attachments for emails
To view and manage your database with a GUI:
npm run db:studioThis will open Drizzle Studio in your browser where you can:
- View all tables and data
- Run queries
- Manage your database schema
| Variable | Description | Example |
|---|---|---|
DATABASE_URL |
Neon database connection string | postgresql://user:pass@host/db?sslmode=require |
JWT_SECRET |
Secret key for JWT tokens | your-super-secret-key-here |
NEXTAUTH_URL |
Your app's URL | http://localhost:3000 |
NEXTAUTH_SECRET |
NextAuth secret key | another-secret-key |
- Ensure your DATABASE_URL is correct
- Check that your Neon database is running
- Verify your IP is allowed (Neon allows all IPs by default)
- Make sure you've run
npm run db:generatebeforenpm run db:push - Check that your DATABASE_URL environment variable is set
- Verify JWT_SECRET is set and is a long, random string
- Clear your browser cookies and try again
For production deployment:
- Set up your production environment variables
- Use a production-ready JWT_SECRET
- Update NEXTAUTH_URL to your production domain
- Consider setting up database connection pooling for better performance
- Never commit
.env.localto version control - Use strong, unique secrets for JWT_SECRET and NEXTAUTH_SECRET
- Regularly rotate your secrets in production
- Consider using environment-specific databases (dev, staging, prod)