Repository files navigation

WikiContest Platform

A comprehensive web platform for hosting and managing collaborative Wikipedia article competitions. Built with Flask (Python) backend and Vue.js 3 frontend.

Table of Contents

Overview

What This App Does

  • User Authentication - Register, login, and manage user accounts with support for email/password and OAuth
  • Contest Management - Create contests, set dates, define rules, and assign jury members
  • Article Submissions - Submit Wikipedia articles to contests and track their progress
  • Dashboard & Analytics - View user statistics, contest overview, and leaderboards
  • Responsive Design - Optimized for desktop and mobile devices
  • Real-time Updates - Dynamic content loading and notifications

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL 8.0 or higher (or use SQLite for quick testing)
  • Node.js 16+ (for frontend development)

Quick Start

Follow these steps to get the WikiContest platform running locally:

1. Clone the Repository

git clone <repository-url>cd wikicontest/backend

2. Create Virtual Environment

python -m venv venv
# On macOS/Linuxsource venv/bin/activate
# On Windows
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Setup MySQL Database

Option A: MySQL (Recommended for Production)

# Connect to MySQL
mysql -u root -p
# Create database
CREATE DATABASE wikicontest;

Option B: SQLite (Quick Testing)

Skip MySQL setup and use SQLite by editing .env (step 5) to use:

DATABASE_URL=sqlite:///wikicontest.db

5. Configure Environment

# Copy example environment file
cp .env.example .env
# Edit .env and update your configuration# At minimum, update DATABASE_URL with your MySQL credentials

Example .env configuration:

DATABASE_URL=mysql+pymysql://root:password@localhost/wikicontestSECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-here

6. Initialize Database

The application uses Alembic for database migrations. Run migrations to create the database schema:

# Apply all migrations
alembic upgrade head
# Alternative: Use helper script
python scripts/migrate.py upgrade head

Important: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.

7. Run the Application

You have two options for running the application:

Option A: Development Mode (Recommended)

Run both Flask and Vue.js dev servers in separate terminals for the best development experience:

Terminal 1 - Flask Backend:

python main.py

Terminal 2 - Vue.js Frontend:

cd ../frontend
npm install # Only needed first time
npm run dev

Access at:http://localhost:5173 (Vue.js dev server proxies API requests to Flask)

Option B: Production Build (Single Server)

Build the Vue.js frontend first, then run Flask to serve both API and built frontend:

# Build frontendcd ../frontend
npm install # Only needed first time
npm run build
# Run Flaskcd ../backend
python main.py

Access at:http://localhost:5000 (Flask serves built Vue.js files)

8. Open in Browser

  • Development Mode:http://localhost:5173
  • Production Build:http://localhost:5000

You should see the WikiContest login page. Register a new account to get started!

Configuration

Environment Variables

The .env.example file contains all available configuration options. Copy it to .env and customize:

# Database ConfigurationDATABASE_URL=mysql+pymysql://username:password@localhost/wikicontest# Security Keys (CHANGE IN PRODUCTION!)SECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-key-here# CORS Configuration (for frontend development)CORS_ORIGINS=http://localhost:5173,http://localhost:5000# OAuth 1.0a (Optional - for Wikimedia login)OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-hereCONSUMER_SECRET=your-consumer-secret-here

Configuration Tips

  • Database: Use MySQL for production, SQLite for quick local testing
  • Security Keys: Generate strong random keys for production environments
  • CORS: Add your frontend URLs to allow cross-origin requests during development
  • OAuth: Optional feature for Wikimedia login (see OAuth Setup)

Running the Application

Development Workflow

For the best development experience:

  1. Run Flask backend in one terminal: python main.py
  2. Run Vue.js dev server in another terminal: cd ../frontend && npm run dev
  3. Access the app at http://localhost:5173

The Vue.js dev server provides:

  • Hot module replacement (instant updates)
  • Automatic API proxying to Flask
  • Better debugging experience

Production Workflow

For production or testing the production build:

  1. Build frontend: cd frontend && npm run build
  2. Run Flask: cd backend && python main.py
  3. Access the app at http://localhost:5000

Flask serves the optimized, built Vue.js files.

🔧 Configuration

The .env.example file contains all configuration options. Copy it to .env and update:

  • Database: MySQL connection string (default)
  • Security Keys: Change in production!
  • CORS: Frontend development URLs
  • OAuth 1.0a: Wikimedia OAuth credentials (optional, for OAuth login)

Important Notes

  • Migrations: Always run alembic upgrade head before starting the app
  • Frontend Development: Use the Vue.js dev server (npm run dev) for the best experience
  • API Access: Backend API is available at http://localhost:5000/api/

OAuth Setup

OAuth 1.0a for Wikimedia Login (Optional)

Enable users to log in using their Wikimedia accounts:

1. Register OAuth Consumer

  1. Go to Wikimedia OAuth Registration
  2. Fill in your application details
  3. Set the callback URL:
    • Development:http://localhost:5000/api/user/oauth/callback
    • Production:https://yourdomain.com/api/user/oauth/callback
  4. Save and note your Consumer Key and Consumer Secret

2. Add Credentials to .env

OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-from-registrationCONSUMER_SECRET=your-consumer-secret-from-registration

3. Test OAuth Login

  1. Start the application
  2. Navigate to the login page
  3. Click "Login with Wikimedia"
  4. Authorize the application on Wikimedia
  5. You'll be redirected back and logged in automatically

Note: OAuth login works alongside regular email/password authentication. Users can choose either method.

Testing

Manual Testing

# Ensure migrations are applied
alembic upgrade head
# Start the application
python main.py
# Open http://localhost:5000 (or http://localhost:5173 in dev mode)

Test the Following Features:

  • User registration and login
  • Contest creation
  • Article submission
  • Dashboard functionality
  • Leaderboard display
  • OAuth login (if configured)

Automated Tests

# Install test dependencies
pip install pytest pytest-flask
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/

Production Deployment

1. Setup Production Environment

Configure production environment variables:

export FLASK_ENV=production
export FLASK_DEBUG=False
export DATABASE_URL=mysql+pymysql://user:pass@prod-host/wikicontest
export SECRET_KEY=strong-random-production-key
export JWT_SECRET_KEY=strong-random-jwt-key

2. Build Frontend

cd frontend
npm install
npm run build

3. Apply Database Migrations

cd backend
alembic upgrade head

4. Run with Production Server

# Install Gunicorn
pip install gunicorn
# Run with 4 worker processes
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"

5. Use Reverse Proxy (Recommended)

Set up Nginx or Apache as a reverse proxy:

Example Nginx configuration:

server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}

Project Structure

wikicontest/
├── backend/ # Flask backend application
│ ├── main.py # Application entry point
│ ├── app/ # Main application package
│ │ ├── __init__.py # Flask app factory
│ │ ├── config.py # Configuration management
│ │ ├── database.py # SQLAlchemy database
│ │ ├── models/ # Database models (User, Contest, Submission)
│ │ ├── routes/ # API endpoints (blueprints)
│ │ ├── middleware/ # Authentication & authorization
│ │ └── utils/ # Utility functions
│ ├── alembic/ # Database migrations (Alembic)
│ │ ├── versions/ # Migration version files
│ │ └── env.py # Alembic environment
│ ├── scripts/ # Utility scripts
│ ├── tests/ # Test files (pytest)
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment configuration
│
└── frontend/ # Vue.js 3 frontend application
├── src/ # Source files
│ ├── views/ # Page components (Home, Login, Dashboard, etc.)
│ ├── components/ # Reusable UI components
│ ├── router/ # Vue Router configuration
│ ├── store/ # State management (if using Vuex/Pinia)
│ ├── services/ # API service layer
│ └── App.vue # Root component
├── public/ # Static assets
├── package.json # Frontend dependencies
├── vite.config.js # Vite build configuration
└── index.html # HTML entry point

Key Directories

  • backend/app/models/ - Database models (User, Contest, Submission)
  • backend/app/routes/ - API endpoints organized by domain
  • backend/alembic/versions/ - Database migration history
  • frontend/src/views/ - Vue page components
  • frontend/src/components/ - Reusable Vue components

Frontend Technology

The frontend is built with modern Vue.js 3 and related technologies:

Tech Stack

  • Vue.js 3 - Progressive JavaScript framework with Composition API
  • Vue Router - Official router for client-side navigation
  • Vite - Next-generation frontend tooling for fast development
  • Bootstrap 5 - CSS framework for responsive design
  • Axios - Promise-based HTTP client for API communication

Frontend Features

  • Component-based architecture
  • Reactive data binding
  • Client-side routing
  • State management
  • Hot module replacement in development
  • Optimized production builds

Frontend Setup

For detailed frontend setup instructions, see docs/VUE_FRONTEND_SETUP.md.

Quick frontend commands:

cd frontend
# Install dependencies
npm install
# Development server with HMR
npm run dev
# Production build
npm run build
# Preview production build
npm run preview

Contributing

We welcome contributions to the WikiContest platform!

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Test thoroughly
    • Test both backend and frontend
    • Ensure all tests pass
  5. Submit a pull request
    • Describe your changes clearly
    • Reference any related issues

Development Guidelines

  • Follow Python PEP 8 for backend code
  • Follow Vue.js style guide for frontend code
  • Write meaningful commit messages
  • Add docstrings to Python functions
  • Comment complex logic
  • Keep functions focused and under 50 lines when possible

Additional Resources

License

This project is part of the WikiContest platform.

WikiContest Platform - Empowering collaborative Wikipedia article competitions!

About

A Wikipedia Contest Tool

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

WikiContest Platform

