🏗️ CRCC Construction Intelligence Hub — Self-Hosted
Fully automated AI-powered email processing for construction project management.
Built for China Railway 18th Bureau Group (CRCC) • DSC Hotel (G+8) • Dubai Studio City
⚡ What It Does
Runs 24/7 on your machine. Automatically:
- Connects to your IMAP mail server (
imap.cr18gdubai.cn)
- Fetches new unread emails every 60 seconds
- Extracts attachments (PDFs, images, documents)
- Sends everything to Google Gemini 3 Flash Preview for AI analysis
- Extracts: document type, reference number, status, consultant comments, action required
- Stores structured data in a database
- Shows a live dashboard with charts, filters, search, and CSV/Excel export
Zero manual intervention required.
🚀 Quick Start (3 Minutes)
Prerequisites
Step 1: Download
1git clone https://huggingface.co/Ultronprime/crcc-construction-hub-docker
2cd crcc-construction-hub-docker
Step 2: Configure
Edit .env with your actual credentials:
1IMAP_HOST=imap.cr18gdubai.cn
2IMAP_PORT=993
3IMAP_USER=mohammad.jamzith@cr18gdubai.cn
4IMAP_PASSWORD=your_actual_password
5GOOGLE_API_KEY=your_gemini_api_key
Step 3: Run
Done! Open
http://localhost:8501 — the system is now monitoring your inbox.
📧 Email Server Compatibility
This app uses the exact same settings as your email client:
| Setting | Value |
|---|
| Protocol | IMAP4 |
| Host | imap.cr18gdubai.cn |
| Port | 993 |
| Security | TLS on special port (IMAP SSL) |
| Auth | Login/Password |
🤖 AI Model
Hardcoded: gemini-3-flash-preview
This model supports:
- Multimodal input (text + PDFs + images simultaneously)
- 1M+ token context window (handles large documents)
- Structured JSON output with schema enforcement
- Cost-efficient for high-volume processing
📁 Project Structure
crcc-construction-hub-docker/
├── app.py # Streamlit dashboard + controls
├── modules/
│ ├── database.py # SQLite persistence layer
│ ├── email_fetcher.py # IMAP client + attachment extraction
│ ├── gemini_processor.py # Gemini AI structured extraction
│ └── pipeline.py # Orchestration (fetch → AI → store)
├── docker-compose.yml # One-command deployment
├── Dockerfile # Container definition
├── requirements.txt # Python dependencies
├── .env.template # Configuration template
└── data/ # Persistent storage (auto-created)
├── construction_hub.db # SQLite database
└── attachments/ # Downloaded email attachments
⚙️ Configuration
All settings via .env file:
| Variable | Default | Description |
|---|
IMAP_HOST | imap.cr18gdubai.cn | Mail server |
IMAP_PORT | 993 | IMAP SSL port |
IMAP_USER | — | Your email address |
IMAP_PASSWORD | — | Your email password |
GOOGLE_API_KEY | — | Gemini API key |
EMAIL_CHECK_INTERVAL | 60 | Seconds between checks |
AUTO_START_POLLING | true | Start monitoring on app launch |
MAX_ATTACHMENT_SIZE_MB | 50 | Skip files larger than this |
LOG_LEVEL | INFO | Logging verbosity |
🖥️ Dashboard Features
- 📊 Dashboard — KPI metrics, charts by type/status/discipline, activity timeline
- 📋 Documents — Sortable/filterable table, detail view with AI summary
- 🔍 Search — Full-text search across all fields
- ⬇️ Export — CSV and Excel download for management meetings
- ⚙️ Settings — Test connections, view system status
🔄 Commands
1# Start (background)
2docker compose up -d
3
4# View logs
5docker compose logs -f
6
7# Stop
8docker compose down
9
10# Restart (after .env changes)
11docker compose restart
12
13# Update (pull latest)
14git pull && docker compose up -d --build
🛡️ Data Persistence
Your data survives container restarts:
./data/construction_hub.db — All processed emails and AI results
./data/attachments/ — Downloaded email attachments
To backup: just copy the data/ folder.
❓ Why Self-Hosted (Not Cloud)?
Your email server imap.cr18gdubai.cn is on a private network. Cloud platforms (HF Spaces, AWS Lambda, etc.) cannot reach it because:
- Port 993 is blocked by cloud egress firewalls
- The server may only accept connections from known IPs
Self-hosting on your office PC/server = direct network access to your mail server = full automation works.
🐛 Troubleshooting
| Issue | Fix |
|---|
| Can't connect to IMAP | Check VPN is active, verify credentials in .env |
| Gemini API 429 | Increase EMAIL_CHECK_INTERVAL to 120+ seconds |
| Container keeps restarting | Run docker compose logs to see the error |
| No emails processed | Check if emails are marked as read already |
| Want to reprocess old emails | Mark emails as unread in your mail client |
📄 License
Internal tool for CRCC. Not for distribution.
Generated by ML Intern
This model repository was generated by
ML Intern, an agent for machine learning research and development on the Hugging Face Hub.
Usage
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "Ultronprime/crcc-construction-hub-docker"
4tokenizer = AutoTokenizer.from_pretrained(model_id)
5model = AutoModelForCausalLM.from_pretrained(model_id)
For non-causal architectures, replace AutoModelForCausalLM with the appropriate AutoModel class.