Development & contributing

Introduction#

Local setup, tests, style, debugging, and how to add a channel or data source without inventing a parallel stack. CI expectations and the extension points that already exist.

Project structure#

The project is organized as a modular Python application under the app/ directory:

  • Core configuration and daemon utilities
  • Service layer for business logic
  • Servers for Telegram bot, webhook, and update orchestration
  • Data models and schemas
  • Tests and logs
  • Development and deployment assets

Core components#

  • CLI entry point orchestrating commands for bot, scheduler, webhook, update, send, official, and daemon control
  • Centralized configuration with Pydantic settings and logging setup
  • Daemon utilities for Unix-style background processes
  • Service layer for database operations, Telegram notifications, and integrations
  • Notification runner coordinating dispatch across channels
  • Telegram bot server handling commands and user interactions

Responsibilities and integration points are defined in the CLI and service wiring.

Architecture overview#

The system follows a dependency-injected, modular architecture:

  • Data sources (SuperSet portal, emails, official website) feed structured data into MongoDB
  • Services encapsulate business logic and integrate with external APIs
  • Notification channels (Telegram, Web Push) consume unsent notices from storage
  • CLI and servers orchestrate execution and expose admin interfaces

Detailed component analysis#

CLI and command orchestration#

The CLI defines subcommands for bot, scheduler, webhook, update, send, official, and daemon control. It sets up logging, supports daemon mode, and wires services for orchestrated execution.

Configuration and logging#

Centralized settings management with Pydantic, environment loading, and configurable logging levels and destinations. Includes daemon-aware printing and PID file management.

Daemon utilities#

Unix-style daemonization with PID file management, graceful stop, and status reporting. Background processes detach and redirect output.

Database service#

Encapsulates MongoDB operations for notices, jobs, placement offers, users, and policies. Provides helpers for existence checks, retrieval, and statistics.

Telegram service#

Implements Telegram notifications with message chunking, formatting, and broadcasting capabilities. Integrates with a Telegram client wrapper.

Notification runner#

Coordinates sending unsent notices across channels using dependency injection. Supports Telegram and Web Push, with optional NotificationService composition.

Telegram bot server#

Long-polling Telegram bot with command handlers for user registration, help, status, stats, and administrative commands. Integrates with services for DB, notifications, and stats.

Dependency analysis#

  • Project metadata and dependencies are defined in pyproject.toml and requirements.txt
  • Development uses uv for dependency management and reproducible environments
  • Docker Compose spins up a local MongoDB instance for development

Performance considerations#

  • Use daemon mode for background processes to reduce overhead and improve reliability
  • Chunk long Telegram messages to avoid rate limits and failures
  • Minimize database round-trips by batching operations and using aggregation where possible
  • Use caching for settings and enable logging levels appropriate to environment
  • Profile CPU and memory usage during heavy update cycles using built-in profiling tools

[No sources needed since this section provides general guidance]

Troubleshooting guide#

Common issues and remedies:

  • Verify environment variables and MongoDB connectivity before running
  • Check daemon status and logs for background processes
  • Use verbose CLI mode for detailed logs
  • Inspect scheduler job registrations and intervals
  • Validate Telegram bot token and chat ID configuration

Contribution workflow#

  • Fork and branch: feature/your-feature-name or fix/issue-description
  • Develop with pytest for unit tests and flake8 for style checks
  • Commit with conventional messages (feat:, fix:, refactor:, docs:, test:)
  • Create Pull Request with checklist items addressed
  • Address reviewer feedback and ensure tests pass

Extensibility & integration guide#

  • Adding a new notification channel:
  • Implement a channel-specific service following the INotificationChannel pattern
  • Integrate via NotificationRunner and CLI flags
  • Add tests and update documentation
  • Adding a new data source:
  • Create a client/service pair similar to SupersetClientService or PlacementService
  • Wire into update orchestration in main.py
  • Ensure idempotent persistence and event generation for notifications
  • Integrating additional LLM pipelines:
  • Extend LangGraph workflows in dedicated services
  • Maintain separation of concerns and inject dependencies

Continuous integration and release management#

  • GitHub Actions under .github/workflows/ are disabled (.legacy). Live scraping is python main.py scheduler, not CI.
  • Python 3.12+ (requires-python in app/pyproject.toml)
  • Secrets for Telegram, MongoDB, SuperSet, and email live in .env
  • uv sync from app/ is the install path; uv.lock is the lockfile

Development & testing guide#

  • Local setup with uv sync and Docker Compose for MongoDB
  • Run pytest for unit tests and coverage
  • Use mocks for external services in tests
  • Follow AGENTS.md style rules

Debugging and profiling#

  • Use safe_print for daemon-friendly output
  • Enable verbose logging via CLI flags
  • Employ pdb or IDE debuggers for interactive inspection
  • Profile code using cProfile for hotspots

Code standards and style#

  • Python 3.12+ with type hints and docstrings
  • Organized imports, consistent naming, and class structure
  • Logging at appropriate levels and error handling patterns
  • Configuration via Pydantic settings with validation

Conclusion#

Clone https://github.com/tashifkhan/JIIT-placement-alerts, cd app, uv sync, copy .env.example. Tests are pytest under app/tests/. The scheduler cron is in app/servers/scheduler_server.py.