A comprehensive web platform for hosting and managing collaborative Wikipedia article competitions. Built with Flask (Python) backend and Vue.js 3 frontend.

Table of Contents

Overview

What This App Does

  • User Authentication - Register, login, and manage user accounts with support for email/password and OAuth
  • Contest Management - Create contests, set dates, define rules, and assign jury members
  • Article Submissions - Submit Wikipedia articles to contests and track their progress
  • Dashboard & Analytics - View user statistics, contest overview, and leaderboards
  • Responsive Design - Optimized for desktop and mobile devices
  • Real-time Updates - Dynamic content loading and notifications

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL 8.0 or higher (or use SQLite for quick testing)
  • Node.js 16+ (for frontend development)

Quick Start

Follow these steps to get the WikiContest platform running locally:

1. Clone the Repository

git clone <repository-url>cd wikicontest/backend

2. Create Virtual Environment

python -m venv venv
# On macOS/Linuxsource venv/bin/activate
# On Windows
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Setup MySQL Database

Option A: MySQL (Recommended for Production)

# Connect to MySQL
mysql -u root -p
# Create database
CREATE DATABASE wikicontest;

Option B: SQLite (Quick Testing)

Skip MySQL setup and use SQLite by editing .env (step 5) to use:

DATABASE_URL=sqlite:///wikicontest.db

5. Configure Environment

# Copy example environment file
cp .env.example .env
# Edit .env and update your configuration# At minimum, update DATABASE_URL with your MySQL credentials

Example .env configuration:

DATABASE_URL=mysql+pymysql://root:password@localhost/wikicontestSECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-here

6. Initialize Database

The application uses Alembic for database migrations. Run migrations to create the database schema:

# Apply all migrations
alembic upgrade head
# Alternative: Use helper script
python scripts/migrate.py upgrade head

Important: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.

7. Run the Application

You have two options for running the application:

Option A: Development Mode (Recommended)

Run both Flask and Vue.js dev servers in separate terminals for the best development experience:

Terminal 1 - Flask Backend:

python main.py

Terminal 2 - Vue.js Frontend:

cd ../frontend
npm install # Only needed first time
npm run dev

Access at:http://localhost:5173 (Vue.js dev server proxies API requests to Flask)

Option B: Production Build (Single Server)

Build the Vue.js frontend first, then run Flask to serve both API and built frontend:

# Build frontendcd ../frontend
npm install # Only needed first time
npm run build
# Run Flaskcd ../backend
python main.py

Access at:http://localhost:5000 (Flask serves built Vue.js files)

8. Open in Browser

  • Development Mode:http://localhost:5173
  • Production Build:http://localhost:5000

You should see the WikiContest login page. Register a new account to get started!

Configuration

Environment Variables

The .env.example file contains all available configuration options. Copy it to .env and customize:

# Database ConfigurationDATABASE_URL=mysql+pymysql://username:password@localhost/wikicontest# Security Keys (CHANGE IN PRODUCTION!)SECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-key-here# CORS Configuration (for frontend development)CORS_ORIGINS=http://localhost:5173,http://localhost:5000# OAuth 1.0a (Optional - for Wikimedia login)OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-hereCONSUMER_SECRET=your-consumer-secret-here

Configuration Tips

  • Database: Use MySQL for production, SQLite for quick local testing
  • Security Keys: Generate strong random keys for production environments
  • CORS: Add your frontend URLs to allow cross-origin requests during development
  • OAuth: Optional feature for Wikimedia login (see OAuth Setup)

Running the Application

Development Workflow

For the best development experience:

  1. Run Flask backend in one terminal: python main.py
  2. Run Vue.js dev server in another terminal: cd ../frontend && npm run dev
  3. Access the app at http://localhost:5173

The Vue.js dev server provides:

  • Hot module replacement (instant updates)
  • Automatic API proxying to Flask
  • Better debugging experience

Production Workflow

For production or testing the production build:

  1. Build frontend: cd frontend && npm run build
  2. Run Flask: cd backend && python main.py
  3. Access the app at http://localhost:5000

Flask serves the optimized, built Vue.js files.

🔧 Configuration

The .env.example file contains all configuration options. Copy it to .env and update:

  • Database: MySQL connection string (default)
  • Security Keys: Change in production!
  • CORS: Frontend development URLs
  • OAuth 1.0a: Wikimedia OAuth credentials (optional, for OAuth login)

Important Notes

  • Migrations: Always run alembic upgrade head before starting the app
  • Frontend Development: Use the Vue.js dev server (npm run dev) for the best experience
  • API Access: Backend API is available at http://localhost:5000/api/

OAuth Setup

OAuth 1.0a for Wikimedia Login (Optional)

Enable users to log in using their Wikimedia accounts:

1. Register OAuth Consumer

  1. Go to Wikimedia OAuth Registration
  2. Fill in your application details
  3. Set the callback URL:
    • Development:http://localhost:5000/api/user/oauth/callback
    • Production:https://yourdomain.com/api/user/oauth/callback
  4. Save and note your Consumer Key and Consumer Secret

2. Add Credentials to .env

OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-from-registrationCONSUMER_SECRET=your-consumer-secret-from-registration

3. Test OAuth Login

  1. Start the application
  2. Navigate to the login page
  3. Click "Login with Wikimedia"
  4. Authorize the application on Wikimedia
  5. You'll be redirected back and logged in automatically

Note: OAuth login works alongside regular email/password authentication. Users can choose either method.

Testing

Manual Testing

# Ensure migrations are applied
alembic upgrade head
# Start the application
python main.py
# Open http://localhost:5000 (or http://localhost:5173 in dev mode)

Test the Following Features:

  • User registration and login
  • Contest creation
  • Article submission
  • Dashboard functionality
  • Leaderboard display
  • OAuth login (if configured)

Automated Tests

# Install test dependencies
pip install pytest pytest-flask
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/

Production Deployment

1. Setup Production Environment

Configure production environment variables:

export FLASK_ENV=production
export FLASK_DEBUG=False
export DATABASE_URL=mysql+pymysql://user:pass@prod-host/wikicontest
export SECRET_KEY=strong-random-production-key
export JWT_SECRET_KEY=strong-random-jwt-key

2. Build Frontend

cd frontend
npm install
npm run build

3. Apply Database Migrations

cd backend
alembic upgrade head

4. Run with Production Server

# Install Gunicorn
pip install gunicorn
# Run with 4 worker processes
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"

5. Use Reverse Proxy (Recommended)

Set up Nginx or Apache as a reverse proxy:

Example Nginx configuration:

server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}

Project Structure

wikicontest/
├── backend/ # Flask backend application
│ ├── main.py # Application entry point
│ ├── app/ # Main application package
│ │ ├── __init__.py # Flask app factory
│ │ ├── config.py # Configuration management
│ │ ├── database.py # SQLAlchemy database
│ │ ├── models/ # Database models (User, Contest, Submission)
│ │ ├── routes/ # API endpoints (blueprints)
│ │ ├── middleware/ # Authentication & authorization
│ │ └── utils/ # Utility functions
│ ├── alembic/ # Database migrations (Alembic)
│ │ ├── versions/ # Migration version files
│ │ └── env.py # Alembic environment
│ ├── scripts/ # Utility scripts
│ ├── tests/ # Test files (pytest)
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment configuration
│
└── frontend/ # Vue.js 3 frontend application
├── src/ # Source files
│ ├── views/ # Page components (Home, Login, Dashboard, etc.)
│ ├── components/ # Reusable UI components
│ ├── router/ # Vue Router configuration
│ ├── store/ # State management (if using Vuex/Pinia)
│ ├── services/ # API service layer
│ └── App.vue # Root component
├── public/ # Static assets
├── package.json # Frontend dependencies
├── vite.config.js # Vite build configuration
└── index.html # HTML entry point

Key Directories

  • backend/app/models/ - Database models (User, Contest, Submission)
  • backend/app/routes/ - API endpoints organized by domain
  • backend/alembic/versions/ - Database migration history
  • frontend/src/views/ - Vue page components
  • frontend/src/components/ - Reusable Vue components

Frontend Technology

The frontend is built with modern Vue.js 3 and related technologies:

Tech Stack

  • Vue.js 3 - Progressive JavaScript framework with Composition API
  • Vue Router - Official router for client-side navigation
  • Vite - Next-generation frontend tooling for fast development
  • Bootstrap 5 - CSS framework for responsive design
  • Axios - Promise-based HTTP client for API communication

Frontend Features

  • Component-based architecture
  • Reactive data binding
  • Client-side routing
  • State management
  • Hot module replacement in development
  • Optimized production builds

Frontend Setup

For detailed frontend setup instructions, see docs/VUE_FRONTEND_SETUP.md.

Quick frontend commands:

cd frontend
# Install dependencies
npm install
# Development server with HMR
npm run dev
# Production build
npm run build
# Preview production build
npm run preview

Contributing

We welcome contributions to the WikiContest platform!

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Test thoroughly
    • Test both backend and frontend
    • Ensure all tests pass
  5. Submit a pull request
    • Describe your changes clearly
    • Reference any related issues

Development Guidelines

  • Follow Python PEP 8 for backend code
  • Follow Vue.js style guide for frontend code
  • Write meaningful commit messages
  • Add docstrings to Python functions
  • Comment complex logic
  • Keep functions focused and under 50 lines when possible

Additional Resources

License

This project is part of the WikiContest platform.

WikiContest Platform - Empowering collaborative Wikipedia article competitions!

About

A Wikipedia Contest Tool

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

WikiContest Platform

A comprehensive web platform for hosting and managing collaborative Wikipedia article competitions. Built with Flask (Python) backend and Vue.js 3 frontend.

