A modern email management system built with Turborepo monorepo architecture, featuring microservices for handling email processing, storage, and real-time updates.
This project uses Turborepo as a monorepo management tool with the following structure:
inbox/
βββ apps/
β βββ consumer-push2storage/ # Consumes messages and stores to database
β βββ http-server/ # Main HTTP API server
β βββ label-assigner/ # Assigns labels to emails
β βββ publisher-publish-mail-from-imap/ # Publishes emails from IMAP
β βββ web/ # Frontend Next.js application
β βββ worker/ # Background job processor
β βββ ws-server/ # WebSocket server for real-time updates
βββ packages/
β βββ elasticSearch/ # Elasticsearch utilities
β βββ eslint-config/ # Shared ESLint configuration
β βββ postgre-db/ # PostgreSQL database client
β βββ rabbitmq/ # RabbitMQ client utilities
β βββ redisClient/ # Redis client utilities
β βββ types/ # Shared TypeScript types
β βββ typescript-config/ # Shared TypeScript configuration
β βββ ui/ # Shared UI components
βββ docker-compose.yml
- Node.js (v18 or higher)
- Docker and Docker Compose
- Git
- pnpm (recommended) or npm/yarn
# Fork the repository on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/inbox.git
cd inbox# Install pnpm globally if you haven't already
npm install -g pnpm
# Install all dependencies
pnpm installThe project includes a docker-compose.yml file that sets up all required services:
- PostgreSQL database
- Redis cache
- Elasticsearch
- RabbitMQ message broker
# Start all services in detached mode
docker-compose up -d
# Check if all services are running
docker-compose ps
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Stop and remove volumes (clean slate)
docker-compose down -v- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API:
- Navigate to "APIs & Services" > "Library"
- Search for "Gmail API" and enable it
- Create OAuth 2.0 credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Choose "Web application"
- Add authorized redirect URIs:
http://localhost:3002/api/auth/callback/google
- Save and copy the Client ID and Client Secret
If you prefer a cloud Redis instance instead of Docker:
- Sign up for Redis Cloud or Upstash
- Create a new Redis database
- Copy the connection details:
- Host
- Port
- Password
- Username (usually 'default')
Note: For local development, the Docker Compose setup includes Redis, so this step is optional.
The Docker Compose file includes PostgreSQL. Connection details:
- Host: localhost
- Port: 5432
- Database: inbox_db
- Username: inbox_user
- Password: inbox_password
Database URL format:
postgresql://inbox_user:inbox_password@localhost:5432/inbox_db
- Sign up at Cloudinary
- Go to your Dashboard
- Copy the following details:
- Cloud Name
- API Key
- API Secret
Create .env files in the respective application directories:
NEXT_PUBLIC_FRONTEND_URL="http://localhost:3000"
GOOGLE_CLIENT_ID='your_google_client_id_here'
GOOGLE_CLIENT_SECRET='your_google_client_secret_here'
GOOGLE_REDIRECT_URI="http://localhost:3002/api/auth/callback/google"
DATABASE_URL="postgresql://inbox_user:inbox_password@localhost:5432/inbox_db"
REDIS_USERNAME='default'
REDIS_PASSWORD='your_redis_password_here'
REDIS_HOST='localhost'
REDIS_PORT='6379'NEXT_PUBLIC_FRONTEND_URL="http://localhost:3000"
WORKER_BACKEND_URL='http://worker:3008'
DATABASE_URL="postgresql://inbox_user:inbox_password@localhost:5432/inbox_db"
REDIS_USERNAME='default'
REDIS_PASSWORD='your_redis_password_here'
REDIS_HOST='localhost'
REDIS_PORT='6379'
secret_key='your_secret_key_here'
access_key='your_access_key_here'IMAP_BACKEND_URL='http://publisher-publish-mail-from-imap:3009'
RABBITMQ_CLUSTER_URL="amqp://inbox_user:inbox_password@localhost:5672/"
DATABASE_URL="postgresql://inbox_user:inbox_password@localhost:5432/inbox_db"WORKER_BACKEND_URL='http://worker:3008'
DATABASE_URL="postgresql://inbox_user:inbox_password@localhost:5432/inbox_db"
RABBITMQ_CLUSTER_URL="amqp://inbox_user:inbox_password@localhost:5672/"
CLOUDINARY_NAME='your_cloudinary_name'
API_KEY='your_cloudinary_api_key'
API_SECRET='your_cloudinary_api_secret'DATABASE_URL="postgresql://inbox_user:inbox_password@localhost:5432/inbox_db"
RABBITMQ_CLUSTER_URL="amqp://inbox_user:inbox_password@localhost:5672/"
ELESTIC_SEARCH_CONNECTION_URL="http://localhost:9200"REDIS_USERNAME='default'
REDIS_PASSWORD='your_redis_password_here'
REDIS_HOST='localhost'
REDIS_PORT='6379'DATABASE_URL="postgresql://inbox_user:inbox_password@localhost:5432/inbox_db"
RABBITMQ_CLUSTER_URL="amqp://inbox_user:inbox_password@localhost:5672/"# Navigate to the database package
cd packages/postgre-db
# Generate Prisma client
pnpm prisma generate
# Return to root
cd ../..# Navigate to the database package
cd packages/postgre-db
# Run migrations
pnpm prisma migrate dev
# Or if you want to push schema without migration
pnpm prisma db push
# Return to root
cd ../..cd packages/postgre-db
pnpm prisma db seed
cd ../..# Run all applications in development mode
pnpm dev
# Run specific application
pnpm dev --filter=web
pnpm dev --filter=http-server# Build all applications
pnpm build
# Build specific application
pnpm build --filter=web# Start all applications
pnpm start
# Start specific application
pnpm start --filter=web| Service | Port | Description |
|---|---|---|
| Web (Frontend) | 3000 | Next.js web application |
| HTTP Server | 3002 | Main API server |
| Worker | 3008 | Background job processor |
| IMAP Publisher | 3009 | Email publisher service |
| WebSocket Server | 3010 | Real-time updates |
| PostgreSQL | 5432 | Database |
| Redis | 6379 | Cache and session store |
| RabbitMQ | 5672 | Message broker |
| RabbitMQ Management | 15672 | RabbitMQ web UI |
| Elasticsearch | 9200 | Search engine |
# Run tests for all packages
pnpm test
# Run tests for specific package
pnpm test --filter=web# Check for linting errors
pnpm lint
# Format code
pnpm format
# Clean all node_modules and build artifacts
pnpm clean
# View Prisma Studio (database GUI)
cd packages/postgre-db && pnpm prisma studio# Check Docker logs
docker-compose logs
# Restart specific service
docker-compose restart postgres# Find process using port (example: port 3000)
lsof -i :3000
# Kill the process
kill -9 <PID># Regenerate Prisma Client
cd packages/postgre-db
pnpm prisma generate- Ensure RabbitMQ is running:
docker-compose ps - Check RabbitMQ management UI at
http://localhost:15672- Username:
inbox_user - Password:
inbox_password
- Username:
- Turborepo Documentation
- Next.js Documentation
- Prisma Documentation
- RabbitMQ Tutorials
- Redis Documentation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Create an issue on GitHub
- Check existing documentation
- Review closed issues for solutions
Happy Coding! π