{result.subject || '(No Subject)'}
+{result.snippet}
+No results found.
+ )} +diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..35fe6ac --- /dev/null +++ b/.env.example @@ -0,0 +1,10 @@ +# Postgres Credentials +POSTGRES_USER=allmail +POSTGRES_PASSWORD=my_secure_password +POSTGRES_DB=emails_db + +# Gemini API Key (free tier covers embedding usage) +GEMINI_API_KEY=your-gemini-api-key-here + +# Other Settings +MAILDIR_PATH=./Maildir diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..d1fac7d --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,54 @@ +name: Deploy to Server + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + container: + image: alpine:latest # Alpine to keep CPU/memory low + steps: + - name: Install SSH and Networking Tools + run: apk add --no-cache openssh-client iproute2 git + + - name: Configure SSH Key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + echo "StrictHostKeyChecking no" > ~/.ssh/config + + - name: Execute Remote Deployment + run: | + # 1. Find the host machine's IP via the docker bridge gateway + HOST_IP=$(ip route | awk '/default/ { print $3 }') + echo "==> Detected Host IP: $HOST_IP" + + # 2. SSH into the host to execute the deployment safely + ssh adipu@$HOST_IP << 'EOF' + # Exit immediately if any command fails + set -e + + echo "==> Navigating to project directory..." + cd ~/AllMail + + echo "==> Pulling latest code..." + git pull origin main + + echo "==> Running Build..." + # If this build fails, 'set -e' aborts the script instantly. + # Existing containers will NOT be touched, keeping the site up. + docker compose build + + echo "==> Build successful! Deploying new containers..." + # This only runs if the build was 100% successful. + docker compose up -d + + echo "==> Cleaning up old images to save disk space..." + docker image prune -f + + echo "==> Deployment Complete!" + EOF diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..4e52bd1 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.11-slim + +WORKDIR /app + +# Install system dependencies for building psycopg2 and others +RUN apt-get update && apt-get install -y \ + gcc \ + libpq-dev \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +RUN chmod +x run.sh + +ENTRYPOINT ["./run.sh"] diff --git a/api/database.py b/api/database.py new file mode 100644 index 0000000..d7f9494 --- /dev/null +++ b/api/database.py @@ -0,0 +1,44 @@ +import os +from sqlalchemy import create_engine, Column, Integer, String, Text, DateTime, text +from sqlalchemy.orm import declarative_base, sessionmaker +from pgvector.sqlalchemy import Vector + +POSTGRES_USER = os.environ.get("POSTGRES_USER", "allmail") +POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD", "postgres") +POSTGRES_DB = os.environ.get("POSTGRES_DB", "emails_db") +DB_HOST = os.environ.get("DB_HOST", "localhost") + +DATABASE_URL = f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{DB_HOST}/{POSTGRES_DB}" + +engine = create_engine(DATABASE_URL) +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) + +Base = declarative_base() + +# Gemini gemini-embedding-001 with output_dimensionality=768 +EMBEDDING_DIMENSIONS = 768 + +class Email(Base): + __tablename__ = "emails" + + id = Column(Integer, primary_key=True, index=True) + message_id = Column(String, unique=True, index=True) + subject = Column(Text) + sender = Column(String) + date = Column(DateTime) + content = Column(Text) + embedding = Column(Vector(EMBEDDING_DIMENSIONS)) + +def init_db(): + # Install pgvector extension if not exists + with engine.connect() as conn: + conn.execute(text("CREATE EXTENSION IF NOT EXISTS vector")) + conn.commit() + Base.metadata.create_all(bind=engine) + +def get_db(): + db = SessionLocal() + try: + yield db + finally: + db.close() diff --git a/api/indexer.py b/api/indexer.py new file mode 100644 index 0000000..40c4f51 --- /dev/null +++ b/api/indexer.py @@ -0,0 +1,149 @@ +import os +import time +import email +from email.policy import default +from bs4 import BeautifulSoup +from watchdog.observers import Observer +from watchdog.events import FileSystemEventHandler +from database import SessionLocal, Email, EMBEDDING_DIMENSIONS +from google import genai +from google.genai import types +from datetime import datetime +from sqlalchemy.exc import IntegrityError + +MAILDIR_PATH = os.environ.get("MAILDIR_PATH", "/Maildir") + +# Initialize Gemini client +gemini_client = None +api_key = os.environ.get("GEMINI_API_KEY") +if api_key: + gemini_client = genai.Client(api_key=api_key) + print("Gemini client initialized for indexer.") +else: + print("WARNING: GEMINI_API_KEY not set. Indexer will skip embedding generation.") + +def extract_text_from_email(msg): + text_content = "" + if msg.is_multipart(): + for part in msg.walk(): + content_type = part.get_content_type() + if content_type == "text/plain": + payload = part.get_payload(decode=True) + if payload: + text_content += payload.decode('utf-8', errors='ignore') + "\n" + elif content_type == "text/html": + payload = part.get_payload(decode=True) + if payload: + html_content = payload.decode('utf-8', errors='ignore') + soup = BeautifulSoup(html_content, 'html.parser') + text_content += soup.get_text(separator=' ') + "\n" + else: + content_type = msg.get_content_type() + payload = msg.get_payload(decode=True) + if payload: + if content_type == "text/html": + html_content = payload.decode('utf-8', errors='ignore') + soup = BeautifulSoup(html_content, 'html.parser') + text_content = soup.get_text(separator=' ') + else: + text_content = payload.decode('utf-8', errors='ignore') + return text_content.strip() + +def process_email_file(filepath): + print(f"Processing new email file: {filepath}") + if not gemini_client: + print("Skipping embedding generation: Gemini API key is missing.") + return + + try: + with open(filepath, 'rb') as f: + msg = email.message_from_binary_file(f, policy=default) + + message_id = msg.get('Message-ID', filepath) + subject = msg.get('Subject', '') + sender = msg.get('From', '') + date_str = msg.get('Date') + + try: + email_date = email.utils.parsedate_to_datetime(date_str) if date_str else datetime.utcnow() + except: + email_date = datetime.utcnow() + + content = extract_text_from_email(msg) + + if not content: + print(f"No text content found in {filepath}. Skipping.") + return + + # Combine subject and content for better embedding + text_to_embed = f"Subject: {subject}\nSender: {sender}\n\n{content}" + + # Limit text to avoid token limits (very rough truncation) + text_to_embed = text_to_embed[:8000] + + # Get embedding via Gemini — RETRIEVAL_DOCUMENT is the correct task type + # for content being stored and later retrieved by a query + response = gemini_client.models.embed_content( + model="gemini-embedding-001", + contents=text_to_embed, + config=types.EmbedContentConfig( + task_type="RETRIEVAL_DOCUMENT", + output_dimensionality=EMBEDDING_DIMENSIONS, + ), + ) + embedding = response.embeddings[0].values + + # Save to DB + db = SessionLocal() + try: + new_email = Email( + message_id=message_id, + subject=subject, + sender=sender, + date=email_date, + content=content, + embedding=embedding + ) + db.add(new_email) + db.commit() + print(f"Successfully indexed email: {subject}") + except IntegrityError: + db.rollback() + print(f"Email {message_id} already exists in database.") + except Exception as e: + db.rollback() + print(f"Database error saving email: {e}") + finally: + db.close() + + except Exception as e: + print(f"Error processing email {filepath}: {e}") + +class NewEmailHandler(FileSystemEventHandler): + def on_created(self, event): + if not event.is_directory: + # Simple check if it's likely an email file (mbsync creates files in cur/ or new/) + if 'new/' in event.src_path or 'cur/' in event.src_path: + process_email_file(event.src_path) + +def start_watching(): + print(f"Starting to watch {MAILDIR_PATH} for new emails...") + + # Optional: Do a full initial sync of existing files here. + # We will skip that for brevity and just watch for new ones. + + event_handler = NewEmailHandler() + observer = Observer() + observer.schedule(event_handler, MAILDIR_PATH, recursive=True) + observer.start() + try: + while True: + time.sleep(1) + except KeyboardInterrupt: + observer.stop() + observer.join() + +if __name__ == "__main__": + # Wait for DB to be initialized by FastAPI + time.sleep(5) + start_watching() diff --git a/api/main.py b/api/main.py new file mode 100644 index 0000000..78ae500 --- /dev/null +++ b/api/main.py @@ -0,0 +1,95 @@ +from fastapi import FastAPI, Depends, HTTPException +from fastapi.middleware.cors import CORSMiddleware +from sqlalchemy.orm import Session +from sqlalchemy import text +from database import get_db, init_db, Email, EMBEDDING_DIMENSIONS +from pydantic import BaseModel +from typing import List, Optional +from google import genai +from google.genai import types +import os +import time + +app = FastAPI(title="Unified Email Semantic Search API") + +# Setup CORS for the SPA +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +# Initialize Gemini client — reads GEMINI_API_KEY from environment +gemini_client = None + +class SearchQuery(BaseModel): + query: str + limit: int = 10 + +class SearchResult(BaseModel): + message_id: str + subject: str + sender: str + date: str + snippet: str + distance: float + +@app.on_event("startup") +def on_startup(): + global gemini_client + print("Initializing Database...") + time.sleep(2) # Give postgres a moment to be fully ready + try: + init_db() + except Exception as e: + print(f"Error initializing DB: {e}") + + api_key = os.environ.get("GEMINI_API_KEY") + if api_key: + gemini_client = genai.Client(api_key=api_key) + print("Gemini client initialized.") + else: + print("WARNING: GEMINI_API_KEY not set. Embedding features disabled.") + +@app.post("/search", response_model=List[SearchResult]) +def search_emails(request: SearchQuery, db: Session = Depends(get_db)): + if not gemini_client: + raise HTTPException(status_code=500, detail="Gemini API Key is not configured.") + + try: + response = gemini_client.models.embed_content( + model="gemini-embedding-001", + contents=request.query, + config=types.EmbedContentConfig( + task_type="RETRIEVAL_QUERY", + output_dimensionality=EMBEDDING_DIMENSIONS, + ), + ) + query_embedding = response.embeddings[0].values + except Exception as e: + raise HTTPException(status_code=500, detail=f"Embedding API error: {e}") + + # Use pgvector's cosine distance operator via SQLAlchemy ORM + results = db.query( + Email, + Email.embedding.cosine_distance(query_embedding).label('distance') + ).order_by( + Email.embedding.cosine_distance(query_embedding) + ).limit(request.limit).all() + + response_data = [] + for email, distance in results: + # Create a snippet from the content + snippet = email.content[:200] + "..." if email.content and len(email.content) > 200 else (email.content or "") + response_data.append(SearchResult( + message_id=email.message_id or "", + subject=email.subject or "", + sender=email.sender or "", + date=email.date.isoformat() if email.date else "", + snippet=snippet, + distance=distance + )) + + return response_data diff --git a/api/requirements.txt b/api/requirements.txt new file mode 100644 index 0000000..94198ae --- /dev/null +++ b/api/requirements.txt @@ -0,0 +1,9 @@ +fastapi==0.111.0 +uvicorn==0.30.1 +sqlalchemy==2.0.30 +psycopg2-binary==2.9.9 +pgvector==0.2.5 +watchdog==4.0.1 +google-genai>=1.0.0 +beautifulsoup4==4.12.3 +pydantic==2.7.2 diff --git a/api/run.sh b/api/run.sh new file mode 100644 index 0000000..19809f2 --- /dev/null +++ b/api/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "Starting Uvicorn..." +uvicorn main:app --host 0.0.0.0 --port 8000 & + +echo "Starting Indexer daemon..." +python indexer.py & + +# Wait for any process to exit +wait -n + +# Exit with status of process that exited first +exit $? diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3804d30 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,69 @@ +services: + db: + image: pgvector/pgvector:pg16 + restart: unless-stopped + environment: + POSTGRES_USER: ${POSTGRES_USER:-allmail} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB:-emails_db} + volumes: + - postgres_data:/var/lib/postgresql/data + command: postgres -c shared_buffers=256MB -c max_connections=50 + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-allmail} -d ${POSTGRES_DB:-emails_db}"] + interval: 5s + timeout: 5s + retries: 10 + deploy: + resources: + limits: + memory: 1G + + mail-sync: + build: + context: ./mail-sync + restart: unless-stopped + volumes: + - ./Maildir:/Maildir + deploy: + resources: + limits: + memory: 256M + + api: + build: + context: ./api + restart: unless-stopped + environment: + POSTGRES_USER: ${POSTGRES_USER:-allmail} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB:-emails_db} + DB_HOST: db + GEMINI_API_KEY: ${GEMINI_API_KEY} + MAILDIR_PATH: /Maildir + volumes: + - ./Maildir:/Maildir:ro + depends_on: + db: + condition: service_healthy + deploy: + resources: + limits: + memory: 512M + + webmail: + build: + context: ./webmail + restart: unless-stopped + volumes: + - ./Maildir:/Maildir:ro + # Bind only on host loopback — Cloudflare Tunnel proxies allmail.wahwa.com here. + ports: + - "127.0.0.1:8080:80" + deploy: + resources: + limits: + memory: 512M + +volumes: + postgres_data: diff --git a/mail-sync/Dockerfile b/mail-sync/Dockerfile new file mode 100644 index 0000000..481b38a --- /dev/null +++ b/mail-sync/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:latest + +RUN apk add --no-cache isync cron python3 ca-certificates bash su-exec tzdata + +# Copy configuration template and entrypoint +COPY mbsyncrc.template /root/.mbsyncrc.template +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +# Create the Maildir directory +RUN mkdir -p /Maildir + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["cron", "-f"] diff --git a/mail-sync/entrypoint.sh b/mail-sync/entrypoint.sh new file mode 100644 index 0000000..6703975 --- /dev/null +++ b/mail-sync/entrypoint.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +# Copy the template to the actual config location if it doesn't exist +if [ ! -f /root/.mbsyncrc ]; then + echo "No .mbsyncrc found. Copying template. PLEASE CONFIGURE THIS FILE." + cp /root/.mbsyncrc.template /root/.mbsyncrc +fi + +# Set up cron job if not already set +if ! crontab -l | grep -q "mbsync -a"; then + echo "Setting up mbsync cron job (every 5 minutes)..." + (crontab -l 2>/dev/null; echo "*/5 * * * * /usr/bin/mbsync -a >> /var/log/mbsync.log 2>&1") | crontab - +fi + +# Make sure log file exists +touch /var/log/mbsync.log + +# Run mbsync once on startup +echo "Running initial mbsync..." +/usr/bin/mbsync -a || echo "Initial mbsync failed, probably needs configuration." + +# Execute the CMD (usually cron -f) +if [ "$1" = "cron" ]; then + echo "Starting cron daemon..." + crond -f -l 2 +else + exec "$@" +fi diff --git a/mail-sync/mbsyncrc.template b/mail-sync/mbsyncrc.template new file mode 100644 index 0000000..1e2610c --- /dev/null +++ b/mail-sync/mbsyncrc.template @@ -0,0 +1,20 @@ +# IMAPAccount example +# Host imap.example.com +# User user@example.com +# PassCmd "echo password" +# SSLType IMAPS + +# IMAPStore example-remote +# Account example + +# MaildirStore example-local +# SubFolders Verbatim +# Path /Maildir/example/ +# Inbox /Maildir/example/Inbox + +# Channel example +# Far :example-remote: +# Near :example-local: +# Patterns * +# Create Both +# SyncState * diff --git a/walkthrough.md b/walkthrough.md new file mode 100644 index 0000000..92b8a57 --- /dev/null +++ b/walkthrough.md @@ -0,0 +1,87 @@ +# Phase 1 Implementation Walkthrough + +The foundational Phase 1 (Retrieval-Only Architecture) for your Unified Email Semantic Search system is now complete. The repository structure, Docker configurations, backend API, indexing daemon, and frontend have been successfully scaffolded in `/home/adipu/AllMail`. + +## Repository Structure Overview + +```mermaid +graph TD + A[AllMail/] --> B(db_data/) + A --> C(Maildir/) + A --> D(mail-sync/) + A --> E(api/) + A --> F(webmail/) + A --> G(.gitea/) + A --> H(docker-compose.yml) + A --> I(.env.example) + + D --> D1[Dockerfile] + D --> D2[entrypoint.sh] + D --> D3[mbsyncrc.template] + + E --> E1[Dockerfile] + E --> E2[main.py] + E --> E3[indexer.py] + E --> E4[database.py] + E --> E5[run.sh] + + F --> F1[Dockerfile] + F --> F2[nginx.conf] + F --> F3[entrypoint.sh] + F --> F4[spa/] +``` + +## Key Components Implemented + +### 1. Docker Infrastructure & Resource Management +- Created `docker-compose.yml` with memory limits applied specifically to respect the 16GB total memory overhead: + - `db` is restricted to `1G` (and Postgres tuned via command arguments `shared_buffers=256MB`). + - `api` is restricted to `512M`. + - `mail-sync` is restricted to `256M`. + - `webmail` is restricted to `512M`. +- Uses real filesystem mounts for persistent data: `./db_data` for PostgreSQL and `./Maildir` for the email files. + +### 2. Database & API (`api/`) +- A Python 3.11 container running both a FastAPI server (`main.py`) and a background Watchdog daemon (`indexer.py`). +- Integrates `pgvector` and uses SQLAlchemy to manage vector embeddings. +- Automatically connects to OpenAI for `text-embedding-3-small` and indexes new files arriving in `./Maildir`. + +### 3. Synchronization (`mail-sync/`) +- A lightweight Alpine image utilizing `isync` (mbsync). +- Contains an entrypoint that initializes a 5-minute cron schedule. +- A `mbsyncrc.template` was created to serve as your configuration starting point. + +### 4. Frontend & SnappyMail (`webmail/`) +- A custom `php:8.2-fpm-alpine` container running Nginx. +- Serves a React/Vite SPA on the root (`/`) for querying the Unified Search API. +- Proxies `/mail/` to SnappyMail for standard webmail consumption. +- The `Dockerfile` handles building the React app automatically during `docker compose build`. + +### 5. Deployment CI/CD (`.gitea/`) +- A GitHub-Actions-compatible workflow is present at `.gitea/workflows/deploy.yml` which triggers on pushes to `main` and runs the requested commands (`docker compose up -d --build` & `docker image prune -f`). + +## Next Steps for You + +> [!IMPORTANT] +> **Action Required**: The system is ready to be started, but you need to configure your secrets and accounts before running `docker compose up -d`. + +1. **Configure Environment Variables**: + Copy `.env.example` to `.env` and fill in your passwords and the OpenAI API Key. + ```bash + cp /home/adipu/AllMail/.env.example /home/adipu/AllMail/.env + # Edit .env + ``` + +2. **Configure Mail Accounts**: + Copy the `mbsyncrc` template to an actual config file and configure your IMAP servers. + ```bash + cp /home/adipu/AllMail/mail-sync/mbsyncrc.template /home/adipu/AllMail/mail-sync/mbsyncrc + # Edit mbsyncrc + ``` + +3. **Deploy Phase 1**: + After configuring the above files, you can start the system locally to ensure it builds correctly: + ```bash + cd /home/adipu/AllMail + docker compose up -d --build + ``` diff --git a/webmail/Dockerfile b/webmail/Dockerfile new file mode 100644 index 0000000..056252b --- /dev/null +++ b/webmail/Dockerfile @@ -0,0 +1,36 @@ +FROM node:20-alpine AS builder +WORKDIR /app +COPY spa/package*.json ./ +RUN npm install +COPY spa/ . +RUN npm run build + +FROM php:8.2-fpm-alpine + +RUN apk add --no-cache nginx wget unzip zip libzip-dev \ + && docker-php-ext-install zip + +# Install SnappyMail +WORKDIR /var/www/html/mail +RUN wget -O snappymail.zip https://snappymail.eu/repository/latest.zip && \ + unzip snappymail.zip && \ + rm snappymail.zip && \ + find . -type d -exec chmod 755 {} \; && \ + find . -type f -exec chmod 644 {} \; && \ + chown -R www-data:www-data /var/www/html/mail + +# Copy built SPA +COPY --from=builder /app/dist /var/www/html/spa +RUN chown -R www-data:www-data /var/www/html/spa + +# Copy configurations +COPY nginx.conf /etc/nginx/nginx.conf +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Create Nginx run directory +RUN mkdir -p /run/nginx + +EXPOSE 80 + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/webmail/entrypoint.sh b/webmail/entrypoint.sh new file mode 100644 index 0000000..927010e --- /dev/null +++ b/webmail/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +# Start PHP-FPM in the background +php-fpm -D + +# Start Nginx in the foreground +exec nginx -g "daemon off;" diff --git a/webmail/nginx.conf b/webmail/nginx.conf new file mode 100644 index 0000000..a25f6f9 --- /dev/null +++ b/webmail/nginx.conf @@ -0,0 +1,54 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + + # Serve the React SPA on the root path + location / { + root /var/www/html/spa; + index index.html; + try_files $uri $uri/ /index.html; + } + + # Proxy /api requests to the backend container + location /api/ { + proxy_pass http://api:8000/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + # Serve SnappyMail on /mail + location ^~ /mail/ { + alias /var/www/html/mail/; + index index.php index.html; + + # Need a specific regex for PHP files inside alias + location ~ \.php$ { + if (!-f $request_filename) { + return 404; + } + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $request_filename; + include fastcgi_params; + } + + # Deny access to SnappyMail data folder + location ^~ /mail/data { + deny all; + } + } + } +} diff --git a/webmail/spa/.gitignore b/webmail/spa/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/webmail/spa/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/webmail/spa/README.md b/webmail/spa/README.md new file mode 100644 index 0000000..a36934d --- /dev/null +++ b/webmail/spa/README.md @@ -0,0 +1,16 @@ +# React + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) + +## React Compiler + +The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project. diff --git a/webmail/spa/eslint.config.js b/webmail/spa/eslint.config.js new file mode 100644 index 0000000..ea36dd3 --- /dev/null +++ b/webmail/spa/eslint.config.js @@ -0,0 +1,21 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import { defineConfig, globalIgnores } from 'eslint/config' + +export default defineConfig([ + globalIgnores(['dist']), + { + files: ['**/*.{js,jsx}'], + extends: [ + js.configs.recommended, + reactHooks.configs.flat.recommended, + reactRefresh.configs.vite, + ], + languageOptions: { + globals: globals.browser, + parserOptions: { ecmaFeatures: { jsx: true } }, + }, + }, +]) diff --git a/webmail/spa/index.html b/webmail/spa/index.html new file mode 100644 index 0000000..e96b75b --- /dev/null +++ b/webmail/spa/index.html @@ -0,0 +1,13 @@ + + +
+ + + +{result.snippet}
+No results found.
+ )} +