Table of Contents

Overview

What This App Does

  • User Authentication - Register, login, and manage user accounts with support for email/password and OAuth
  • Contest Management - Create contests, set dates, define rules, and assign jury members
  • Article Submissions - Submit Wikipedia articles to contests and track their progress
  • Dashboard & Analytics - View user statistics, contest overview, and leaderboards
  • Responsive Design - Optimized for desktop and mobile devices
  • Real-time Updates - Dynamic content loading and notifications

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL 8.0 or higher (or use SQLite for quick testing)
  • Node.js 16+ (for frontend development)

Quick Start

Follow these steps to get the WikiContest platform running locally:

1. Clone the Repository

git clone <repository-url>cd wikicontest/backend

2. Create Virtual Environment

python -m venv venv
# On macOS/Linuxsource venv/bin/activate
# On Windows
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Setup MySQL Database

Option A: MySQL (Recommended for Production)

# Connect to MySQL
mysql -u root -p
# Create database
CREATE DATABASE wikicontest;

Option B: SQLite (Quick Testing)

Skip MySQL setup and use SQLite by editing .env (step 5) to use:

DATABASE_URL=sqlite:///wikicontest.db

5. Configure Environment

# Copy example environment file
cp .env.example .env
# Edit .env and update your configuration# At minimum, update DATABASE_URL with your MySQL credentials

Example .env configuration:

DATABASE_URL=mysql+pymysql://root:password@localhost/wikicontestSECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-here

6. Initialize Database

The application uses Alembic for database migrations. Run migrations to create the database schema:

# Apply all migrations
alembic upgrade head
# Alternative: Use helper script
python scripts/migrate.py upgrade head

Important: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.

7. Run the Application

You have two options for running the application:

Option A: Development Mode (Recommended)

Run both Flask and Vue.js dev servers in separate terminals for the best development experience:

Terminal 1 - Flask Backend:

python main.py

Terminal 2 - Vue.js Frontend:

cd ../frontend
npm install # Only needed first time
npm run dev

Access at:http://localhost:5173 (Vue.js dev server proxies API requests to Flask)

Option B: Production Build (Single Server)

Build the Vue.js frontend first, then run Flask to serve both API and built frontend:

# Build frontendcd ../frontend
npm install # Only needed first time
npm run build
# Run Flaskcd ../backend
python main.py

Access at:http://localhost:5000 (Flask serves built Vue.js files)

8. Open in Browser

  • Development Mode:http://localhost:5173
  • Production Build:http://localhost:5000

You should see the WikiContest login page. Register a new account to get started!

Configuration

Environment Variables

The .env.example file contains all available configuration options. Copy it to .env and customize:

# Database ConfigurationDATABASE_URL=mysql+pymysql://username:password@localhost/wikicontest# Security Keys (CHANGE IN PRODUCTION!)SECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-key-here# CORS Configuration (for frontend development)CORS_ORIGINS=http://localhost:5173,http://localhost:5000# OAuth 1.0a (Optional - for Wikimedia login)OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-hereCONSUMER_SECRET=your-consumer-secret-here

Configuration Tips

  • Database: Use MySQL for production, SQLite for quick local testing
  • Security Keys: Generate strong random keys for production environments
  • CORS: Add your frontend URLs to allow cross-origin requests during development
  • OAuth: Optional feature for Wikimedia login (see OAuth Setup)

Running the Application

Development Workflow

For the best development experience:

  1. Run Flask backend in one terminal: python main.py
  2. Run Vue.js dev server in another terminal: cd ../frontend && npm run dev
  3. Access the app at http://localhost:5173

The Vue.js dev server provides:

  • Hot module replacement (instant updates)
  • Automatic API proxying to Flask
  • Better debugging experience

Production Workflow

For production or testing the production build:

  1. Build frontend: cd frontend && npm run build
  2. Run Flask: cd backend && python main.py
  3. Access the app at http://localhost:5000

Flask serves the optimized, built Vue.js files.

🔧 Configuration

The .env.example file contains all configuration options. Copy it to .env and update:

  • Database: MySQL connection string (default)
  • Security Keys: Change in production!
  • CORS: Frontend development URLs
  • OAuth 1.0a: Wikimedia OAuth credentials (optional, for OAuth login)

Important Notes

  • Migrations: Always run alembic upgrade head before starting the app
  • Frontend Development: Use the Vue.js dev server (npm run dev) for the best experience
  • API Access: Backend API is available at http://localhost:5000/api/

OAuth Setup

OAuth 1.0a for Wikimedia Login (Optional)

Enable users to log in using their Wikimedia accounts:

1. Register OAuth Consumer

  1. Go to Wikimedia OAuth Registration
  2. Fill in your application details
  3. Set the callback URL:
    • Development:http://localhost:5000/api/user/oauth/callback
    • Production:https://yourdomain.com/api/user/oauth/callback
  4. Save and note your Consumer Key and Consumer Secret

2. Add Credentials to .env

OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-from-registrationCONSUMER_SECRET=your-consumer-secret-from-registration

3. Test OAuth Login

  1. Start the application
  2. Navigate to the login page
  3. Click "Login with Wikimedia"
  4. Authorize the application on Wikimedia
  5. You'll be redirected back and logged in automatically

Note: OAuth login works alongside regular email/password authentication. Users can choose either method.

Testing

Manual Testing

# Ensure migrations are applied
alembic upgrade head
# Start the application
python main.py
# Open http://localhost:5000 (or http://localhost:5173 in dev mode)

Test the Following Features:

  • User registration and login
  • Contest creation
  • Article submission
  • Dashboard functionality
  • Leaderboard display
  • OAuth login (if configured)

Automated Tests

# Install test dependencies
pip install pytest pytest-flask
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/

Production Deployment

1. Setup Production Environment

Configure production environment variables:

export FLASK_ENV=production
export FLASK_DEBUG=False
export DATABASE_URL=mysql+pymysql://user:pass@prod-host/wikicontest
export SECRET_KEY=strong-random-production-key
export JWT_SECRET_KEY=strong-random-jwt-key

2. Build Frontend

cd frontend
npm install
npm run build

3. Apply Database Migrations

cd backend
alembic upgrade head

4. Run with Production Server

# Install Gunicorn
pip install gunicorn
# Run with 4 worker processes
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"

5. Use Reverse Proxy (Recommended)

Set up Nginx or Apache as a reverse proxy:

Example Nginx configuration:

server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}

Project Structure

wikicontest/
├── backend/ # Flask backend application
│ ├── main.py # Application entry point
│ ├── app/ # Main application package
│ │ ├── __init__.py # Flask app factory
│ │ ├── config.py # Configuration management
│ │ ├── database.py # SQLAlchemy database
│ │ ├── models/ # Database models (User, Contest, Submission)
│ │ ├── routes/ # API endpoints (blueprints)
│ │ ├── middleware/ # Authentication & authorization
│ │ └── utils/ # Utility functions
│ ├── alembic/ # Database migrations (Alembic)
│ │ ├── versions/ # Migration version files
│ │ └── env.py # Alembic environment
│ ├── scripts/ # Utility scripts
│ ├── tests/ # Test files (pytest)
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment configuration
│
└── frontend/ # Vue.js 3 frontend application
├── src/ # Source files
│ ├── views/ # Page components (Home, Login, Dashboard, etc.)
│ ├── components/ # Reusable UI components
│ ├── router/ # Vue Router configuration
│ ├── store/ # State management (if using Vuex/Pinia)
│ ├── services/ # API service layer
│ └── App.vue # Root component
├── public/ # Static assets
├── package.json # Frontend dependencies
├── vite.config.js # Vite build configuration
└── index.html # HTML entry point

Key Directories

  • backend/app/models/ - Database models (User, Contest, Submission)
  • backend/app/routes/ - API endpoints organized by domain
  • backend/alembic/versions/ - Database migration history
  • frontend/src/views/ - Vue page components
  • frontend/src/components/ - Reusable Vue components

Frontend Technology

The frontend is built with modern Vue.js 3 and related technologies:

Tech Stack

  • Vue.js 3 - Progressive JavaScript framework with Composition API
  • Vue Router - Official router for client-side navigation
  • Vite - Next-generation frontend tooling for fast development
  • Bootstrap 5 - CSS framework for responsive design
  • Axios - Promise-based HTTP client for API communication

Frontend Features

  • Component-based architecture
  • Reactive data binding
  • Client-side routing
  • State management
  • Hot module replacement in development
  • Optimized production builds

Frontend Setup

For detailed frontend setup instructions, see docs/VUE_FRONTEND_SETUP.md.

Quick frontend commands:

cd frontend
# Install dependencies
npm install
# Development server with HMR
npm run dev
# Production build
npm run build
# Preview production build
npm run preview

Contributing

We welcome contributions to the WikiContest platform!

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Test thoroughly
    • Test both backend and frontend
    • Ensure all tests pass
  5. Submit a pull request
    • Describe your changes clearly
    • Reference any related issues

Development Guidelines

  • Follow Python PEP 8 for backend code
  • Follow Vue.js style guide for frontend code
  • Write meaningful commit messages
  • Add docstrings to Python functions
  • Comment complex logic
  • Keep functions focused and under 50 lines when possible

Additional Resources

License

This project is part of the WikiContest platform.

WikiContest Platform - Empowering collaborative Wikipedia article competitions!

About

A Wikipedia Contest Tool

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

WikiContest Platform

A comprehensive web platform for hosting and managing collaborative Wikipedia article competitions. Built with Flask (Python) backend and Vue.js 3 frontend.

