// Knowledge Vault of Indian Environmental Laws, Policies, and IS Codes // Comprehensive offline reference system for environmental compliance interface LegalDocument { id: string; title: string; type: 'act' | 'rule' | 'policy' | 'standard' | 'guideline' | 'notification'; authority: string; year: number; status: 'active' | 'amended' | 'superseded'; summary: string; keyProvisions: string[]; applicableTo: string[]; penalties: string[]; references: string[]; lastUpdated: Date; } interface ISCode { code: string; title: string; category: string; year: number; status: 'current' | 'revised' | 'withdrawn'; scope: string; keyRequirements: string[]; testMethods: string[]; applicableIndustries: string[]; relatedCodes: string[]; } interface ComplianceCheck { parameter: string; value: number; unit: string; applicable: LegalDocument[]; compliance: 'compliant' | 'non_compliant' | 'marginal'; recommendations: string[]; nextReview: Date; } class KnowledgeVault { private legalDocuments: Map = new Map(); private isCodes: Map = new Map(); private searchIndex: Map = new Map(); constructor() { this.initializeLegalDatabase(); this.initializeISCodes(); this.buildSearchIndex(); } // Search for legal documents searchLegalDocuments(query: string, filters?: { type?: LegalDocument['type']; authority?: string; year?: number; }): LegalDocument[] { try { if (!query || query.trim().length === 0) { return this.getAllDocuments(filters); } const searchTerms = query.toLowerCase().split(' ').filter(term => term.length > 2); const results = new Set(); // Search in index searchTerms.forEach(term => { const matches = this.searchIndex.get(term) || []; matches.forEach(docId => results.add(docId)); }); let documents = Array.from(results) .map(id => this.legalDocuments.get(id)) .filter((doc): doc is LegalDocument => doc !== undefined); // Apply filters if (filters) { documents = documents.filter(doc => { if (filters.type && doc.type !== filters.type) return false; if (filters.authority && !doc.authority.toLowerCase().includes(filters.authority.toLowerCase())) return false; if (filters.year && doc.year !== filters.year) return false; return true; }); } return documents.sort((a, b) => b.year - a.year); } catch (error) { throw new Error(`Failed to search legal documents: ${error instanceof Error ? error.message : 'Unknown error'}`); } } // Search IS Codes searchISCodes(query: string, category?: string): ISCode[] { try { if (!query || query.trim().length === 0) { const allCodes = Array.from(this.isCodes.values()); return category ? allCodes.filter(code => code.category.toLowerCase().includes(category.toLowerCase())) : allCodes; } const searchTerm = query.toLowerCase(); return Array.from(this.isCodes.values()).filter(code => code.code.toLowerCase().includes(searchTerm) || code.title.toLowerCase().includes(searchTerm) || code.scope.toLowerCase().includes(searchTerm) || (category && code.category.toLowerCase().includes(category.toLowerCase())) ).sort((a, b) => b.year - a.year); } catch (error) { throw new Error(`Failed to search IS codes: ${error instanceof Error ? error.message : 'Unknown error'}`); } } // Check compliance for specific parameters checkCompliance(parameter: string, value: number, unit: string, context?: { industryType?: string; location?: string; dischargeTo?: string; }): ComplianceCheck { try { if (typeof value !== 'number' || isNaN(value)) { throw new Error('Invalid parameter value'); } const applicableDocs = this.getApplicableRegulations(parameter, context); const limits = this.extractLimits(parameter, applicableDocs); let compliance: ComplianceCheck['compliance'] = 'compliant'; const recommendations: string[] = []; // Check against limits for (const limit of limits) { if (value > limit.maxValue) { compliance = 'non_compliant'; recommendations.push(`Exceeds ${limit.standard} limit of ${limit.maxValue} ${unit}`); } else if (value > limit.maxValue * 0.8) { compliance = 'marginal'; recommendations.push(`Approaching ${limit.standard} limit - monitor closely`); } } if (compliance === 'compliant') { recommendations.push('Parameter within acceptable limits'); } const nextReview = new Date(); nextReview.setMonth(nextReview.getMonth() + 6); // 6 months from now return { parameter, value, unit, applicable: applicableDocs, compliance, recommendations, nextReview }; } catch (error) { throw new Error(`Failed to check compliance: ${error instanceof Error ? error.message : 'Unknown error'}`); } } // Get applicable regulations for parameter getApplicableRegulations(parameter: string, context?: any): LegalDocument[] { const parameterKey = parameter.toLowerCase(); const regulations: LegalDocument[] = []; this.legalDocuments.forEach(doc => { const isApplicable = doc.keyProvisions.some(provision => provision.toLowerCase().includes(parameterKey) || provision.toLowerCase().includes('water') || provision.toLowerCase().includes('air') || provision.toLowerCase().includes('emission') ); if (isApplicable) { regulations.push(doc); } }); return regulations; } // Get environmental clearance requirements getEnvironmentalClearanceInfo(projectType: string, projectCapacity?: number): { category: 'A' | 'B1' | 'B2' | 'exempted'; authority: string; requirements: string[]; timeline: string; fees: string; validity: string; } { try { const projectTypeLower = projectType.toLowerCase(); // Simplified categorization based on EIA Notification 2006 let category: 'A' | 'B1' | 'B2' | 'exempted'; let authority: string; let requirements: string[]; let timeline: string; let fees: string; if (projectTypeLower.includes('thermal power') && (projectCapacity || 0) >= 500) { category = 'A'; authority = 'MoEF&CC, New Delhi'; timeline = '210 days'; fees = '₹5-50 lakhs'; } else if (projectTypeLower.includes('cement') && (projectCapacity || 0) >= 1.0) { category = 'A'; authority = 'MoEF&CC, New Delhi'; timeline = '210 days'; fees = '₹10-25 lakhs'; } else if (projectTypeLower.includes('steel') || projectTypeLower.includes('iron')) { category = (projectCapacity || 0) >= 5.0 ? 'A' : 'B1'; authority = category === 'A' ? 'MoEF&CC, New Delhi' : 'State Environment Impact Assessment Authority'; timeline = category === 'A' ? '210 days' : '105 days'; fees = category === 'A' ? '₹15-40 lakhs' : '₹2-10 lakhs'; } else { category = 'B2'; authority = 'State Environment Impact Assessment Authority'; timeline = '105 days'; fees = '₹50,000-5 lakhs'; } requirements = this.getECRequirements(category); return { category, authority, requirements, timeline, fees, validity: '30 years (renewable)' }; } catch (error) { throw new Error(`Failed to get EC information: ${error instanceof Error ? error.message : 'Unknown error'}`); } } // Get consent to operate requirements getConsentRequirements(industryType: string, pollutionCategory: 'red' | 'orange' | 'green' | 'white'): { authority: string; validity: string; requirements: string[]; fees: string; monitoring: string[]; } { try { const requirements = [ 'Valid Environmental Clearance (if applicable)', 'Consent to Establish', 'Pollution control equipment installation certificates', 'Effluent/emission monitoring reports', 'Waste management plan', 'Emergency response plan' ]; const monitoring = [ 'Monthly stack emission monitoring', 'Daily effluent monitoring', 'Quarterly ambient air quality monitoring', 'Annual environmental audit' ]; let validity: string; let fees: string; switch (pollutionCategory) { case 'red': validity = '5 years'; fees = '₹25,000-10 lakhs'; monitoring.push('Continuous emission monitoring system (CEMS)'); break; case 'orange': validity = '5 years'; fees = '₹10,000-5 lakhs'; break; case 'green': validity = '5 years'; fees = '₹5,000-1 lakh'; break; default: validity = '5 years'; fees = '₹2,500-25,000'; } return { authority: 'State Pollution Control Board', validity, requirements, fees, monitoring }; } catch (error) { throw new Error(`Failed to get consent requirements: ${error instanceof Error ? error.message : 'Unknown error'}`); } } // Export knowledge base exportKnowledgeBase(): string { try { const exportData = { legalDocuments: Array.from(this.legalDocuments.values()), isCodes: Array.from(this.isCodes.values()), exportDate: new Date().toISOString(), version: '1.0' }; return JSON.stringify(exportData, null, 2); } catch (error) { throw new Error(`Failed to export knowledge base: ${error instanceof Error ? error.message : 'Unknown error'}`); } } // Private initialization methods private initializeLegalDatabase(): void { // Water-related regulations this.addLegalDocument({ id: 'water_act_1974', title: 'Water (Prevention and Control of Pollution) Act, 1974', type: 'act', authority: 'Parliament of India', year: 1974, status: 'active', summary: 'Provides for the prevention and control of water pollution and maintaining or restoring of wholesomeness of water.', keyProvisions: [ 'Prohibition of discharge of pollutants into water bodies without consent', 'Establishment of Central and State Pollution Control Boards', 'Power to take samples and analyze water', 'Penalties for violation of provisions' ], applicableTo: ['Industries', 'Municipalities', 'Commercial establishments'], penalties: ['Imprisonment up to 6 years', 'Fine up to ₹1 lakh', 'Daily fine of ₹5,000'], references: ['Water Act 1974', 'Water Rules 1975'] }); this.addLegalDocument({ id: 'air_act_1981', title: 'Air (Prevention and Control of Pollution) Act, 1981', type: 'act', authority: 'Parliament of India', year: 1981, status: 'active', summary: 'Provides for the prevention, control and abatement of air pollution.', keyProvisions: [ 'Prohibition of air polluting industries in air pollution control areas', 'Consent required for establishment and operation', 'Power to give directions for closure of industries', 'Standards for emission of air pollutants' ], applicableTo: ['Industries', 'Vehicles', 'Commercial establishments'], penalties: ['Imprisonment up to 6 years', 'Fine up to ₹1 lakh', 'Daily fine of ₹5,000'], references: ['Air Act 1981', 'Air Rules 1982'] }); this.addLegalDocument({ id: 'environment_protection_act_1986', title: 'Environment (Protection) Act, 1986', type: 'act', authority: 'Parliament of India', year: 1986, status: 'active', summary: 'Umbrella legislation providing for protection and improvement of environment.', keyProvisions: [ 'General powers to Central Government for environmental protection', 'Appointment of officers and authorities', 'Power to direct closure of industries', 'Environmental standards and guidelines' ], applicableTo: ['All activities affecting environment'], penalties: ['Imprisonment up to 5 years', 'Fine up to ₹1 lakh', 'Daily fine'], references: ['EPA 1986', 'Environment Rules 1986'] }); this.addLegalDocument({ id: 'eia_notification_2006', title: 'Environmental Impact Assessment Notification, 2006', type: 'notification', authority: 'Ministry of Environment, Forest and Climate Change', year: 2006, status: 'amended', summary: 'Mandates prior environmental clearance for specified activities.', keyProvisions: [ 'Categorization of projects (Category A and B)', 'Screening and scoping procedures', 'Public consultation requirements', 'Monitoring and compliance procedures' ], applicableTo: ['Mining', 'Thermal power', 'Industrial projects', 'Infrastructure'], penalties: ['Project closure', 'Penalty up to ₹1 crore', 'Legal action'], references: ['EIA Notification 2006', 'EIA Amendment 2020'] }); this.addLegalDocument({ id: 'swm_rules_2016', title: 'Solid Waste Management Rules, 2016', type: 'rule', authority: 'Ministry of Environment, Forest and Climate Change', year: 2016, status: 'active', summary: 'Comprehensive rules for management of solid waste.', keyProvisions: [ 'Waste segregation at source', 'Extended producer responsibility', 'Processing and treatment of waste', 'Waste to energy recovery' ], applicableTo: ['Urban local bodies', 'Waste generators', 'Bulk generators'], penalties: ['Fine as per local bye-laws', 'Spot fine up to ₹500'], references: ['SWM Rules 2016', 'SWM Amendment 2018'] }); this.addLegalDocument({ id: 'hwm_rules_2016', title: 'Hazardous and Other Wastes Management Rules, 2016', type: 'rule', authority: 'Ministry of Environment, Forest and Climate Change', year: 2016, status: 'active', summary: 'Rules for management of hazardous and other wastes.', keyProvisions: [ 'Authorization for hazardous waste management', 'Manifest system for waste tracking', 'Treatment and disposal standards', 'Liability and compensation provisions' ], applicableTo: ['Industries generating hazardous waste', 'Treatment facilities'], penalties: ['Closure directions', 'Fine up to ₹1 crore', 'Criminal liability'], references: ['HWM Rules 2016', 'HWM Amendment 2019'] }); } private initializeISCodes(): void { // Water quality standards this.addISCode({ code: 'IS 10500:2012', title: 'Drinking Water — Specification', category: 'Water Quality', year: 2012, status: 'current', scope: 'Specifies requirements for drinking water quality', keyRequirements: [ 'pH: 6.5-8.5', 'TDS: 500 mg/L (acceptable), 2000 mg/L (permissible)', 'Turbidity: 1 NTU (acceptable), 5 NTU (permissible)', 'Chloride: 250 mg/L (acceptable), 1000 mg/L (permissible)' ], testMethods: ['IS 3025 series for water testing'], applicableIndustries: ['Water supply', 'Bottled water', 'Food industry'], relatedCodes: ['IS 3025', 'IS 14543'] }); this.addISCode({ code: 'IS 3025:2009', title: 'Methods of Sampling and Test (Physical and Chemical) for Water and Wastewater', category: 'Testing Methods', year: 2009, status: 'current', scope: 'Standard methods for water and wastewater analysis', keyRequirements: [ 'Sample collection procedures', 'Preservation techniques', 'Analytical methods for various parameters', 'Quality control measures' ], testMethods: ['Gravimetric', 'Titrimetric', 'Spectrophotometric', 'Chromatographic'], applicableIndustries: ['Laboratories', 'Water treatment', 'Environmental monitoring'], relatedCodes: ['IS 10500', 'IS 2490'] }); // Air quality standards this.addISCode({ code: 'IS 5182:2006', title: 'Methods for Measurement of Air Pollution', category: 'Air Quality', year: 2006, status: 'current', scope: 'Methods for measurement of ambient air quality', keyRequirements: [ 'Sampling methods for particulate matter', 'Gas sampling techniques', 'Calibration procedures', 'Data validation methods' ], testMethods: ['Gravimetric analysis', 'Spectrophotometry', 'Gas chromatography'], applicableIndustries: ['Environmental monitoring', 'Industrial hygiene', 'Research'], relatedCodes: ['IS 11255', 'IS 9969'] }); // Structural codes this.addISCode({ code: 'IS 456:2000', title: 'Plain and Reinforced Concrete - Code of Practice', category: 'Structural Engineering', year: 2000, status: 'current', scope: 'Requirements for design and construction of concrete structures', keyRequirements: [ 'Material specifications', 'Design methods and principles', 'Construction practices', 'Quality control requirements' ], testMethods: ['Concrete strength testing', 'Durability tests', 'Non-destructive testing'], applicableIndustries: ['Construction', 'Infrastructure', 'Industrial structures'], relatedCodes: ['IS 875', 'IS 1893', 'IS 13920'] }); this.addISCode({ code: 'IS 875:1987', title: 'Code of Practice for Design Loads (Other than Earthquake) for Buildings and Structures', category: 'Structural Engineering', year: 1987, status: 'current', scope: 'Design loads for buildings and structures', keyRequirements: [ 'Dead load calculations', 'Live load specifications', 'Wind load calculations', 'Snow load considerations' ], testMethods: ['Load testing', 'Material property testing'], applicableIndustries: ['Building construction', 'Industrial structures', 'Infrastructure'], relatedCodes: ['IS 456', 'IS 800', 'IS 1893'] }); // Environmental engineering codes this.addISCode({ code: 'IS 4764:2017', title: 'Code of Practice for Concrete Structures for the Storage of Liquids', category: 'Environmental Engineering', year: 2017, status: 'current', scope: 'Design and construction of liquid storage structures', keyRequirements: [ 'Structural design criteria', 'Waterproofing requirements', 'Joint design and sealing', 'Quality control procedures' ], testMethods: ['Water tightness testing', 'Structural load testing'], applicableIndustries: ['Water treatment', 'Chemical storage', 'Sewage treatment'], relatedCodes: ['IS 456', 'IS 3370', 'IS 875'] }); } private addLegalDocument(doc: Omit): void { const document: LegalDocument = { ...doc, lastUpdated: new Date() }; this.legalDocuments.set(doc.id, document); } private addISCode(code: ISCode): void { this.isCodes.set(code.code, code); } private buildSearchIndex(): void { // Build search index for legal documents this.legalDocuments.forEach(doc => { const searchableText = [ doc.title, doc.summary, ...doc.keyProvisions, ...doc.applicableTo ].join(' ').toLowerCase(); const words = searchableText.split(/\W+/).filter(word => word.length > 2); words.forEach(word => { if (!this.searchIndex.has(word)) { this.searchIndex.set(word, []); } const docIds = this.searchIndex.get(word)!; if (!docIds.includes(doc.id)) { docIds.push(doc.id); } }); }); } private getAllDocuments(filters?: any): LegalDocument[] { let documents = Array.from(this.legalDocuments.values()); if (filters) { documents = documents.filter(doc => { if (filters.type && doc.type !== filters.type) return false; if (filters.authority && !doc.authority.toLowerCase().includes(filters.authority.toLowerCase())) return false; if (filters.year && doc.year !== filters.year) return false; return true; }); } return documents.sort((a, b) => b.year - a.year); } private extractLimits(parameter: string, documents: LegalDocument[]): Array<{ standard: string; maxValue: number; unit: string; }> { // Simplified limit extraction - in a real implementation, this would parse the documents const limits: Array<{ standard: string; maxValue: number; unit: string }> = []; const paramLower = parameter.toLowerCase(); if (paramLower.includes('ph')) { limits.push({ standard: 'IS 10500:2012', maxValue: 8.5, unit: 'pH units' }); } else if (paramLower.includes('bod')) { limits.push({ standard: 'CPCB Standards', maxValue: 30, unit: 'mg/L' }); } else if (paramLower.includes('cod')) { limits.push({ standard: 'CPCB Standards', maxValue: 250, unit: 'mg/L' }); } else if (paramLower.includes('tds')) { limits.push({ standard: 'IS 10500:2012', maxValue: 500, unit: 'mg/L' }); } else if (paramLower.includes('pm2.5')) { limits.push({ standard: 'CPCB NAAQS', maxValue: 40, unit: 'μg/m³' }); } else if (paramLower.includes('pm10')) { limits.push({ standard: 'CPCB NAAQS', maxValue: 60, unit: 'μg/m³' }); } return limits; } private getECRequirements(category: string): string[] { const baseRequirements = [ 'Project proposal with detailed technical specifications', 'Environmental Impact Assessment report', 'Environmental Management Plan', 'Risk assessment and disaster management plan', 'Details of public consultation (for Category A & B1)' ]; if (category === 'A') { return [ ...baseRequirements, 'Approved Terms of Reference from MoEF&CC', 'Comprehensive EIA by accredited consultants', 'Expert Appraisal Committee presentation', 'State government recommendation' ]; } else if (category === 'B1') { return [ ...baseRequirements, 'State level expert appraisal', 'District Collector certificate' ]; } else { return [ 'Simplified project information', 'Environmental clearance from SEIAA', 'No public consultation required' ]; } } } export const knowledgeVault = new KnowledgeVault(); export { LegalDocument, ISCode, ComplianceCheck };