This guide explains all configuration options for OpenSite Analytics.
The backend configuration is managed through environment variables in backend/.env.
DATABASE_URL=sqlite:///./analytics.db
sqlite:///./analytics.dbAPI_HOST=0.0.0.0
API_PORT=8000
0.0.0.0 (all interfaces)8000SECRET_KEY=your-secret-key-change-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
python3 -c "import secrets; print(secrets.token_urlsafe(32))"HS25630 minutesCORS_ORIGINS=["http://localhost:3000"]
["http://localhost:3000"]["http://localhost:3000", "https://yourdomain.com"]RATE_LIMIT_REQUESTS=100
RATE_LIMIT_PERIOD=60
10060 (1 minute)DATA_RETENTION_DAYS=90
90 daysThe frontend configuration is managed through environment variables in frontend/.env.local.
NEXT_PUBLIC_API_URL=http://localhost:8000
http://localhost:8000Install PostgreSQL and create a database:
:::bash
createdb opensite_analytics
Update backend/.env:
:::env
DATABASE_URL=postgresql://user:password@localhost/opensite_analytics
Install PostgreSQL dependencies:
:::bash
pip3 install psycopg2-binary
Install MySQL and create a database:
:::bash
mysql -u root -p
CREATE DATABASE opensite_analytics;
Update backend/.env:
:::env
DATABASE_URL=mysql+pymysql://user:password@localhost/opensite_analytics
Install MySQL dependencies:
:::bash
pip3 install pymysql
Generate a secure random secret key:
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
Copy the output and use it as your SECRET_KEY.
To enable email notifications (not yet implemented), you would add:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-app-password
SMTP_FROM=noreply@yourdomain.com
.env files to version control