Table of Contents

Overview

What This App Does

  • User Authentication - Register, login, and manage user accounts with support for email/password and OAuth
  • Contest Management - Create contests, set dates, define rules, and assign jury members
  • Article Submissions - Submit Wikipedia articles to contests and track their progress
  • Dashboard & Analytics - View user statistics, contest overview, and leaderboards
  • Responsive Design - Optimized for desktop and mobile devices
  • Real-time Updates - Dynamic content loading and notifications

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL 8.0 or higher (or use SQLite for quick testing)
  • Node.js 16+ (for frontend development)

Quick Start

Follow these steps to get the WikiContest platform running locally:

1. Clone the Repository

git clone <repository-url>cd wikicontest/backend

2. Create Virtual Environment

python -m venv venv
# On macOS/Linuxsource venv/bin/activate
# On Windows
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Setup MySQL Database

Option A: MySQL (Recommended for Production)

# Connect to MySQL
mysql -u root -p
# Create database
CREATE DATABASE wikicontest;

Option B: SQLite (Quick Testing)

Skip MySQL setup and use SQLite by editing .env (step 5) to use:

DATABASE_URL=sqlite:///wikicontest.db

5. Configure Environment

# Copy example environment file
cp .env.example .env
# Edit .env and update your configuration# At minimum, update DATABASE_URL with your MySQL credentials

Example .env configuration:

DATABASE_URL=mysql+pymysql://root:password@localhost/wikicontestSECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-here

6. Initialize Database

The application uses Alembic for database migrations. Run migrations to create the database schema:

# Apply all migrations
alembic upgrade head
# Alternative: Use helper script
python scripts/migrate.py upgrade head

Important: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.

7. Run the Application

You have two options for running the application:

Option A: Development Mode (Recommended)

Run both Flask and Vue.js dev servers in separate terminals for the best development experience:

Terminal 1 - Flask Backend:

python main.py

Terminal 2 - Vue.js Frontend:

cd ../frontend
npm install # Only needed first time
npm run dev

Access at:http://localhost:5173 (Vue.js dev server proxies API requests to Flask)

Option B: Production Build (Single Server)

Build the Vue.js frontend first, then run Flask to serve both API and built frontend:

# Build frontendcd ../frontend
npm install # Only needed first time
npm run build
# Run Flaskcd ../backend
python main.py

Access at:http://localhost:5000 (Flask serves built Vue.js files)

8. Open in Browser

  • Development Mode:http://localhost:5173
  • Production Build:http://localhost:5000

You should see the WikiContest login page. Register a new account to get started!

Configuration

Environment Variables

The .env.example file contains all available configuration options. Copy it to .env and customize:

# Database ConfigurationDATABASE_URL=mysql+pymysql://username:password@localhost/wikicontest# Security Keys (CHANGE IN PRODUCTION!)SECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-key-here# CORS Configuration (for frontend development)CORS_ORIGINS=http://localhost:5173,http://localhost:5000# OAuth 1.0a (Optional - for Wikimedia login)OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-hereCONSUMER_SECRET=your-consumer-secret-here

Configuration Tips

  • Database: Use MySQL for production, SQLite for quick local testing
  • Security Keys: Generate strong random keys for production environments
  • CORS: Add your frontend URLs to allow cross-origin requests during development
  • OAuth: Optional feature for Wikimedia login (see OAuth Setup)

Running the Application

Development Workflow

For the best development experience:

  1. Run Flask backend in one terminal: python main.py
  2. Run Vue.js dev server in another terminal: cd ../frontend && npm run dev
  3. Access the app at http://localhost:5173

The Vue.js dev server provides:

  • Hot module replacement (instant updates)
  • Automatic API proxying to Flask
  • Better debugging experience

Production Workflow

For production or testing the production build:

  1. Build frontend: cd frontend && npm run build
  2. Run Flask: cd backend && python main.py
  3. Access the app at http://localhost:5000

Flask serves the optimized, built Vue.js files.

🔧 Configuration

The .env.example file contains all configuration options. Copy it to .env and update:

  • Database: MySQL connection string (default)
  • Security Keys: Change in production!
  • CORS: Frontend development URLs
  • OAuth 1.0a: Wikimedia OAuth credentials (optional, for OAuth login)

Important Notes

  • Migrations: Always run alembic upgrade head before starting the app
  • Frontend Development: Use the Vue.js dev server (npm run dev) for the best experience
  • API Access: Backend API is available at http://localhost:5000/api/

OAuth Setup

OAuth 1.0a for Wikimedia Login (Optional)

Enable users to log in using their Wikimedia accounts:

1. Register OAuth Consumer

  1. Go to Wikimedia OAuth Registration
  2. Fill in your application details
  3. Set the callback URL:
    • Development:http://localhost:5000/api/user/oauth/callback
    • Production:https://yourdomain.com/api/user/oauth/callback
  4. Save and note your Consumer Key and Consumer Secret

2. Add Credentials to .env

OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-from-registrationCONSUMER_SECRET=your-consumer-secret-from-registration

3. Test OAuth Login

  1. Start the application
  2. Navigate to the login page
  3. Click "Login with Wikimedia"
  4. Authorize the application on Wikimedia
  5. You'll be redirected back and logged in automatically

Note: OAuth login works alongside regular email/password authentication. Users can choose either method.

Testing

Manual Testing

# Ensure migrations are applied
alembic upgrade head
# Start the application
python main.py
# Open http://localhost:5000 (or http://localhost:5173 in dev mode)

Test the Following Features:

  • User registration and login
  • Contest creation
  • Article submission
  • Dashboard functionality
  • Leaderboard display
  • OAuth login (if configured)

Automated Tests

# Install test dependencies
pip install pytest pytest-flask
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/

Production Deployment

1. Setup Production Environment

Configure production environment variables:

export FLASK_ENV=production
export FLASK_DEBUG=False
export DATABASE_URL=mysql+pymysql://user:pass@prod-host/wikicontest
export SECRET_KEY=strong-random-production-key
export JWT_SECRET_KEY=strong-random-jwt-key

2. Build Frontend

cd frontend
npm install
npm run build

3. Apply Database Migrations

cd backend
alembic upgrade head

4. Run with Production Server

# Install Gunicorn
pip install gunicorn
# Run with 4 worker processes
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"

5. Use Reverse Proxy (Recommended)

Set up Nginx or Apache as a reverse proxy:

Example Nginx configuration:

server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}

Project Structure

wikicontest/
├── backend/ # Flask backend application
│ ├── main.py # Application entry point
│ ├── app/ # Main application package
│ │ ├── __init__.py # Flask app factory
│ │ ├── config.py # Configuration management
│ │ ├── database.py # SQLAlchemy database
│ │ ├── models/ # Database models (User, Contest, Submission)
│ │ ├── routes/ # API endpoints (blueprints)
│ │ ├── middleware/ # Authentication & authorization
│ │ └── utils/ # Utility functions
│ ├── alembic/ # Database migrations (Alembic)
│ │ ├── versions/ # Migration version files
│ │ └── env.py # Alembic environment
│ ├── scripts/ # Utility scripts
│ ├── tests/ # Test files (pytest)
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment configuration
│
└── frontend/ # Vue.js 3 frontend application
├── src/ # Source files
│ ├── views/ # Page components (Home, Login, Dashboard, etc.)
│ ├── components/ # Reusable UI components
│ ├── router/ # Vue Router configuration
│ ├── store/ # State management (if using Vuex/Pinia)
│ ├── services/ # API service layer
│ └── App.vue # Root component
├── public/ # Static assets
├── package.json # Frontend dependencies
├── vite.config.js # Vite build configuration
└── index.html # HTML entry point

Key Directories

  • backend/app/models/ - Database models (User, Contest, Submission)
  • backend/app/routes/ - API endpoints organized by domain
  • backend/alembic/versions/ - Database migration history
  • frontend/src/views/ - Vue page components
  • frontend/src/components/ - Reusable Vue components

Frontend Technology

The frontend is built with modern Vue.js 3 and related technologies:

Tech Stack

  • Vue.js 3 - Progressive JavaScript framework with Composition API
  • Vue Router - Official router for client-side navigation
  • Vite - Next-generation frontend tooling for fast development
  • Bootstrap 5 - CSS framework for responsive design
  • Axios - Promise-based HTTP client for API communication

Frontend Features

  • Component-based architecture
  • Reactive data binding
  • Client-side routing
  • State management
  • Hot module replacement in development
  • Optimized production builds

Frontend Setup

For detailed frontend setup instructions, see docs/VUE_FRONTEND_SETUP.md.

Quick frontend commands:

cd frontend
# Install dependencies
npm install
# Development server with HMR
npm run dev
# Production build
npm run build
# Preview production build
npm run preview

Contributing

We welcome contributions to the WikiContest platform!

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Test thoroughly
    • Test both backend and frontend
    • Ensure all tests pass
  5. Submit a pull request
    • Describe your changes clearly
    • Reference any related issues

Development Guidelines

  • Follow Python PEP 8 for backend code
  • Follow Vue.js style guide for frontend code
  • Write meaningful commit messages
  • Add docstrings to Python functions
  • Comment complex logic
  • Keep functions focused and under 50 lines when possible

Additional Resources

License

This project is part of the WikiContest platform.

WikiContest Platform - Empowering collaborative Wikipedia article competitions!

About

A Wikipedia Contest Tool

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

WikiContest Platform

A comprehensive web platform for hosting and managing collaborative Wikipedia article competitions. Built with Flask (Python) backend and Vue.js 3 frontend.

Table of Contents

Overview

