A modern social media API built with NestJS, featuring Twitter-like functionality including posts, follows, engagement features, and comprehensive user management. Jink provides a robust backend for social networking applications with secure authentication, real-time interactions, and scalable architecture.
Jink is a RESTful API that powers social media applications with core features like user authentication, post creation and management, social interactions (likes, bookmarks, reposts, quotes), and user relationships (follows). Built with enterprise-grade security using JWT tokens, Argon2 password hashing, and comprehensive input validation, it solves the need for a reliable, scalable social media backend that can handle modern social networking requirements.
- Secure Authentication: JWT-based auth with refresh tokens, email verification, and password reset
- User Management: Complete user profiles with customizable avatars, cover images, and bio information
- Post System: Create, edit, delete posts with image support and reply threading
- Social Interactions: Like, bookmark, repost, and quote posts with real-time engagement tracking
- Social Network: Follow/unfollow users with follower/following management
- Media Upload: Cloudinary integration for profile pictures, cover images, and post attachments
- Post Visibility: Public, followers-only, and private post visibility controls
- Pin Posts: Ability to pin important posts to user profiles
- API Documentation: Comprehensive Swagger/OpenAPI documentation
- Rate Limiting: Built-in throttling for authentication endpoints
- Testing: Unit and E2E testing with Jest and Pactum
- Docker Support: Containerized PostgreSQL databases for development and testing
- Node.js (v18 or higher)
- Yarn package manager
- Docker and Docker Compose
- PostgreSQL (via Docker)
-
Clone the repository
git clone https://github.com/mrrmartin01/jink.git cd jink -
Install dependencies
yarn install
-
Set up environment variables Create a
.envfile in the root directory:# Database DATABASE_URL="postgresql://postgres:123@localhost:5434/jink" # JWT Configuration JWT_SECRET="your-super-secret-jwt-key" # Application PORT=9000 NODE_ENV="development" FRONTEND_URL="http://localhost:3000" # Email Configuration (for verification emails) MAIL_HOST="smtp.gmail.com" MAIL_PORT=587 MAIL_USER="[email protected]" MAIL_PASS="your-app-password" # Cloudinary (for image uploads) CLOUDINARY_CLOUD_NAME="your-cloud-name" CLOUDINARY_API_KEY="your-api-key" CLOUDINARY_API_SECRET="your-api-secret"
-
Start the database
yarn db:dev:up
-
Run database migrations
yarn prisma:dev:deploy
-
Generate Prisma client
npx prisma generate
-
Start the development server
yarn start:dev
The API will be available at http://localhost:9000/api with Swagger documentation at http://localhost:9000/api/docs.
-
Register a new user
curl -X POST http://localhost:9000/api/auth/signup \ -H "Content-Type: application/json" \ -d '{ "email": "[email protected]", "userName": "johndoe", "password": "securepassword123", "firstName": "John", "lastName": "Doe" }'
-
Verify account via email
curl -X POST http://localhost:9000/api/auth/verify \ -H "Content-Type: application/json" \ -d '{ "email": "[email protected]", "code": "123456" }'
-
Sign in
curl -X POST http://localhost:9000/api/auth/signin \ -H "Content-Type: application/json" \ -d '{ "identifier": "[email protected]", "password": "securepassword123" }'
-
Create a post
curl -X POST http://localhost:9000/api/posts \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{ "content": "Hello, world! This is my first post on Jink.", "visibility": "PUBLIC" }'
-
Get user's posts
curl -X GET http://localhost:9000/api/posts \ -H "Authorization: Bearer YOUR_JWT_TOKEN" -
Like a post
curl -X POST http://localhost:9000/api/like \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{ "postId": "post-uuid-here" }'
-
Follow a user
curl -X POST http://localhost:9000/api/follows/user-uuid-here \ -H "Authorization: Bearer YOUR_JWT_TOKEN" -
Bookmark a post
curl -X POST http://localhost:9000/api/bookmarks/post-uuid-here \ -H "Authorization: Bearer YOUR_JWT_TOKEN" -
Quote a post
curl -X POST http://localhost:9000/api/quote \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{ "postId": "post-uuid-here", "content": "This is my comment on the original post!" }'
| Variable | Description | Required | Default |
|---|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes | - |
JWT_SECRET |
Secret key for JWT token signing | Yes | - |
PORT |
Application port | No | 9000 |
NODE_ENV |
Environment (development/production) | No | development |
FRONTEND_URL |
Frontend URL for CORS | Yes | - |
MAIL_HOST |
SMTP server host | Yes | - |
MAIL_PORT |
SMTP server port | Yes | - |
MAIL_USER |
SMTP username | Yes | - |
MAIL_PASS |
SMTP password | Yes | - |
CLOUDINARY_CLOUD_NAME |
Cloudinary cloud name | Yes | - |
CLOUDINARY_API_KEY |
Cloudinary API key | Yes | - |
CLOUDINARY_API_SECRET |
Cloudinary API secret | Yes | - |
The application uses PostgreSQL with Prisma ORM. Database schemas are defined in prisma/schema.prisma and migrations are managed through Prisma CLI.
- @nestjs/core (^11.0.1) - NestJS framework
- @nestjs/common (^11.0.1) - Common NestJS utilities
- @nestjs/platform-express (^11.1.6) - Express platform adapter
- @nestjs/config (^4.0.2) - Configuration management
- @nestjs/swagger (^11.2.0) - API documentation
- @nestjs/throttler (^6.4.0) - Rate limiting
- @nestjs/jwt (^11.0.0) - JWT authentication
- @nestjs/passport (^11.0.5) - Passport integration
- @prisma/client (^6.9.0) - Prisma database client
- prisma (^6.9.0) - Prisma CLI and tools
- passport (^0.7.0) - Authentication middleware
- passport-jwt (^4.0.1) - JWT strategy for Passport
- argon2 (^0.43.0) - Password hashing
- cookie-parser (^1.4.7) - Cookie parsing middleware
- class-validator (^0.14.2) - Validation decorators
- class-transformer (^0.5.1) - Object transformation
- cloudinary (^2.7.0) - Cloud-based image management
- multer (^2.0.2) - File upload handling
- @nestjs-modules/mailer (^2.0.2) - Email service
- nodemailer (^7.0.6) - Email sending
Quick start for new users:
# Clone and install
git clone https://github.com/mrrmartin01/jink && cd jink && yarn install
# Start database and run migrations
yarn db:dev:restart
# Start development server
yarn start:devVisit http://localhost:9000/api/docs for interactive API documentation.
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run tests:
yarn testandyarn test:e2e - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow TypeScript best practices
- Use ESLint and Prettier for code formatting
- Write comprehensive tests for new features
- Update documentation for API changes
- Follow conventional commit messages
- Use GitHub Issues for bug reports and feature requests
- Provide detailed reproduction steps for bugs
- Include environment information and error logs
Unit Tests
yarn testUnit Tests with Coverage
yarn test:covE2E Tests
yarn test:e2eWatch Mode
yarn test:watch- Unit Tests: Jest with ts-jest
- E2E Tests: Pactum for API testing
- Test Database: Separate PostgreSQL container (port 5435)
- Coverage: Istanbul for code coverage reports
Tests use a separate database instance and environment configuration (.env.test).
This project is licensed under the UNLICENSED license. All rights reserved.
For usage rights and permissions, please contact the project maintainers.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
- Project Lead: Mrr. Martin01
- Core Contributors: Team Members
🟢 Active Development - This project is actively maintained and under development. We regularly release updates, fix bugs, and add new features. The API is stable for production use with proper environment configuration.
- Description
- Features
- Installation
- Usage
- Configuration
- Dependencies
- Getting Started
- Contributing
- Testing
- License
- Contact/Support
- Badges
- Project Status
Database Connection Issues
# If database won't start
yarn db:dev:rm && yarn db:dev:up
# If migrations fail
yarn prisma:dev:deployPort Already in Use
# Change PORT in .env file or kill process using port 9000
lsof -ti:9000 | xargs kill -9JWT Token Issues
- Ensure
JWT_SECRETis set in environment variables - Check token expiration and refresh token validity
- Verify cookie settings for production vs development
Email Verification Not Working
- Check SMTP credentials in environment variables
- Verify email service allows less secure apps (Gmail)
- Check spam folder for verification emails
Image Upload Issues
- Verify Cloudinary credentials are correct
- Check file size limits (max 4 images per post)
- Ensure proper file format (jpg, png, gif)
- Real-time Notifications and Messaging - WebSocket integration for live updates
- Advanced Search - Full-text search for posts and users
- Content Moderation - Automated content filtering and reporting
- Analytics Dashboard - User engagement and post performance metrics
- Mobile API - Optimized endpoints for mobile applications
- Push Notifications - Mobile push notification support
- Advanced Privacy Controls - Granular privacy settings
- Content Scheduling - Post scheduling and automation
- Caching Layer - Redis integration for improved performance
- Database Optimization - Query optimization and indexing
- CDN Integration - Global content delivery for media files
- Load Balancing - Horizontal scaling support
- NestJS - Progressive Node.js framework
- Prisma - Next-generation ORM for Node.js and TypeScript
- PostgreSQL - Powerful, open source object-relational database
- Cloudinary - Cloud-based image and video management
- JWT - JSON Web Token for secure authentication
This project draws inspiration from modern social media platforms and aims to provide a robust, scalable foundation for social networking applications.
Special thanks to all contributors who have helped shape this project through code contributions, bug reports, and feature suggestions.
Made by The_Dark_Themed_Fella using NestJS and TypeScript