Official placement data collection

Introduction#

OfficialPlacementData stores placement snapshots over time. Use it for trends, period comparisons, and reports that need the official numbers rather than whatever landed in email.

Project structure#

The OfficialPlacementData collection is part of the MongoDB database schema for the SuperSet Telegram Notification Bot system. It integrates with the broader data pipeline that includes notices, jobs, placement offers, and user management collections.

Core components#

The OfficialPlacementData collection schema consists of several key components that work together to provide detailed placement statistics:

Unique identifiers and timestamp tracking#

  • data_id: Unique identifier for each snapshot, for dedupe and versioning
  • timestamp: ISODate field for precise temporal tracking of snapshots
  • content_hash: SHA-256 hash of content (excluding volatile fields) for automatic change detection

Overall statistics#

Embedded document containing detailed placement metrics:

  • total_students: Total student population
  • total_placed: Number of students placed
  • placement_percentage: Calculated placement rate
  • average_package: Mean package across all placed students
  • highest_package: Maximum package offered
  • lowest_package: Minimum package offered

Branch-Wise statistics#

Dynamic embedded object structure allowing branch-specific statistics:

  • Branch keys: CSE, ECE, IT, BT, Intg. MTech
  • Each branch contains: total, placed, percentage, average_package
  • Supports flexible branch additions without schema changes

Company-Wise statistics#

Array of embedded documents for company-level breakdown:

  • company: Company name
  • students_placed: Count of students placed
  • average_package: Mean package per company
  • roles: Array of distinct roles offered

Sector-Wise statistics#

Dynamic embedded object for industry sector breakdown:

  • Sector keys: IT, Finance, Consulting, etc.
  • Values: Count of placements per sector
  • Enables industry trend analysis

Metadata and source tracking#

  • source_url: URL of the official source
  • created_at: Document creation timestamp
  • updated_at: Last modification timestamp

Architecture overview#

The OfficialPlacementData collection sits in the pipeline that turns scraped placement pages into stats you can chart:

Detailed component analysis#

Data model structure#

The OfficialPlacementData schema employs a flexible, denormalized design optimized for read-heavy analytics workloads:

Snapshot management and versioning#

Snapshots use content hashing:

Statistical aggregation pipeline#

The system supports detailed statistical analysis through multiple aggregation layers:

Dependency analysis#

The OfficialPlacementData collection has well-defined dependencies within the system architecture:

Data flow dependencies#

The collection participates in several data flow patterns:

  1. Scraping Pipeline: OfficialPlacementService → DatabaseService → OfficialPlacementData
  2. Analytics Pipeline: PlacementStatsCalculatorService → Query → OfficialPlacementData
  3. Notification Pipeline: DatabaseService → Real-time Updates → External Systems

Performance considerations#

The OfficialPlacementData collection is optimized for analytical workloads with several performance-improving features:

Indexing strategy#

  • Unique Index: { data_id: 1 } for fast snapshot lookup and deduplication
  • Time-based Index: { timestamp: -1 } for efficient chronological queries
  • Composite Indexes: Support for common query patterns in analytics

Storage optimization#

  • Flexible Schema: Dynamic embedded objects reduce need for joins
  • Content Hashing: Prevents duplicate snapshots and reduces storage overhead
  • Denormalized Design: Optimizes read performance for analytical queries

Query performance#

  • Projection Support: Efficient field selection for partial document retrieval
  • Aggregation Pipeline: Built-in support for complex statistical calculations
  • Caching Strategy: TTL-based caching for frequently accessed snapshots

Troubleshooting guide#

Common issues and solutions#

Snapshot duplication prevention#

Problem: Duplicate snapshots being inserted Solution: Verify content_hash calculation excludes volatile fields Detection: Compare content_hash values across snapshots

Index performance issues#

Problem: Slow queries on timestamp-based filters Solution: Ensure { timestamp: -1 } index exists and is properly maintained Monitoring: Use explain() to analyze query plans

Memory usage concerns#

Problem: High memory consumption during statistical calculations Solution: Implement pagination for large dataset queries Optimization: Use projection to limit returned fields

Data integrity validation#

Problem: Inconsistent statistical calculations Solution: Validate branch resolution logic and enrollment number parsing Verification: Cross-check calculations against raw data sources

Conclusion#

OfficialPlacementData is the snapshot store for official stats. Hash to skip unchanged pages, aggregate for trends, keep the raw-ish payload when the official format drifts.

Appendices#

Example documents#

Basic snapshot structure#

javascript
{
 _id: ObjectId("..."),
 data_id: "official_2025_01_20",
 timestamp: ISODate("2025-01-20T00:00:00Z"),
 overall_statistics: {
 total_students: 500,
 total_placed: 450,
 placement_percentage: 90,
 average_package: 15.5,
 highest_package: 45.0,
 lowest_package: 8.0
 },
 branch_wise: {
 "CSE": {
 total: 200,
 placed: 190,
 percentage: 95,
 average_package: 18.0
 }
 },
 company_wise: [
 {
 company: "Google",
 students_placed: 45,
 average_package: 24.0,
 roles: ["Software Engineer", "Data Engineer"]
 }
 ],
 sector_wise: {
 "IT": 150,
 "Finance": 120
 },
 source_url: "https://jiit.ac.in/placement",
 created_at: ISODate("2025-01-20T06:30:00Z"),
 updated_at: ISODate("2025-01-20T06:30:00Z")
}

Query patterns#

Latest snapshot retrieval#

javascript
db.OfficialPlacementData.findOne(
 { timestamp: { $gt: new Date(Date.now() - 24*60*60*1000) } },
 { "branch_wise": 1 }
)

Historical trend analysis#

javascript
db.OfficialPlacementData.find().sort({ timestamp: 1 })

Branch-wise comparison#

javascript
db.OfficialPlacementData.aggregate([
 { $unwind: "$branch_wise" },
 { $group: { _id: "$branch_wise.branch", avg_package: { $avg: "$branch_wise.average_package" } } }
])