What This App Does

  • User Authentication - Register, login, and manage user accounts with support for email/password and OAuth
  • Contest Management - Create contests, set dates, define rules, and assign jury members
  • Article Submissions - Submit Wikipedia articles to contests and track their progress
  • Dashboard & Analytics - View user statistics, contest overview, and leaderboards
  • Responsive Design - Optimized for desktop and mobile devices
  • Real-time Updates - Dynamic content loading and notifications

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL 8.0 or higher (or use SQLite for quick testing)
  • Node.js 16+ (for frontend development)

Quick Start

Follow these steps to get the WikiContest platform running locally:

1. Clone the Repository

git clone <repository-url>cd wikicontest/backend

2. Create Virtual Environment

python -m venv venv
# On macOS/Linuxsource venv/bin/activate
# On Windows
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Setup MySQL Database

Option A: MySQL (Recommended for Production)

# Connect to MySQL
mysql -u root -p
# Create database
CREATE DATABASE wikicontest;

Option B: SQLite (Quick Testing)

Skip MySQL setup and use SQLite by editing .env (step 5) to use:

DATABASE_URL=sqlite:///wikicontest.db

5. Configure Environment

# Copy example environment file
cp .env.example .env
# Edit .env and update your configuration# At minimum, update DATABASE_URL with your MySQL credentials

Example .env configuration:

DATABASE_URL=mysql+pymysql://root:password@localhost/wikicontestSECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-here

6. Initialize Database

The application uses Alembic for database migrations. Run migrations to create the database schema:

# Apply all migrations
alembic upgrade head
# Alternative: Use helper script
python scripts/migrate.py upgrade head

Important: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.

7. Run the Application

You have two options for running the application:

Option A: Development Mode (Recommended)

Run both Flask and Vue.js dev servers in separate terminals for the best development experience:

Terminal 1 - Flask Backend:

python main.py

Terminal 2 - Vue.js Frontend:

cd ../frontend
npm install # Only needed first time
npm run dev

Access at:http://localhost:5173 (Vue.js dev server proxies API requests to Flask)

Option B: Production Build (Single Server)

Build the Vue.js frontend first, then run Flask to serve both API and built frontend:

# Build frontendcd ../frontend
npm install # Only needed first time
npm run build
# Run Flaskcd ../backend
python main.py

Access at:http://localhost:5000 (Flask serves built Vue.js files)

8. Open in Browser

  • Development Mode:http://localhost:5173
  • Production Build:http://localhost:5000

You should see the WikiContest login page. Register a new account to get started!

Configuration

Environment Variables

The .env.example file contains all available configuration options. Copy it to .env and customize:

# Database ConfigurationDATABASE_URL=mysql+pymysql://username:password@localhost/wikicontest# Security Keys (CHANGE IN PRODUCTION!)SECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-key-here# CORS Configuration (for frontend development)CORS_ORIGINS=http://localhost:5173,http://localhost:5000# OAuth 1.0a (Optional - for Wikimedia login)OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-hereCONSUMER_SECRET=your-consumer-secret-here

Configuration Tips

  • Database: Use MySQL for production, SQLite for quick local testing
  • Security Keys: Generate strong random keys for production environments
  • CORS: Add your frontend URLs to allow cross-origin requests during development
  • OAuth: Optional feature for Wikimedia login (see OAuth Setup)

Running the Application

Development Workflow

For the best development experience:

  1. Run Flask backend in one terminal: python main.py
  2. Run Vue.js dev server in another terminal: cd ../frontend && npm run dev
  3. Access the app at http://localhost:5173

The Vue.js dev server provides:

  • Hot module replacement (instant updates)
  • Automatic API proxying to Flask
  • Better debugging experience

Production Workflow

For production or testing the production build:

  1. Build frontend: cd frontend && npm run build
  2. Run Flask: cd backend && python main.py
  3. Access the app at http://localhost:5000

Flask serves the optimized, built Vue.js files.

🔧 Configuration

The .env.example file contains all configuration options. Copy it to .env and update:

  • Database: MySQL connection string (default)
  • Security Keys: Change in production!
  • CORS: Frontend development URLs
  • OAuth 1.0a: Wikimedia OAuth credentials (optional, for OAuth login)

Important Notes

  • Migrations: Always run alembic upgrade head before starting the app
  • Frontend Development: Use the Vue.js dev server (npm run dev) for the best experience
  • API Access: Backend API is available at http://localhost:5000/api/

OAuth Setup

OAuth 1.0a for Wikimedia Login (Optional)

Enable users to log in using their Wikimedia accounts:

1. Register OAuth Consumer

  1. Go to Wikimedia OAuth Registration
  2. Fill in your application details
  3. Set the callback URL:
    • Development:http://localhost:5000/api/user/oauth/callback
    • Production:https://yourdomain.com/api/user/oauth/callback
  4. Save and note your Consumer Key and Consumer Secret

2. Add Credentials to .env

OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-from-registrationCONSUMER_SECRET=your-consumer-secret-from-registration

3. Test OAuth Login

  1. Start the application
  2. Navigate to the login page
  3. Click "Login with Wikimedia"
  4. Authorize the application on Wikimedia
  5. You'll be redirected back and logged in automatically

Note: OAuth login works alongside regular email/password authentication. Users can choose either method.

Testing

Manual Testing

# Ensure migrations are applied
alembic upgrade head
# Start the application
python main.py
# Open http://localhost:5000 (or http://localhost:5173 in dev mode)

Test the Following Features:

  • User registration and login
  • Contest creation
  • Article submission
  • Dashboard functionality
  • Leaderboard display
  • OAuth login (if configured)

Automated Tests

# Install test dependencies
pip install pytest pytest-flask
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/

Production Deployment

1. Setup Production Environment

Configure production environment variables:

export FLASK_ENV=production
export FLASK_DEBUG=False
export DATABASE_URL=mysql+pymysql://user:pass@prod-host/wikicontest
export SECRET_KEY=strong-random-production-key
export JWT_SECRET_KEY=strong-random-jwt-key

2. Build Frontend

cd frontend
npm install
npm run build

3. Apply Database Migrations

cd backend
alembic upgrade head

4. Run with Production Server

# Install Gunicorn
pip install gunicorn
# Run with 4 worker processes
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"

5. Use Reverse Proxy (Recommended)

Set up Nginx or Apache as a reverse proxy:

Example Nginx configuration:

server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}

Project Structure

wikicontest/
├── backend/ # Flask backend application
│ ├── main.py # Application entry point
│ ├── app/ # Main application package
│ │ ├── __init__.py # Flask app factory
│ │ ├── config.py # Configuration management
│ │ ├── database.py # SQLAlchemy database
│ │ ├── models/ # Database models (User, Contest, Submission)
│ │ ├── routes/ # API endpoints (blueprints)
│ │ ├── middleware/ # Authentication & authorization
│ │ └── utils/ # Utility functions
│ ├── alembic/ # Database migrations (Alembic)
│ │ ├── versions/ # Migration version files
│ │ └── env.py # Alembic environment
│ ├── scripts/ # Utility scripts
│ ├── tests/ # Test files (pytest)
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment configuration
│
└── frontend/ # Vue.js 3 frontend application
├── src/ # Source files
│ ├── views/ # Page components (Home, Login, Dashboard, etc.)
│ ├── components/ # Reusable UI components
│ ├── router/ # Vue Router configuration
│ ├── store/ # State management (if using Vuex/Pinia)
│ ├── services/ # API service layer
│ └── App.vue # Root component
├── public/ # Static assets
├── package.json # Frontend dependencies
├── vite.config.js # Vite build configuration
└── index.html # HTML entry point

Key Directories

  • backend/app/models/ - Database models (User, Contest, Submission)
  • backend/app/routes/ - API endpoints organized by domain
  • backend/alembic/versions/ - Database migration history
  • frontend/src/views/ - Vue page components
  • frontend/src/components/ - Reusable Vue components

Frontend Technology

The frontend is built with modern Vue.js 3 and related technologies:

Tech Stack

  • Vue.js 3 - Progressive JavaScript framework with Composition API
  • Vue Router - Official router for client-side navigation
  • Vite - Next-generation frontend tooling for fast development
  • Bootstrap 5 - CSS framework for responsive design
  • Axios - Promise-based HTTP client for API communication

Frontend Features

  • Component-based architecture
  • Reactive data binding
  • Client-side routing
  • State management
  • Hot module replacement in development
  • Optimized production builds

Frontend Setup

For detailed frontend setup instructions, see docs/VUE_FRONTEND_SETUP.md.

Quick frontend commands:

cd frontend
# Install dependencies
npm install
# Development server with HMR
npm run dev
# Production build
npm run build
# Preview production build
npm run preview

Contributing

We welcome contributions to the WikiContest platform!

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Test thoroughly
    • Test both backend and frontend
    • Ensure all tests pass
  5. Submit a pull request
    • Describe your changes clearly
    • Reference any related issues

Development Guidelines

  • Follow Python PEP 8 for backend code
  • Follow Vue.js style guide for frontend code
  • Write meaningful commit messages
  • Add docstrings to Python functions
  • Comment complex logic
  • Keep functions focused and under 50 lines when possible

Additional Resources

License

This project is part of the WikiContest platform.

WikiContest Platform - Empowering collaborative Wikipedia article competitions!

About

A Wikipedia Contest Tool

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

WikiContest Platform

A comprehensive web platform for hosting and managing collaborative Wikipedia article competitions. Built with Flask (Python) backend and Vue.js 3 frontend.

Table of Contents

Overview

