This guide explains the new centralized configuration and database initialization system.
- Single
.envfile in the root directory - All modules (heise, chip, visualization) load from the same configuration
- No more duplicate
.envfiles in subdirectories
init_database.pyautomatically creates all required tables and columns- Runs automatically when you start
heise/main.pyorchip/main.py - Handles schema updates without manual intervention
- Cleaner sidebar with 6 main pages instead of 10
- Metrics moved to main area for better visibility
- Auto-refresh functionality with configurable intervals (30s, 60s, 120s, 300s)
- Faster data updates with 60-second cache TTL
- All UI text, comments, and function names are now in English
- Consistent terminology across the application
Create or edit .env file in the root directory:
# Database Configuration (default values)
DB_NAME=datamining
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=localhost
DB_PORT=5432
# Email Notifications (optional)
EMAIL_USER=your_email@example.com
EMAIL_PASSWORD=your_email_password
SMTP_SERVER=smtp.example.com
SMTP_PORT=587
ALERT_EMAIL=alert_recipient@example.com
# Google AI (optional, for Streamlit AI features)
GOOGLE_API_KEY=your_google_api_keyNote: A .env.example file is provided as a template.
The database will be automatically initialized on first run:
# Start Heise crawler
cd heise
python3 main.py
# Or start Chip crawler
cd chip
python3 main.pyOn first run, you'll see:
[INFO] Initializing database...
[SUCCESS] Table 'heise' initialized successfully
[SUCCESS] Table 'chip' initialized successfully
[SUCCESS] Crawl state tables initialized successfully
[SUCCESS] Database initialization completed successfully!
cd visualization
streamlit run streamlit_app.pyThe Streamlit dashboard now includes automatic data refresh:
- In the sidebar, check "Enable Auto-Refresh"
- Select your preferred interval (30s, 60s, 120s, or 300s)
- The dashboard will automatically reload data at the specified interval
You can also manually refresh data using the "🔄 Refresh Data" button.
The sidebar now has 6 main pages:
- 📊 Dashboard - Overview with key metrics and charts
- 📈 Time Analysis - Temporal trends and patterns
- 🔑 Keywords - Keyword frequency and analysis
- 🔍 Search - Search and filter articles
- 🕸️ Author Network - Visual relationship graphs
- 🔧 SQL Queries - Custom database queries
Key metrics (total articles, authors, categories, database status) are now displayed in the main content area instead of cluttering the sidebar.
CREATE TABLE heise (
id SERIAL PRIMARY KEY,
title TEXT,
url TEXT UNIQUE,
date TEXT,
author TEXT,
category TEXT,
keywords TEXT,
word_count INTEGER,
editor_abbr TEXT,
site_name TEXT
);CREATE TABLE chip (
id SERIAL PRIMARY KEY,
url TEXT UNIQUE,
title TEXT,
author TEXT,
date TEXT,
keywords TEXT,
description TEXT,
type TEXT,
page_level1 TEXT,
page_level2 TEXT,
page_level3 TEXT,
page_template TEXT
);CREATE TABLE heise_crawl_state (
id SERIAL PRIMARY KEY,
year INTEGER,
month INTEGER,
article_index INTEGER,
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE chip_crawl_state (
id SERIAL PRIMARY KEY,
sitemap_index INTEGER,
article_index INTEGER,
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);If you need to manually initialize the database:
python3 init_database.pyThis is useful for:
- Setting up the database before running crawlers
- Adding missing columns to existing tables
- Verifying database configuration
datamining/
├── .env # ⭐ Centralized configuration
├── .env.example # Template for configuration
├── init_database.py # ⭐ Database initialization module
├── heise/
│ ├── main.py # Heise crawler (auto-init DB)
│ ├── notification.py # Loads .env from root
│ └── ...
├── chip/
│ ├── main.py # Chip crawler (auto-init DB)
│ ├── notification.py # Loads .env from root
│ └── ...
└── visualization/
└── streamlit_app.py # Dashboard (loads .env from root)
-
Cache Duration: Data is cached for 60 seconds by default. For more frequent updates, the auto-refresh feature will bypass cache.
-
Database Connection: The dashboard checks database connectivity and displays status in real-time.
-
Filter Data: Use the "Data Source" filter in sidebar to focus on specific sources (Heise or Chip).
If you see "No data available. Check database connection":
-
Verify PostgreSQL is running:
sudo systemctl status postgresql
-
Check
.envconfiguration:cat .env
-
Test database connection:
python3 init_database.py
If you get ModuleNotFoundError:
pip install -r requirements.txtFor Streamlit-specific dependencies:
pip install -r visualization/requirements_streamlit.txt- Make sure "Enable Auto-Refresh" is checked in the sidebar
- The page will reload after the selected interval
- If using a very short interval (30s), be aware of database load
If you have existing .env files in subdirectories:
- Merge all
.envfiles into a single.envin the root directory - Remove old
.envfiles fromheise/,chip/, and other subdirectories - Restart all services to use the new configuration
The system will automatically use the root .env file.
- ✅ Configure
.envwith your database credentials - ✅ Run database initialization (automatic on first crawler start)
- ✅ Start crawlers to collect data
- ✅ Launch Streamlit dashboard to visualize data
- ✅ Enable auto-refresh for real-time monitoring
When adding new features:
- Use English for all code, comments, and documentation
- Load configuration from root
.envfile - Update
init_database.pyif adding new tables/columns - Keep the sidebar minimal and focused