4.3 KiB
Local Development Setup Guide
This guide will help you set up the Vaishnavi Creation backend for local development without Docker.
Prerequisites
Make sure you have the following installed and running:
- Node.js 18+ ✅ (You have v22.14.0)
- PostgreSQL 15+ - Make sure it's running
- MongoDB 7+ - Make sure it's running
- Redis 7+ (Optional) - For caching and background jobs
Step 1: Configure Environment Variables
-
Copy the environment template:
cp .env.example .env -
Edit the
.envfile with your database credentials:For PostgreSQL, update the DATABASE_URL:
# Replace with your actual PostgreSQL credentials DATABASE_URL="postgresql://username:password@localhost:5432/vaishnavi_db?schema=public"Common PostgreSQL configurations:
- Default user:
postgres - Default password:
postgres(or whatever you set) - Default port:
5432 - Database name:
vaishnavi_db(we'll create this)
For MongoDB, update the MONGODB_URI:
# Usually this is fine for local MongoDB MONGODB_URI="mongodb://localhost:27017/vaishnavi_products"For Redis (Optional):
# Comment this out if you don't have Redis installed REDIS_URL="redis://localhost:6379" - Default user:
Step 2: Create PostgreSQL Database
Connect to PostgreSQL and create the database:
-- Connect to PostgreSQL (replace with your credentials)
psql -U postgres
-- Create the database
CREATE DATABASE vaishnavi_db;
-- Exit psql
\q
Windows Users: If you have PostgreSQL installed via installer, you might need to use pgAdmin or the command prompt with full path.
Step 3: Run the Setup Script
npm run setup
This script will:
- ✅ Check Node.js version
- ✅ Install dependencies
- ✅ Generate Prisma client
- ✅ Create database schema
- ✅ Seed the database with sample data
Step 4: Start Development Server
npm run dev
The API will be available at http://localhost:3000
Troubleshooting
PostgreSQL Connection Issues
-
Make sure PostgreSQL is running:
- Windows: Check Services or start PostgreSQL service
- Linux/Mac:
sudo systemctl start postgresqlorbrew services start postgresql
-
Check your connection string:
# Format: postgresql://username:password@host:port/database DATABASE_URL="postgresql://postgres:yourpassword@localhost:5432/vaishnavi_db?schema=public" -
Test connection manually:
# Test if PostgreSQL is accessible psql -U postgres -h localhost -p 5432 -c "SELECT version();"
MongoDB Connection Issues
-
Make sure MongoDB is running:
- Windows: Check Services or start MongoDB service
- Linux:
sudo systemctl start mongod - Mac:
brew services start mongodb-community
-
Test MongoDB connection:
# Connect to MongoDB mongosh # or mongo
Redis Connection Issues (Optional)
If you don't have Redis installed or don't want to use it:
-
Comment out the Redis URL in your
.envfile:# REDIS_URL="redis://localhost:6379" -
The application will work without Redis, but caching and background jobs won't be available.
Manual Setup (Alternative)
If the setup script doesn't work, you can run the commands manually:
# Install dependencies
npm install
# Generate Prisma client
npx prisma generate
# Create database schema
npx prisma db push
# Seed database
npm run db:seed
# Start development server
npm run dev
Verification
Once everything is set up, you can verify by:
- Health Check: Visit
http://localhost:3000/health - API Root: Visit
http://localhost:3000/ - Database Studio: Run
npm run db:studioto view your data
Default Users
After seeding, you'll have these test users:
- Admin:
admin@vaishnavi.com/admin123 - Customer:
customer@example.com/customer123
Next Steps
- Test the API endpoints using Postman or curl
- Set up your frontend application
- Configure AWS S3 for file uploads (optional)
- Set up email services for notifications (optional)
Getting Help
If you encounter issues:
- Check the logs in your terminal
- Verify all services are running
- Double-check your
.envconfiguration - Make sure you have the correct database permissions
Happy coding! 🚀