What This App Does

  • User Authentication - Register, login, and manage user accounts with support for email/password and OAuth
  • Contest Management - Create contests, set dates, define rules, and assign jury members
  • Article Submissions - Submit Wikipedia articles to contests and track their progress
  • Dashboard & Analytics - View user statistics, contest overview, and leaderboards
  • Responsive Design - Optimized for desktop and mobile devices
  • Real-time Updates - Dynamic content loading and notifications

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL 8.0 or higher (or use SQLite for quick testing)
  • Node.js 16+ (for frontend development)

Quick Start

Follow these steps to get the WikiContest platform running locally:

1. Clone the Repository

git clone <repository-url>cd wikicontest/backend

2. Create Virtual Environment

python -m venv venv
# On macOS/Linuxsource venv/bin/activate
# On Windows
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Setup MySQL Database

Option A: MySQL (Recommended for Production)

# Connect to MySQL
mysql -u root -p
# Create database
CREATE DATABASE wikicontest;

Option B: SQLite (Quick Testing)

Skip MySQL setup and use SQLite by editing .env (step 5) to use:

DATABASE_URL=sqlite:///wikicontest.db

5. Configure Environment

# Copy example environment file
cp .env.example .env
# Edit .env and update your configuration# At minimum, update DATABASE_URL with your MySQL credentials

Example .env configuration:

DATABASE_URL=mysql+pymysql://root:password@localhost/wikicontestSECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-here

6. Initialize Database

The application uses Alembic for database migrations. Run migrations to create the database schema:

# Apply all migrations
alembic upgrade head
# Alternative: Use helper script
python scripts/migrate.py upgrade head

Important: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.

7. Run the Application

You have two options for running the application:

Option A: Development Mode (Recommended)

Run both Flask and Vue.js dev servers in separate terminals for the best development experience:

Terminal 1 - Flask Backend:

python main.py

Terminal 2 - Vue.js Frontend:

cd ../frontend
npm install # Only needed first time
npm run dev

Access at:http://localhost:5173 (Vue.js dev server proxies API requests to Flask)

Option B: Production Build (Single Server)

Build the Vue.js frontend first, then run Flask to serve both API and built frontend:

# Build frontendcd ../frontend
npm install # Only needed first time
npm run build
# Run Flaskcd ../backend
python main.py

Access at:http://localhost:5000 (Flask serves built Vue.js files)

8. Open in Browser

  • Development Mode:http://localhost:5173
  • Production Build:http://localhost:5000

You should see the WikiContest login page. Register a new account to get started!

Configuration

Environment Variables

The .env.example file contains all available configuration options. Copy it to .env and customize:

# Database ConfigurationDATABASE_URL=mysql+pymysql://username:password@localhost/wikicontest# Security Keys (CHANGE IN PRODUCTION!)SECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-key-here# CORS Configuration (for frontend development)CORS_ORIGINS=http://localhost:5173,http://localhost:5000# OAuth 1.0a (Optional - for Wikimedia login)OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-hereCONSUMER_SECRET=your-consumer-secret-here

Configuration Tips

  • Database: Use MySQL for production, SQLite for quick local testing
  • Security Keys: Generate strong random keys for production environments
  • CORS: Add your frontend URLs to allow cross-origin requests during development
  • OAuth: Optional feature for Wikimedia login (see OAuth Setup)

Running the Application

Development Workflow

For the best development experience:

  1. Run Flask backend in one terminal: python main.py
  2. Run Vue.js dev server in another terminal: cd ../frontend && npm run dev
  3. Access the app at http://localhost:5173

The Vue.js dev server provides:

  • Hot module replacement (instant updates)
  • Automatic API proxying to Flask
  • Better debugging experience

Production Workflow

For production or testing the production build:

  1. Build frontend: cd frontend && npm run build
  2. Run Flask: cd backend && python main.py
  3. Access the app at http://localhost:5000

Flask serves the optimized, built Vue.js files.

🔧 Configuration

The .env.example file contains all configuration options. Copy it to .env and update:

  • Database: MySQL connection string (default)
  • Security Keys: Change in production!
  • CORS: Frontend development URLs
  • OAuth 1.0a: Wikimedia OAuth credentials (optional, for OAuth login)

Important Notes

  • Migrations: Always run alembic upgrade head before starting the app
  • Frontend Development: Use the Vue.js dev server (npm run dev) for the best experience
  • API Access: Backend API is available at http://localhost:5000/api/

OAuth Setup

OAuth 1.0a for Wikimedia Login (Optional)

Enable users to log in using their Wikimedia accounts:

1. Register OAuth Consumer

  1. Go to Wikimedia OAuth Registration
  2. Fill in your application details
  3. Set the callback URL:
    • Development:http://localhost:5000/api/user/oauth/callback
    • Production:https://yourdomain.com/api/user/oauth/callback
  4. Save and note your Consumer Key and Consumer Secret

2. Add Credentials to .env

OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-from-registrationCONSUMER_SECRET=your-consumer-secret-from-registration

3. Test OAuth Login

  1. Start the application
  2. Navigate to the login page
  3. Click "Login with Wikimedia"
  4. Authorize the application on Wikimedia
  5. You'll be redirected back and logged in automatically

Note: OAuth login works alongside regular email/password authentication. Users can choose either method.

Testing

Manual Testing

# Ensure migrations are applied
alembic upgrade head
# Start the application
python main.py
# Open http://localhost:5000 (or http://localhost:5173 in dev mode)

Test the Following Features:

  • User registration and login
  • Contest creation
  • Article submission
  • Dashboard functionality
  • Leaderboard display
  • OAuth login (if configured)

Automated Tests

# Install test dependencies
pip install pytest pytest-flask
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/

Production Deployment

1. Setup Production Environment

Configure production environment variables:

export FLASK_ENV=production
export FLASK_DEBUG=False
export DATABASE_URL=mysql+pymysql://user:pass@prod-host/wikicontest
export SECRET_KEY=strong-random-production-key
export JWT_SECRET_KEY=strong-random-jwt-key

2. Build Frontend

cd frontend
npm install
npm run build

3. Apply Database Migrations

cd backend
alembic upgrade head

4. Run with Production Server

# Install Gunicorn
pip install gunicorn
# Run with 4 worker processes
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"

5. Use Reverse Proxy (Recommended)

Set up Nginx or Apache as a reverse proxy:

Example Nginx configuration:

server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}

Project Structure

wikicontest/
├── backend/ # Flask backend application
│ ├── main.py # Application entry point
│ ├── app/ # Main application package
│ │ ├── __init__.py # Flask app factory
│ │ ├── config.py # Configuration management
│ │ ├── database.py # SQLAlchemy database
│ │ ├── models/ # Database models (User, Contest, Submission)
│ │ ├── routes/ # API endpoints (blueprints)
│ │ ├── middleware/ # Authentication & authorization
│ │ └── utils/ # Utility functions
│ ├── alembic/ # Database migrations (Alembic)
│ │ ├── versions/ # Migration version files
│ │ └── env.py # Alembic environment
│ ├── scripts/ # Utility scripts
│ ├── tests/ # Test files (pytest)
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment configuration
│
└── frontend/ # Vue.js 3 frontend application
├── src/ # Source files
│ ├── views/ # Page components (Home, Login, Dashboard, etc.)
│ ├── components/ # Reusable UI components
│ ├── router/ # Vue Router configuration
│ ├── store/ # State management (if using Vuex/Pinia)
│ ├── services/ # API service layer
│ └── App.vue # Root component
├── public/ # Static assets
├── package.json # Frontend dependencies
├── vite.config.js # Vite build configuration
└── index.html # HTML entry point

Key Directories

  • backend/app/models/ - Database models (User, Contest, Submission)
  • backend/app/routes/ - API endpoints organized by domain
  • backend/alembic/versions/ - Database migration history
  • frontend/src/views/ - Vue page components
  • frontend/src/components/ - Reusable Vue components

Frontend Technology

The frontend is built with modern Vue.js 3 and related technologies:

Tech Stack

  • Vue.js 3 - Progressive JavaScript framework with Composition API
  • Vue Router - Official router for client-side navigation
  • Vite - Next-generation frontend tooling for fast development
  • Bootstrap 5 - CSS framework for responsive design
  • Axios - Promise-based HTTP client for API communication

Frontend Features

  • Component-based architecture
  • Reactive data binding
  • Client-side routing
  • State management
  • Hot module replacement in development
  • Optimized production builds

Frontend Setup

For detailed frontend setup instructions, see docs/VUE_FRONTEND_SETUP.md.

Quick frontend commands:

cd frontend
# Install dependencies
npm install
# Development server with HMR
npm run dev
# Production build
npm run build
# Preview production build
npm run preview

Contributing

We welcome contributions to the WikiContest platform!

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Test thoroughly
    • Test both backend and frontend
    • Ensure all tests pass
  5. Submit a pull request
    • Describe your changes clearly
    • Reference any related issues

Development Guidelines

  • Follow Python PEP 8 for backend code
  • Follow Vue.js style guide for frontend code
  • Write meaningful commit messages
  • Add docstrings to Python functions
  • Comment complex logic
  • Keep functions focused and under 50 lines when possible

Additional Resources

License

This project is part of the WikiContest platform.

WikiContest Platform - Empowering collaborative Wikipedia article competitions!

About

A Wikipedia Contest Tool

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

WikiContest Platform

A comprehensive web platform for hosting and managing collaborative Wikipedia article competitions. Built with Flask (Python) backend and Vue.js 3 frontend.

Table of Contents

Overview

