Opensource Site Tracking Wiki
Self-hosted private analytics for real-time multi-site tracking.
Brought to you by:
autobotsolution
Welcome to the Open Source Site Tracking getting started guide. This document will help you set up and start using the platform quickly.
Before you begin, ensure you have the following installed:
git clone https://github.com/AutoBotSolutions/Opensource-Site-Tracking.git
cd opensource-site-tracking
# Navigate to backend directory
cd backend
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Initialize database
python init_db.py
# Start development server
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Navigate to frontend directory (in a new terminal)
cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
Open your browser and navigate to:
# Clone the repository
git clone https://github.com/AutoBotSolutions/Opensource-Site-Tracking.git
cd opensource-site-tracking
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
Create a .env file in the backend directory:
# Database Configuration
DATABASE_URL=sqlite:///site_tracking.db
# DATABASE_URL=postgresql://user:password@localhost/dbname
# Application Settings
SECRET_KEY=your-secret-key-here
DEBUG=True
ENVIRONMENT=development
# Analytics Settings
ANALYTICS_ENABLED=True
DATA_RETENTION_DAYS=365
# Security Settings
JWT_SECRET_KEY=your-jwt-secret-key
JWT_EXPIRATION_HOURS=24
Create a .env.local file in the frontend directory:
# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000
# Application Settings
NEXT_PUBLIC_APP_NAME=Open Source Site Tracking
NEXT_PUBLIC_APP_VERSION=1.0.0
# Navigate to backend directory
cd backend
# Create admin user
python scripts/create_admin.py --email admin@example.com --password admin123
Add the tracking script to your website:
<!-- Add to your website's <head> section -->
<script src="http://localhost:8000/tracking.js" data-project-id="your-project-id"></script>
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest
# Run with coverage
pytest --cov=app
# Code formatting
black app/
isort app/
# Type checking
mypy app/
# Install development dependencies
npm install --save-dev
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Code formatting
npm run format
npm run lint
# Type checking
npm run type-check
# Create new migration
python scripts/create_migration.py "migration_name"
# Apply migrations
python migrate.py upgrade
# Rollback migration
python migrate.py downgrade
Problem: Backend server won't start
# Check Python version
python --version
# Check virtual environment
which python
# Reinstall dependencies
pip install -r requirements.txt --force-reinstall
Problem: Database connection errors
# Check database file
ls -la site_tracking.db
# Recreate database
rm site_tracking.db
python init_db.py
Problem: Frontend build fails
# Clear node modules
rm -rf node_modules package-lock.json
npm install
# Clear Next.js cache
rm -rf .next
npm run dev
Problem: API connection errors
# Check backend is running
curl http://localhost:8000/health
# Check API URL in .env.local
cat .env.local
Now that you have the application running, consider:
Happy tracking! 🚀