| Metric | Value |
|---|---|
| Total SLOC | 9,741 |
| Source Files | 58 |
| .js | 4,173 |
| .tsx | 2,333 |
| .md | 1,874 |
| .ts | 562 |
| .sql | 384 |
A photo and video sharing social platform with photo/video uploads, filters, feeds, stories, likes, comments, and follows.
- Photo/video upload with 12 Instagram-style CSS filters
- Personalized feed from followed users
- Stories (24-hour ephemeral content with view tracking)
- Likes, comments, and saves
- Follow/unfollow system
- User profiles with post grid
- Explore page for discovering new content
- Session-based authentication
- Frontend: TypeScript + Vite + React 19 + Tanstack Router + Zustand + Tailwind CSS
- Backend: Node.js + Express
- Database: PostgreSQL
- Cache: Redis
- Object Storage: MinIO (S3-compatible)
- Message Queue: RabbitMQ (async image processing)
- Image Processing: Sharp
- Initial architecture design
- Core functionality implementation
- Database/Storage layer
- API endpoints
- Testing
- Performance optimization
- Documentation
- Node.js 18+ and npm
- Docker and Docker Compose
- Start infrastructure services:
cd instagram
docker-compose up -dThis starts PostgreSQL, Redis, MinIO, and RabbitMQ with automatic bucket creation.
- Install backend dependencies:
cd backend
cp .env.example .env
npm install- Install frontend dependencies:
cd frontend
npm install- Start the backend server:
cd backend
npm run devThe API will be available at http://localhost:3001
- Start the frontend development server:
cd frontend
npm run devThe app will be available at http://localhost:5173
If you prefer running services natively:
# Install PostgreSQL (macOS)
brew install postgresql@16
brew services start postgresql@16
# Create database
createdb instagram
psql instagram < backend/db/init.sql# Install Redis (macOS)
brew install redis
brew services start redis# Install MinIO (macOS)
brew install minio/stable/minio
minio server ~/minio-data --console-address ":9001"
# Create bucket (in another terminal)
brew install minio/stable/mc
mc alias set local http://localhost:9000 minioadmin minioadmin
mc mb local/instagram-media
mc anonymous set public local/instagram-mediaUpdate backend/.env with your native service configurations.
Backend .env configuration:
# Database
DATABASE_URL=postgresql://instagram:instagram123@localhost:5432/instagram
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=instagram
POSTGRES_USER=instagram
POSTGRES_PASSWORD=instagram123
# Redis
REDIS_URL=redis://localhost:6379
REDIS_HOST=localhost
REDIS_PORT=6379
# MinIO
MINIO_ENDPOINT=localhost
MINIO_PORT=9000
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin123
MINIO_BUCKET=instagram-media
MINIO_USE_SSL=false
# Session
SESSION_SECRET=your-super-secret-session-key-change-in-production
# Server
PORT=3001
NODE_ENV=developmentFor testing load balancing:
# Terminal 1
npm run dev:server1 # Port 3001
# Terminal 2
npm run dev:server2 # Port 3002
# Terminal 3
npm run dev:server3 # Port 3003Image processing is handled asynchronously via RabbitMQ. Start workers to process uploaded images:
# Single worker
npm run dev:worker
# Multiple workers for parallel processing
npm run dev:worker1 # Terminal 1
npm run dev:worker2 # Terminal 2Workers apply filters (resize, Sharp processing) to uploaded images in the background. Posts are returned immediately with status processing and updated to published once complete.
| Service | URL |
|---|---|
| Frontend | http://localhost:5173 |
| Backend API | http://localhost:3001/api/v1 |
| MinIO Console | http://localhost:9001 |
| RabbitMQ Management | http://localhost:15672 |
| PostgreSQL | localhost:5432 |
| Redis | localhost:6379 |
POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- LoginPOST /api/v1/auth/logout- LogoutGET /api/v1/auth/me- Get current user
POST /api/v1/posts- Create post (multipart form)GET /api/v1/posts/:postId- Get postDELETE /api/v1/posts/:postId- Delete postPOST /api/v1/posts/:postId/like- Like postDELETE /api/v1/posts/:postId/like- Unlike postPOST /api/v1/posts/:postId/save- Save postDELETE /api/v1/posts/:postId/save- Unsave postGET /api/v1/posts/:postId/likes- Get post likes
GET /api/v1/posts/:postId/comments- Get commentsPOST /api/v1/posts/:postId/comments- Add commentDELETE /api/v1/comments/:commentId- Delete commentPOST /api/v1/comments/:commentId/like- Like commentDELETE /api/v1/comments/:commentId/like- Unlike comment
GET /api/v1/users/:username- Get user profilePUT /api/v1/users/me- Update profileGET /api/v1/users/:username/posts- Get user postsGET /api/v1/users/me/saved- Get saved postsPOST /api/v1/users/:userId/follow- Follow userDELETE /api/v1/users/:userId/follow- Unfollow userGET /api/v1/users/:username/followers- Get followersGET /api/v1/users/:username/following- Get followingGET /api/v1/users/search/users- Search users
GET /api/v1/feed- Get home feedGET /api/v1/feed/explore- Get explore page
POST /api/v1/stories- Create storyGET /api/v1/stories/tray- Get story trayGET /api/v1/stories/user/:userId- Get user storiesGET /api/v1/stories/me- Get my storiesPOST /api/v1/stories/:storyId/view- Mark story viewedGET /api/v1/stories/:storyId/viewers- Get story viewersDELETE /api/v1/stories/:storyId- Delete story
The app includes 12 CSS-based Instagram-style filters:
none- No filterclarendon- Increased contrast and saturationgingham- Slight brightness and sepiamoon- Grayscale with brightnesslark- Brightness with reduced saturationreyes- Sepia with reduced contrastjuno- High saturation and contrastslumber- Reduced saturationcrema- Sepia with reduced saturationludwig- Slight brightnessaden- Warm tones with saturationperpetua- Increased contrast and brightness
See architecture.md for detailed system design documentation.
See claude.md for development insights and iteration history.
# Backend tests (when implemented)
cd backend
npm test
# Frontend tests (when implemented)
cd frontend
npm test# Stop Docker services
docker-compose down
# Stop and remove volumes (full cleanup)
docker-compose down -v- Direct messaging with WebSocket
- Video transcoding
- Push notifications
- Content moderation
- Hashtags and mentions
- Admin dashboard
- Sharding & IDs at Instagram - How Instagram generates unique IDs and shards data across PostgreSQL clusters
- Storing Hundreds of Millions of Simple Key-Value Pairs in Redis - Instagram's approach to efficient Redis memory usage
- What Powers Instagram: Hundreds of Instances, Dozens of Technologies - Original architecture overview from Instagram engineering
- Building Feed at Facebook Scale - Feed generation patterns applicable to Instagram-style timelines
- Serving 100 Million Users with MinIO - Object storage patterns for media-heavy applications
- Image Processing with Sharp - High-performance Node.js image processing library documentation
- Designing Instagram - System Design Primer - Scaling patterns for photo sharing platforms
- CDN Architecture for Media Delivery - Content delivery network fundamentals for image/video distribution