ποΈ 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
- Docker Desktop installed
- Google Gemini API key from https://aistudio.google.com/apikey
Step 1: Download
git clone https://huggingface.co/Ultronprime/crcc-construction-hub-docker
cd crcc-construction-hub-docker
Step 2: Configure
cp .env.template .env
Edit .env with your actual credentials:
IMAP_HOST=imap.cr18gdubai.cn
IMAP_PORT=993
IMAP_USER=mohammad.jamzith@cr18gdubai.cn
IMAP_PASSWORD=your_actual_password
GOOGLE_API_KEY=your_gemini_api_key
Step 3: Run
docker compose up -d
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
# Start (background)
docker compose up -d
# View logs
docker compose logs -f
# Stop
docker compose down
# Restart (after .env changes)
docker compose restart
# Update (pull latest)
git 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.
- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "Ultronprime/crcc-construction-hub-docker"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
For non-causal architectures, replace AutoModelForCausalLM with the appropriate AutoModel class.