What This App Does

  • User Authentication - Register, login, and manage user accounts with support for email/password and OAuth
  • Contest Management - Create contests, set dates, define rules, and assign jury members
  • Article Submissions - Submit Wikipedia articles to contests and track their progress
  • Dashboard & Analytics - View user statistics, contest overview, and leaderboards
  • Responsive Design - Optimized for desktop and mobile devices
  • Real-time Updates - Dynamic content loading and notifications

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL 8.0 or higher (or use SQLite for quick testing)
  • Node.js 16+ (for frontend development)

Quick Start

Follow these steps to get the WikiContest platform running locally:

1. Clone the Repository

git clone <repository-url>cd wikicontest/backend

2. Create Virtual Environment

python -m venv venv
# On macOS/Linuxsource venv/bin/activate
# On Windows
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Setup MySQL Database

Option A: MySQL (Recommended for Production)

# Connect to MySQL
mysql -u root -p
# Create database
CREATE DATABASE wikicontest;

Option B: SQLite (Quick Testing)

Skip MySQL setup and use SQLite by editing .env (step 5) to use:

DATABASE_URL=sqlite:///wikicontest.db

5. Configure Environment

# Copy example environment file
cp .env.example .env
# Edit .env and update your configuration# At minimum, update DATABASE_URL with your MySQL credentials

Example .env configuration:

DATABASE_URL=mysql+pymysql://root:password@localhost/wikicontestSECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-here

6. Initialize Database

The application uses Alembic for database migrations. Run migrations to create the database schema:

# Apply all migrations
alembic upgrade head
# Alternative: Use helper script
python scripts/migrate.py upgrade head

Important: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.

7. Run the Application

You have two options for running the application:

Option A: Development Mode (Recommended)

Run both Flask and Vue.js dev servers in separate terminals for the best development experience:

Terminal 1 - Flask Backend:

python main.py

Terminal 2 - Vue.js Frontend:

cd ../frontend
npm install # Only needed first time
npm run dev

Access at:http://localhost:5173 (Vue.js dev server proxies API requests to Flask)

Option B: Production Build (Single Server)

Build the Vue.js frontend first, then run Flask to serve both API and built frontend:

# Build frontendcd ../frontend
npm install # Only needed first time
npm run build
# Run Flaskcd ../backend
python main.py

Access at:http://localhost:5000 (Flask serves built Vue.js files)

8. Open in Browser

  • Development Mode:http://localhost:5173
  • Production Build:http://localhost:5000

You should see the WikiContest login page. Register a new account to get started!

Configuration

Environment Variables

The .env.example file contains all available configuration options. Copy it to .env and customize:

# Database ConfigurationDATABASE_URL=mysql+pymysql://username:password@localhost/wikicontest# Security Keys (CHANGE IN PRODUCTION!)SECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-key-here# CORS Configuration (for frontend development)CORS_ORIGINS=http://localhost:5173,http://localhost:5000# OAuth 1.0a (Optional - for Wikimedia login)OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-hereCONSUMER_SECRET=your-consumer-secret-here

Configuration Tips

  • Database: Use MySQL for production, SQLite for quick local testing
  • Security Keys: Generate strong random keys for production environments
  • CORS: Add your frontend URLs to allow cross-origin requests during development
  • OAuth: Optional feature for Wikimedia login (see OAuth Setup)

Running the Application

Development Workflow

For the best development experience:

  1. Run Flask backend in one terminal: python main.py
  2. Run Vue.js dev server in another terminal: cd ../frontend && npm run dev
  3. Access the app at http://localhost:5173

The Vue.js dev server provides:

  • Hot module replacement (instant updates)
  • Automatic API proxying to Flask
  • Better debugging experience

Production Workflow

For production or testing the production build:

  1. Build frontend: cd frontend && npm run build
  2. Run Flask: cd backend && python main.py
  3. Access the app at http://localhost:5000

Flask serves the optimized, built Vue.js files.

🔧 Configuration

The .env.example file contains all configuration options. Copy it to .env and update:

  • Database: MySQL connection string (default)
  • Security Keys: Change in production!
  • CORS: Frontend development URLs
  • OAuth 1.0a: Wikimedia OAuth credentials (optional, for OAuth login)

Important Notes

  • Migrations: Always run alembic upgrade head before starting the app
  • Frontend Development: Use the Vue.js dev server (npm run dev) for the best experience
  • API Access: Backend API is available at http://localhost:5000/api/

OAuth Setup

OAuth 1.0a for Wikimedia Login (Optional)

Enable users to log in using their Wikimedia accounts:

1. Register OAuth Consumer

  1. Go to Wikimedia OAuth Registration
  2. Fill in your application details
  3. Set the callback URL:
    • Development:http://localhost:5000/api/user/oauth/callback
    • Production:https://yourdomain.com/api/user/oauth/callback
  4. Save and note your Consumer Key and Consumer Secret

2. Add Credentials to .env

OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-from-registrationCONSUMER_SECRET=your-consumer-secret-from-registration

3. Test OAuth Login

  1. Start the application
  2. Navigate to the login page
  3. Click "Login with Wikimedia"
  4. Authorize the application on Wikimedia
  5. You'll be redirected back and logged in automatically

Note: OAuth login works alongside regular email/password authentication. Users can choose either method.

Testing

Manual Testing

# Ensure migrations are applied
alembic upgrade head
# Start the application
python main.py
# Open http://localhost:5000 (or http://localhost:5173 in dev mode)

Test the Following Features:

  • User registration and login
  • Contest creation
  • Article submission
  • Dashboard functionality
  • Leaderboard display
  • OAuth login (if configured)

Automated Tests

# Install test dependencies
pip install pytest pytest-flask
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/

Production Deployment

1. Setup Production Environment

Configure production environment variables:

export FLASK_ENV=production
export FLASK_DEBUG=False
export DATABASE_URL=mysql+pymysql://user:pass@prod-host/wikicontest
export SECRET_KEY=strong-random-production-key
export JWT_SECRET_KEY=strong-random-jwt-key

2. Build Frontend

cd frontend
npm install
npm run build

3. Apply Database Migrations

cd backend
alembic upgrade head

4. Run with Production Server

# Install Gunicorn
pip install gunicorn
# Run with 4 worker processes
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"

5. Use Reverse Proxy (Recommended)

Set up Nginx or Apache as a reverse proxy:

Example Nginx configuration:

server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}

Project Structure

wikicontest/
├── backend/ # Flask backend application
│ ├── main.py # Application entry point
│ ├── app/ # Main application package
│ │ ├── __init__.py # Flask app factory
│ │ ├── config.py # Configuration management
│ │ ├── database.py # SQLAlchemy database
│ │ ├── models/ # Database models (User, Contest, Submission)
│ │ ├── routes/ # API endpoints (blueprints)
│ │ ├── middleware/ # Authentication & authorization
│ │ └── utils/ # Utility functions
│ ├── alembic/ # Database migrations (Alembic)
│ │ ├── versions/ # Migration version files
│ │ └── env.py # Alembic environment
│ ├── scripts/ # Utility scripts
│ ├── tests/ # Test files (pytest)
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment configuration
│
└── frontend/ # Vue.js 3 frontend application
├── src/ # Source files
│ ├── views/ # Page components (Home, Login, Dashboard, etc.)
│ ├── components/ # Reusable UI components
│ ├── router/ # Vue Router configuration
│ ├── store/ # State management (if using Vuex/Pinia)
│ ├── services/ # API service layer
│ └── App.vue # Root component
├── public/ # Static assets
├── package.json # Frontend dependencies
├── vite.config.js # Vite build configuration
└── index.html # HTML entry point

Key Directories

  • backend/app/models/ - Database models (User, Contest, Submission)
  • backend/app/routes/ - API endpoints organized by domain
  • backend/alembic/versions/ - Database migration history
  • frontend/src/views/ - Vue page components
  • frontend/src/components/ - Reusable Vue components

Frontend Technology

The frontend is built with modern Vue.js 3 and related technologies:

Tech Stack

  • Vue.js 3 - Progressive JavaScript framework with Composition API
  • Vue Router - Official router for client-side navigation
  • Vite - Next-generation frontend tooling for fast development
  • Bootstrap 5 - CSS framework for responsive design
  • Axios - Promise-based HTTP client for API communication

Frontend Features

  • Component-based architecture
  • Reactive data binding
  • Client-side routing
  • State management
  • Hot module replacement in development
  • Optimized production builds

Frontend Setup

For detailed frontend setup instructions, see docs/VUE_FRONTEND_SETUP.md.

Quick frontend commands:

cd frontend
# Install dependencies
npm install
# Development server with HMR
npm run dev
# Production build
npm run build
# Preview production build
npm run preview

Contributing

We welcome contributions to the WikiContest platform!

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Test thoroughly
    • Test both backend and frontend
    • Ensure all tests pass
  5. Submit a pull request
    • Describe your changes clearly
    • Reference any related issues

Development Guidelines

  • Follow Python PEP 8 for backend code
  • Follow Vue.js style guide for frontend code
  • Write meaningful commit messages
  • Add docstrings to Python functions
  • Comment complex logic
  • Keep functions focused and under 50 lines when possible

Additional Resources

License

This project is part of the WikiContest platform.

WikiContest Platform - Empowering collaborative Wikipedia article competitions!

About

A Wikipedia Contest Tool

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

WikiContest Platform

A comprehensive web platform for hosting and managing collaborative Wikipedia article competitions. Built with Flask (Python) backend and Vue.js 3 frontend.

Table of Contents

Overview

