A social networking platform backend built with NestJS, featuring a hybrid database architecture with PostgreSQL and Neo4j.
- Framework: NestJS (Node.js)
- Databases:
- PostgreSQL (User data, posts, profiles)
- Neo4j (Social graph, relationships)
- Redis (Caching)
- Authentication: JWT + OAuth2 (Google)
- File Storage: Cloudinary
- API Documentation: Swagger/OpenAPI
- β JWT-based authentication
- β Google OAuth2 integration
- β Password reset flow
- β Rate limiting
- β Session management
- β Create, read, update, delete posts
- β Image uploads via Cloudinary
- β Post reactions
- β Comments system
- β Follow/unfollow users
- β Friend requests
- β Connection management
- β Neo4j-powered social graph
- β Personalized feed
- β Privacy settings
- β Content visibility control
- β Social graph-based filtering
- Node.js 20+
- pnpm
- Docker & Docker Compose (for local development)
- PostgreSQL 15+
- Neo4j 5+
- Redis 7+
# Clone repository
git clone <repository-url>
cd Ding-Platform-Backend
# Copy environment variables
cp .env.example .env
# Edit .env with your configuration
# Start all services
./docker-dev.sh start
# Or use docker-compose directly
docker-compose up -d
# View logs
./docker-dev.sh logs
# Access services:
# Backend: http://localhost:3000
# API Docs: http://localhost:3000/api/docs
# Prisma Studio: http://localhost:5555
# Neo4j Browser: http://localhost:7474# Install dependencies
pnpm install
# Setup databases (PostgreSQL, Neo4j, Redis must be running)
# Generate Prisma Client
pnpm prisma generate
# Run migrations
pnpm prisma migrate dev
# Seed database (optional)
pnpm run prisma:seed
# Start development server
pnpm run start:dev- Render: See RENDER_DEPLOYMENT.md for detailed Render deployment guide
- Quick Start: See RENDER_QUICK_START.md for fast deployment
- Docker: See DOCKER_SETUP.md for Docker configuration
- Development: http://localhost:3000/api/docs
- Production: https://your-app.onrender.com/api/docs
POST /comments/posts/:postIdβ create a top-level comment (auth required, supportsparentCommentIdto reply)GET /comments/posts/:postIdβ list top-level comments with pagination andsort=top|recentGET /comments/:commentId/repliesβ list replies for a specific commentPATCH /comments/:commentIdβ update own comment content (auth required)DELETE /comments/:commentIdβ soft-delete own comment and update graph sync (auth required)
- ENV_GUIDE.md - Environment variables
- FEED_DOCUMENTATION.md - Feed system
- PROGRESS.md - Project progress
- Sprint summaries in root directory
# Development
pnpm run start:dev # Start with hot-reload
pnpm run start:debug # Start in debug mode
# Production
pnpm run build # Build application
pnpm run start:prod # Start production server
# Database
pnpm prisma generate # Generate Prisma Client
pnpm prisma migrate dev # Run migrations (dev)
pnpm prisma migrate deploy # Run migrations (prod)
pnpm prisma studio # Open Prisma Studio
pnpm run prisma:seed # Seed database
# Testing
pnpm run test # Unit tests
pnpm run test:e2e # E2E tests
pnpm run test:cov # Test coverage
# Code Quality
pnpm run lint # Lint code
pnpm run format # Format code
# Docker
./docker-dev.sh start # Start dev environment
./docker-dev.sh stop # Stop dev environment
./docker-dev.sh logs # View logs
./docker-dev.sh migrate # Run migrations
./docker-dev.sh shell # Access backend shell
./docker-prod.sh deploy # Deploy production
./docker-prod.sh health # Check health
./docker-prod.sh backup # Backup databasesThe easiest way to deploy is using Render with the included blueprint:
-
Setup Neo4j Aura (free tier available)
- Create instance at console.neo4j.io
-
Deploy via Blueprint
# Push to GitHub git push origin main # In Render dashboard: # - New + β Blueprint # - Connect repository # - Configure environment variables # - Deploy
-
Complete guide: See RENDER_DEPLOYMENT.md
# Build and deploy
./docker-prod.sh deploy
# Or manually
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -dThe application also supports Vercel deployment (see vercel.json).
Key environment variables (see .env.example for complete list):
# Server
NODE_ENV=development
PORT=3000
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/ding_db
NEO4J_URI=bolt://localhost:7687
NEO4J_AUTH=neo4j/password
REDIS_URL=redis://localhost:6379
# Authentication
JWT_SECRET=your-secret-key
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# Services
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
SMTP_HOST=smtp.gmail.com
SMTP_USER=[email protected]
SMTP_PASS=your-app-passwordsrc/
βββ common/ # Shared utilities, decorators, guards
βββ configs/ # Database, Neo4j, Redis configurations
βββ modules/
β βββ auth/ # Authentication & authorization
β βββ user/ # User management
β βββ profile/ # User profiles
β βββ post/ # Post management
β βββ social/ # Social graph (follow/friend)
β βββ feed/ # Personalized feed
β βββ privacy/ # Privacy settings
βββ app.module.ts # Root module
βββ main.ts # Application entry point
prisma/
βββ schema.prisma # Database schema
βββ migrations/ # Database migrations
βββ seed.ts # Database seeding
scripts/
βββ render-build.sh # Render build script
βββ render-start.sh # Render start script
# Run all tests
pnpm run test
# Run e2e tests
pnpm run test:e2e
# Test coverage
pnpm run test:cov- JWT-based authentication
- Bcrypt password hashing
- Rate limiting (100 req/min)
- Helmet.js security headers
- CORS configuration
- Input validation with class-validator
- SQL injection protection via Prisma
- XSS protection
- Endpoint:
/health - Returns: Service status, uptime, environment
- Development: Pretty-printed console logs
- Production: JSON logs with Pino
- Optional: Sentry integration
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the UNLICENSED License.
Built with β€οΈ by the Ding Platform team
- Documentation: Check files in project root
- Issues: Open a GitHub issue
- Email: [Your support email]
- Real-time notifications (WebSocket)
- Direct messaging
- Advanced search
- Analytics dashboard
- Mobile app API optimization
- GraphQL API
- Microservices architecture
Ready to deploy? Check out RENDER_QUICK_START.md for a 5-minute deployment guide!