NeonAppsBackend
A NestJS backend project providing user, friendship, notification, todo and real-time chat (Socket.IO) features. It uses Prisma ORM and integrates Redis for caching and real-time adapters.
Technologies: Node.js, TypeScript, NestJS, Prisma, PostgreSQL, Redis, Socket.IO, BullMQ
Status: Development (local). Fill in .env values before pushing to GitHub or deploying.
Overview
- API: REST + WebSocket (chat gateway)
- Auth: JWT + Google OAuth
- Persistence: Prisma + PostgreSQL (see
prisma/migrations)
Quick Start
- Clone the repo and install dependencies:
pnpm install- Create a
.envfile and set the following environment variables (validation is defined insrc/common/configs/env.config.ts):
NODE_ENV(development|production|test)PORT(e.g. 8080)DATABASE_URL(Postgres connection URL)JWT_SECRETJWT_EXPIRES_IN(e.g.7d)GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_CALLBACK_URLMAIL_USER(SMTP user/email)MAIL_PASS(SMTP password)FRONTEND_URL(frontend origin)REDIS_URL(optional)
Example .env (replace values with your own secrets):
NODE_ENV=development
PORT=8080
DATABASE_URL=postgresql://user:pass@localhost:5432/neon_db
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7d
GOOGLE_CLIENT_ID=xxx
GOOGLE_CLIENT_SECRET=yyy
GOOGLE_CALLBACK_URL=http://localhost:3000/api/auth/google/callback
MAIL_USER=[email protected]
MAIL_PASS=mailpassword
FRONTEND_URL=http://localhost:5173
REDIS_URL=redis://localhost:6379- Generate Prisma client and apply migrations (development):
npx prisma generate
npx prisma migrate dev --name initTo apply migrations in production:
npx prisma migrate deploy- Start the development server:
pnpm run start:dev- (Optional) Run the admin seed script:
npx ts-node -r tsconfig-paths/register src/seed-admin.tsScripts / Common Commands
- Build:
pnpm run build - Start (production):
pnpm run start:prod - Unit tests:
pnpm run test— E2E:pnpm run test:e2e - Lint & format:
pnpm run lint,pnpm run format
Database & Migration Notes
- Prisma schema:
prisma/schema.prisma - Migrations:
prisma/migrations - To add a new migration use:
npx prisma migrate dev --name <desc>
Docker
- The project includes a
Dockerfile. Example build/run:
docker build -t neonapps-backend .
docker run -e DATABASE_URL="$DATABASE_URL" -p 8080:8080 neonapps-backendNote: For production, run prisma migrate deploy and provide proper environment variables.
Important Directories
src/— application source codesrc/modules— domain modules (auth, chat, user, todo, notification, friendship...)src/core/database— Prisma service and DB setupprisma/— schema and migrations
Common Issues
Environment validation failed: You likely missed required.envvariables. Checksrc/common/configs/env.config.tsfor required keys.- Redis/Socket.IO: ensure
REDIS_URLis correctly set for adapter and cache.
Contributing
- Fork → create a feature branch
- Add changes and run tests locally
- Open a pull request with a descriptive title and summary
License & Copyright
- The repository currently lists
UNLICENSEDinpackage.json. If you plan to publish this on GitHub, add an appropriate license file if needed.
-- README updated. If you want, I can commit and push the change to your Git remote.
Common Issues
Environment validation failed: You likely missed required.envvariables. Checksrc/common/configs/env.config.tsfor required keys.- Redis/Socket.IO: ensure
REDIS_URLis correctly set for adapter and cache.
Contributing
- Fork → create a feature branch
- Add changes and run tests locally
- Open a pull request with a descriptive title and summary
License & Copyright
- The repository currently lists
UNLICENSEDinpackage.json. If you plan to publish this on GitHub, add an appropriate license file if needed.
-- README updated. If you want, I can commit and push the change to your Git remote.