What This App Does

  • User Authentication - Register, login, and manage user accounts with support for email/password and OAuth
  • Contest Management - Create contests, set dates, define rules, and assign jury members
  • Article Submissions - Submit Wikipedia articles to contests and track their progress
  • Dashboard & Analytics - View user statistics, contest overview, and leaderboards
  • Responsive Design - Optimized for desktop and mobile devices
  • Real-time Updates - Dynamic content loading and notifications

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL 8.0 or higher (or use SQLite for quick testing)
  • Node.js 16+ (for frontend development)

Quick Start

Follow these steps to get the WikiContest platform running locally:

1. Clone the Repository

git clone <repository-url>cd wikicontest/backend

2. Create Virtual Environment

python -m venv venv
# On macOS/Linuxsource venv/bin/activate
# On Windows
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Setup MySQL Database

Option A: MySQL (Recommended for Production)

# Connect to MySQL
mysql -u root -p
# Create database
CREATE DATABASE wikicontest;

Option B: SQLite (Quick Testing)

Skip MySQL setup and use SQLite by editing .env (step 5) to use:

DATABASE_URL=sqlite:///wikicontest.db

5. Configure Environment

# Copy example environment file
cp .env.example .env
# Edit .env and update your configuration# At minimum, update DATABASE_URL with your MySQL credentials

Example .env configuration:

DATABASE_URL=mysql+pymysql://root:password@localhost/wikicontestSECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-here

6. Initialize Database

The application uses Alembic for database migrations. Run migrations to create the database schema:

# Apply all migrations
alembic upgrade head
# Alternative: Use helper script
python scripts/migrate.py upgrade head

Important: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.

7. Run the Application

You have two options for running the application:

Option A: Development Mode (Recommended)

Run both Flask and Vue.js dev servers in separate terminals for the best development experience:

Terminal 1 - Flask Backend:

python main.py

Terminal 2 - Vue.js Frontend:

cd ../frontend
npm install # Only needed first time
npm run dev

Access at:http://localhost:5173 (Vue.js dev server proxies API requests to Flask)

Option B: Production Build (Single Server)

Build the Vue.js frontend first, then run Flask to serve both API and built frontend:

# Build frontendcd ../frontend
npm install # Only needed first time
npm run build
# Run Flaskcd ../backend
python main.py

Access at:http://localhost:5000 (Flask serves built Vue.js files)

8. Open in Browser

  • Development Mode:http://localhost:5173
  • Production Build:http://localhost:5000

You should see the WikiContest login page. Register a new account to get started!

Configuration

Environment Variables

The .env.example file contains all available configuration options. Copy it to .env and customize:

# Database ConfigurationDATABASE_URL=mysql+pymysql://username:password@localhost/wikicontest# Security Keys (CHANGE IN PRODUCTION!)SECRET_KEY=your-secret-key-hereJWT_SECRET_KEY=your-jwt-secret-key-here# CORS Configuration (for frontend development)CORS_ORIGINS=http://localhost:5173,http://localhost:5000# OAuth 1.0a (Optional - for Wikimedia login)OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-hereCONSUMER_SECRET=your-consumer-secret-here

Configuration Tips

  • Database: Use MySQL for production, SQLite for quick local testing
  • Security Keys: Generate strong random keys for production environments
  • CORS: Add your frontend URLs to allow cross-origin requests during development
  • OAuth: Optional feature for Wikimedia login (see OAuth Setup)

Running the Application

Development Workflow

For the best development experience:

  1. Run Flask backend in one terminal: python main.py
  2. Run Vue.js dev server in another terminal: cd ../frontend && npm run dev
  3. Access the app at http://localhost:5173

The Vue.js dev server provides:

  • Hot module replacement (instant updates)
  • Automatic API proxying to Flask
  • Better debugging experience

Production Workflow

For production or testing the production build:

  1. Build frontend: cd frontend && npm run build
  2. Run Flask: cd backend && python main.py
  3. Access the app at http://localhost:5000

Flask serves the optimized, built Vue.js files.

🔧 Configuration

The .env.example file contains all configuration options. Copy it to .env and update:

  • Database: MySQL connection string (default)
  • Security Keys: Change in production!
  • CORS: Frontend development URLs
  • OAuth 1.0a: Wikimedia OAuth credentials (optional, for OAuth login)

Important Notes

  • Migrations: Always run alembic upgrade head before starting the app
  • Frontend Development: Use the Vue.js dev server (npm run dev) for the best experience
  • API Access: Backend API is available at http://localhost:5000/api/

OAuth Setup

OAuth 1.0a for Wikimedia Login (Optional)

Enable users to log in using their Wikimedia accounts:

1. Register OAuth Consumer

  1. Go to Wikimedia OAuth Registration
  2. Fill in your application details
  3. Set the callback URL:
    • Development:http://localhost:5000/api/user/oauth/callback
    • Production:https://yourdomain.com/api/user/oauth/callback
  4. Save and note your Consumer Key and Consumer Secret

2. Add Credentials to .env

OAUTH_MWURI=https://meta.wikimedia.org/w/index.phpCONSUMER_KEY=your-consumer-key-from-registrationCONSUMER_SECRET=your-consumer-secret-from-registration

3. Test OAuth Login

  1. Start the application
  2. Navigate to the login page
  3. Click "Login with Wikimedia"
  4. Authorize the application on Wikimedia
  5. You'll be redirected back and logged in automatically

Note: OAuth login works alongside regular email/password authentication. Users can choose either method.

Testing

Manual Testing

# Ensure migrations are applied
alembic upgrade head
# Start the application
python main.py
# Open http://localhost:5000 (or http://localhost:5173 in dev mode)

Test the Following Features:

  • User registration and login
  • Contest creation
  • Article submission
  • Dashboard functionality
  • Leaderboard display
  • OAuth login (if configured)

Automated Tests

# Install test dependencies
pip install pytest pytest-flask
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/

Production Deployment

1. Setup Production Environment

Configure production environment variables:

export FLASK_ENV=production
export FLASK_DEBUG=False
export DATABASE_URL=mysql+pymysql://user:pass@prod-host/wikicontest
export SECRET_KEY=strong-random-production-key
export JWT_SECRET_KEY=strong-random-jwt-key

2. Build Frontend

cd frontend
npm install
npm run build

3. Apply Database Migrations

cd backend
alembic upgrade head

4. Run with Production Server

# Install Gunicorn
pip install gunicorn
# Run with 4 worker processes
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"

5. Use Reverse Proxy (Recommended)

Set up Nginx or Apache as a reverse proxy:

Example Nginx configuration:

server{listen80;server_name yourdomain.com;location / {proxy_passhttp://127.0.0.1:5000;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}

Project Structure

wikicontest/
├── backend/ # Flask backend application
│ ├── main.py # Application entry point
│ ├── app/ # Main application package
│ │ ├── __init__.py # Flask app factory
│ │ ├── config.py # Configuration management
│ │ ├── database.py # SQLAlchemy database
│ │ ├── models/ # Database models (User, Contest, Submission)
│ │ ├── routes/ # API endpoints (blueprints)
│ │ ├── middleware/ # Authentication & authorization
│ │ └── utils/ # Utility functions
│ ├── alembic/ # Database migrations (Alembic)
│ │ ├── versions/ # Migration version files
│ │ └── env.py # Alembic environment
│ ├── scripts/ # Utility scripts
│ ├── tests/ # Test files (pytest)
│ ├── requirements.txt # Python dependencies
│ └── .env # Environment configuration
│
└── frontend/ # Vue.js 3 frontend application
├── src/ # Source files
│ ├── views/ # Page components (Home, Login, Dashboard, etc.)
│ ├── components/ # Reusable UI components
│ ├── router/ # Vue Router configuration
│ ├── store/ # State management (if using Vuex/Pinia)
│ ├── services/ # API service layer
│ └── App.vue # Root component
├── public/ # Static assets
├── package.json # Frontend dependencies
├── vite.config.js # Vite build configuration
└── index.html # HTML entry point

Key Directories

  • backend/app/models/ - Database models (User, Contest, Submission)
  • backend/app/routes/ - API endpoints organized by domain
  • backend/alembic/versions/ - Database migration history
  • frontend/src/views/ - Vue page components
  • frontend/src/components/ - Reusable Vue components

Frontend Technology

The frontend is built with modern Vue.js 3 and related technologies:

Tech Stack

  • Vue.js 3 - Progressive JavaScript framework with Composition API
  • Vue Router - Official router for client-side navigation
  • Vite - Next-generation frontend tooling for fast development
  • Bootstrap 5 - CSS framework for responsive design
  • Axios - Promise-based HTTP client for API communication

Frontend Features

  • Component-based architecture
  • Reactive data binding
  • Client-side routing
  • State management
  • Hot module replacement in development
  • Optimized production builds

Frontend Setup

For detailed frontend setup instructions, see docs/VUE_FRONTEND_SETUP.md.

Quick frontend commands:

cd frontend
# Install dependencies
npm install
# Development server with HMR
npm run dev
# Production build
npm run build
# Preview production build
npm run preview

Contributing

We welcome contributions to the WikiContest platform!

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow existing code style
    • Add tests for new features
    • Update documentation as needed
  4. Test thoroughly
    • Test both backend and frontend
    • Ensure all tests pass
  5. Submit a pull request
    • Describe your changes clearly
    • Reference any related issues

Development Guidelines

  • Follow Python PEP 8 for backend code
  • Follow Vue.js style guide for frontend code
  • Write meaningful commit messages
  • Add docstrings to Python functions
  • Comment complex logic
  • Keep functions focused and under 50 lines when possible

Additional Resources

License

This project is part of the WikiContest platform.

WikiContest Platform - Empowering collaborative Wikipedia article competitions!

About

A Wikipedia Contest Tool

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages