Notification App

Notification App

Build Status Docker Image GitHub Pages Python Version License Code style: black

A real-time web application for monitoring blog posts with intelligent notifications, Azure AD authentication, and web push support.

Description

This Flask-based application automatically monitors blog content and delivers personalized notifications to users. It features Microsoft Azure AD single sign-on authentication, customizable notification filters, and web push notifications for real-time updates.

Key Features

Installation Instructions

Prerequisites

Local Development Setup

  1. Clone the repository

    git clone https://github.com/vakesz/notification_app.git
    cd notification_app
  2. Create a virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -e .
  4. Environment Configuration

    Create a .env file in the project root:

    # Flask Configuration
    SECRET_KEY=your-secret-key-here
    FLASK_ENV=development
    
    # Azure AD Configuration
    AAD_CLIENT_ID=your-azure-ad-client-id
    AAD_CLIENT_SECRET=your-azure-ad-client-secret
    AAD_TENANT_ID=your-azure-ad-tenant-id
    AAD_REDIRECT_URI=http://localhost:5000/auth/callback
    
    # Blog API Configuration
    BLOG_API_URL=https://your-blog-api-url.com
    BLOG_API_AUTH_METHOD=none
    
    # Optional Blog API Authentication (choose one if needed)
    # For OAuth2:
    # BLOG_API_OAUTH2_CLIENT_ID=your-oauth2-client-id
    # BLOG_API_OAUTH2_CLIENT_SECRET=your-oauth2-client-secret
    # BLOG_API_OAUTH2_TOKEN_URL=https://your-oauth2-token-url.com
    
    # For MSAL:
    # BLOG_API_MSAL_CLIENT_ID=your-msal-client-id
    # BLOG_API_MSAL_CLIENT_SECRET=your-msal-client-secret
    # BLOG_API_MSAL_TENANT_ID=your-msal-tenant-id
    # BLOG_API_MSAL_SCOPE=your-msal-scope
    
    # For NTLM:
    # BLOG_API_NTLM_USER=your-ntlm-user
    # BLOG_API_NTLM_PASSWORD=your-ntlm-password
    # BLOG_API_NTLM_DOMAIN=your-ntlm-domain
    
    # Web Push Configuration
    PUSH_VAPID_PUBLIC_KEY=your-vapid-public-key
    PUSH_VAPID_PRIVATE_KEY=your-vapid-private-key
    PUSH_CONTACT_EMAIL=your-contact-email@example.com
    
    # Application Settings
    APP_NAME=Blog Notifications Parser
    APP_DATABASE_PATH=db/posts.db
    POLLING_INTERVAL_MIN=15
    HTTP_TIMEOUT=30
    
    # Optional Advanced Settings
    # HTTP_MAX_RETRIES=3
    # HTTP_RETRY_BACKOFF=1
    # POLLING_BACKOFF_FACTOR=1.5
    # POLLING_MAX_BACKOFF=3600
    # AUTH_TOKEN_TTL_DAYS=30
    # PUSH_TTL=86400
  5. Database Setup

    mkdir -p db
    # Database will be automatically initialized on first run

Docker Deployment

Run with Docker

# Pull the latest image
docker pull ghcr.io/vakesz/notification_app:latest

# Run with environment variables
docker run -d \
  --name notification-app \
  -p 5000:5000 \
  -e SECRET_KEY=your-secret-key \
  -e AAD_CLIENT_ID=your-azure-ad-client-id \
  -e AAD_CLIENT_SECRET=your-azure-ad-client-secret \
  -e AAD_TENANT_ID=your-azure-ad-tenant-id \
  -e BLOG_API_URL=https://your-blog-api-url.com \
  -e PUSH_VAPID_PUBLIC_KEY=your-vapid-public-key \
  -e PUSH_VAPID_PRIVATE_KEY=your-vapid-private-key \
  -e PUSH_CONTACT_EMAIL=your-contact-email@example.com \
  -v notification-db:/app/db \
  ghcr.io/vakesz/notification_app:latest

Run with Docker Compose

version: '3.8'
services:
  app:
    image: ghcr.io/vakesz/notification_app:latest
    ports:
      - "5000:5000"
    environment:
      - SECRET_KEY=your-secret-key
      - AAD_CLIENT_ID=your-client-id
      - AAD_CLIENT_SECRET=your-azure-ad-client-secret
      - AAD_TENANT_ID=your-tenant-id
      - AAD_REDIRECT_URI=http://localhost:5000/auth/callback
      - BLOG_API_URL=https://your-blog-api-url.com
      - PUSH_VAPID_PUBLIC_KEY=your-vapid-public-key
      - PUSH_VAPID_PRIVATE_KEY=your-vapid-private-key
      - PUSH_CONTACT_EMAIL=your-contact-email@example.com
    volumes:
      - notification-db:/app/db
volumes:
  notification-db:

Note: The Docker image uses multi-architecture support (amd64/arm64) and runs with gunicorn -w 4 -b 0.0.0.0:5000 "app.web.main:create_app()" to properly initialize the Flask application factory.

Usage Instructions

Starting the Application

Development Mode:

export FLASK_APP=app.web.main
export FLASK_ENV=development
flask run

Production Mode:

gunicorn -w 4 -b 0.0.0.0:5000 "app.web.main:create_app()"

Accessing the Application

  1. Navigate to http://localhost:5000
  2. Click “Login with Microsoft” to authenticate
  3. Configure your notification preferences in the dashboard
  4. Enable push notifications when prompted by your browser

API Endpoints

The application provides several API endpoints:

Configuration Options

Notification Settings:

Users can customize their notification preferences through the dashboard:

Blog API Authentication:

The application supports multiple authentication methods:

Architecture Overview

├── app/
│   ├── api/routes/          # Flask blueprints and routes
│   ├── core/               # Core configuration and security
│   ├── db/                 # Database models and management
│   ├── services/           # Business logic services
│   ├── utils/              # Utility functions
│   └── web/                # Web application entry point
├── static/                 # Frontend assets
├── templates/              # Jinja2 templates
└── db/                     # SQLite database files

Key Components

Development

Development Dependencies

The project includes comprehensive development tools configured in pyproject.toml:

All development dependencies are automatically installed with:

pip install -e .[dev]

Running Tests and Quality Checks

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Run with coverage
pytest --cov=app --maxfail=1 --disable-warnings -q

Code Quality

The project uses automated code quality tools that are also run in CI:

# Format code
black app/

# Check formatting
black --check .

# Sort imports
isort app/

# Check import sorting
isort --check-only .

# Lint code
flake8 app

Continuous Integration

This project uses GitHub Actions for automated testing and code quality checks. The CI pipeline:

The CI workflow runs on every push to main and on pull requests, ensuring code quality and compatibility across Python versions.

🤝 Contribution Guidelines

Contributions are welcome. Open an issue or create a pull request.

Getting Started

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature-name
  3. Make your changes following the coding standards below
  4. Write tests for new functionality
  5. Submit a pull request with a clear description

Coding Standards

Reporting Issues

License Information

This project is licensed under the MIT License.

Third-Party Dependencies

This project uses several open-source libraries:

See pyproject.toml for a complete list of dependencies.

Support

Built with ❤️ for efficient company communication.