No description
|
All checks were successful
Backend CI / Lint, Type-check, Test (Backend) (push) Successful in 5m3s
feat: add archive_events table for tracking archive processing events and errors Create archive_events table with fields for event level, code, message, details, and context. Add composite index on archiveId and createdAt for efficient event lookups. Include foreign key constraint to archives table with CASCADE delete behavior. ``` |
||
|---|---|---|
| .forgejo/workflows | ||
| .kiro/specs/email-archiving-system | ||
| .vscode | ||
| .windsurf/rules | ||
| backend | ||
| docs | ||
| frontend | ||
| nginx | ||
| scripts | ||
| tasks | ||
| .gitignore | ||
| docker-compose.prod.yml | ||
| docker-compose.yml | ||
| Makefile | ||
| PROJECT_PLAN.md | ||
| README.md | ||
EmailVault - Email Archiving System
A modern, fast, and secure email archiving solution with powerful search capabilities and mobile-optimized interface.
Features
- 🚀 Lightning Fast - Optimized performance with background processing
- 🔒 Secure - Enterprise-grade encryption and security
- 🔍 Powerful Search - Full-text search across all email content
- 📱 Mobile Optimized - Beautiful responsive design
- 📧 Universal Support - Works with any SMTP/IMAP email provider
- 🔄 Background Processing - Non-blocking email archiving
- 📁 Folder Preservation - Maintains original email folder structure
Tech Stack
Frontend
- Next.js 15 with App Router
- React 19
- Tailwind CSS + shadcn/ui
- TypeScript
- React Query (TanStack Query)
Backend
- Node.js with Fastify
- Prisma ORM
- Bull Queue (Redis)
- TypeScript
Database & Storage
- PostgreSQL (with full-text search)
- Redis (queues & caching)
- MinIO (S3-compatible attachment storage)
Quick Start
Prerequisites
- Docker and Docker Compose
- Node.js 20+ (for local development)
Setup
-
Clone and navigate to the project:
cd email-vault -
Start all services:
docker-compose up -d -
Initialize the database:
# Run database migrations docker-compose exec backend npm run db:push -
Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- MinIO Console: http://localhost:9001 (emailvault / emailvault_password)
- Nginx (Production): http://localhost:80
MinIO setup (automated + manual fallback)
-
Automated (default with Docker Compose):
- Both
docker-compose.ymlanddocker-compose.prod.ymlinclude aminio-setupone-shot service that:- Creates a private bucket named
emailvaulton first start. - Ensures anonymous/public access is disabled for that bucket.
- Creates a private bucket named
- Credentials (dev):
MINIO_ROOT_USER=emailvault,MINIO_ROOT_PASSWORD=emailvault_password. - Endpoint (dev):
http://localhost:9000(console athttp://localhost:9001).
- Both
-
What the backend expects:
- The attachment worker stores files in the
emailvaultbucket (seebackend/src/workers/attachment-processing.worker.ts→bucketName = 'emailvault'). - It will also auto-create the bucket at runtime if missing, via
ensureBucketExists(). The compose-based setup makes this explicit and deterministic.
- The attachment worker stores files in the
-
Manual fallback (if you start MinIO without Compose setup):
- Install the MinIO client (mc) or use the
minio/mcDocker image. - Set an alias and create the bucket:
mc alias set local http://localhost:9000 emailvault emailvault_password mc mb -p local/emailvault mc anonymous set none local/emailvault - Alternatively, from the MinIO Console (http://localhost:9001):
- Create a bucket named
emailvault. - Keep it private (no anonymous policy).
- Create a bucket named
- Install the MinIO client (mc) or use the
Production notes
- In
docker-compose.prod.ymlset:MINIO_ROOT_USER,MINIO_ROOT_PASSWORD(for theminioservice andminio-setup).MINIO_ENDPOINTfor the backend (defaults tominio:9000).MINIO_ACCESS_KEY,MINIO_SECRET_KEYfor the backend (should match the MinIO root user/pass unless you provision separate users/keys).- Optionally override
MINIO_BUCKETused byminio-setup(defaults toemailvault). - The MinIO console is not exposed by default in prod compose; expose ports if you need console access.
Development
For local development without Docker:
-
Start infrastructure services:
docker-compose up postgres redis minio -d -
Install dependencies:
# Backend cd backend && npm install # Frontend cd ../frontend && npm install -
Set up environment variables:
# Backend cp backend/.env.example backend/.env # Frontend cp frontend/.env.example frontend/.env -
Run development servers:
# Backend (terminal 1) cd backend && npm run dev # Frontend (terminal 2) cd frontend && npm run dev
Environment Variables
Backend (.env)
DATABASE_URL=postgresql://emailvault:emailvault_password@localhost:5432/emailvault
REDIS_URL=redis://localhost:6379
MINIO_ENDPOINT=localhost:9000
MINIO_ACCESS_KEY=emailvault
MINIO_SECRET_KEY=emailvault_password
JWT_SECRET=your-super-secret-jwt-key-change-in-production
Frontend (.env.local)
NEXT_PUBLIC_API_URL=http://localhost:3001
Project Structure
email-vault/
├── docker-compose.yml # Docker services configuration
├── frontend/ # Next.js 15 frontend
│ ├── src/
│ │ ├── app/ # App Router pages
│ │ ├── components/ # React components
│ │ └── lib/ # Utilities
│ ├── package.json
│ └── Dockerfile
├── backend/ # Fastify backend
│ ├── src/
│ │ ├── index.ts # Main server file
│ │ ├── routes/ # API routes
│ │ ├── services/ # Business logic
│ │ └── types/ # TypeScript types
│ ├── prisma/
│ │ └── schema.prisma # Database schema
│ ├── package.json
│ └── Dockerfile
├── nginx/
│ └── nginx.conf # Reverse proxy config
└── docs/ # Documentation
API Endpoints
Authentication
POST /auth/login- User loginPOST /auth/register- User registration
Email Accounts
GET /email-accounts- List email accountsPOST /email-accounts- Add email accountPUT /email-accounts/:id- Update email accountDELETE /email-accounts/:id- Remove email account
Archives
GET /archives- List archivesPOST /archives- Start new archiveGET /archives/:id- Get archive detailsDELETE /archives/:id- Delete archive
Emails
GET /emails- Search emailsGET /emails/:id- Get email detailsGET /emails/:id/attachments- Get email attachments
Testing
# Backend tests
cd backend && npm test
# Frontend tests
cd frontend && npm test
# E2E tests
cd frontend && npm run test:e2e
Security & Safe Email Viewer
- See
docs/safe-email-viewer.mdfor details on the frontend Safe Email Viewer, URL rewriting, and backend proxy endpoints (/api/proxy/image,/api/proxy/link, and attachment proxy routes). It covers sanitization, SSRF protection, allowed content types/size limits, caching, and response security headers.
Production Deployment
- Update environment variables for production
- Build and deploy:
docker-compose -f docker-compose.prod.yml up -d
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details