Global Constants: Centralized Configuration
This article explains how we use centralized constants to ensure consistency across all pages and templates.
The Problem: Scattered Configuration
Without centralization, configuration appears in multiple places:
-
Company name hardcoded in 50+ templates
-
Phone numbers duplicated across pages
-
Email addresses scattered in code
-
Addresses repeated in multiple formats
Problems:
-
Inconsistency (different phone numbers on different pages)
-
Hard to update (change in 50 places)
-
Errors (typos, outdated info)
The Solution: Single Source of Truth
All configuration defined in app/shared/config.py:
COMPANY_NAME = "Thinvent Technologies Private Limited"
COMPANY_PHONE = "+91-11-430-77467"
COMPANY_WHATSAPP = "919990344251"
SALES_EMAIL = "sales@thinvent.in"
Company Information
Names
Full name: Thinvent Technologies Private Limited
Short name: Thinvent Technologies
Tiny name: Thinvent
Usage: Full name in legal documents, short name in emails, tiny name in UI
Addresses
Two office locations stored as structured data:
Goa office:
-
Address, city, state, pincode
-
Phone number
-
GSTIN (tax ID)
-
Google Maps URL
Gurgaon office:
- Same structure as Goa
Benefit: Consistent formatting across invoices, emails, website
Contact Numbers
Sales phone: +91-11-430-77467
Support phone: +91-11-411-71494
Sales WhatsApp: +91-99903-44251
Support WhatsApp: +91-99903-44247
Storage format: Two versions (raw for API, display for UI)
Email Addresses
Sales: sales@thinvent.in
Support: support@thinvent.in
Info: info@thinvent.in
Accounts: accounts@thinvent.in
Legal Information
CIN: U72300DL2007PTC171292 (Company Identification Number)
Registered address: Delhi office address
Support hours: Monday-Friday, 10:00am-5:00pm
Template Injection
Constants automatically available in all templates:
@web.context_processor
def utility_processor():
return {
"COMPANY_NAME": COMPANY_NAME,
"COMPANY_PHONE": COMPANY_PHONE,
"COMPANY_WHATSAPP": COMPANY_WHATSAPP,
# ... all constants
}
Usage in templates:
<p>{{ COMPANY_NAME }}</p>
<a href="tel:{{ COMPANY_PHONE }}">{{ COMPANY_PHONE }}</a>
Currency Symbols
Symbols for all supported currencies:
CURRENCY_SYMBOLS = {
"INR": "₹",
"USD": "$",
"EUR": "€",
"GBP": "£",
# ... 10 currencies
}
Usage: Display prices with correct symbol
Supported Languages
20 languages with names and codes:
SUPPORTED_LANGUAGES = {
"hi": "हिन्दी",
"bn": "বাংলা",
"ta": "தமிழ்",
# ... 20 languages
}
Usage: Language selector dropdown
AWS Configuration
Region: ap-south-1 (Mumbai)
S3 buckets: Static files, analytics, backups
DynamoDB tables: All table names
Kinesis streams: Analytics ingestion
Benefit: Change region in one place, affects entire app
Email Configuration
SMTP server: Postfix on manage server
From addresses: Per module (sales, support, info)
Reply-to: Configured per email type
Benefit: Consistent email branding
File Paths
All file paths centralized:
Static files: /home/ubuntu/web-static/
Uploads: /home/ubuntu/uploads/
Logs: /var/log/gunicorn/
Benefit: Easy to change storage location
API Keys
Google Ads: API credentials
Google Search Console: Service account
Razorpay: Payment gateway keys
DeepSeek: AI API key
Storage: Loaded from JSON config file (not in code)
Benefit: Secure, environment-specific
Feature Flags
Modules enabled: ["manage", "RMM"] or ["web"]
Debug mode: True/False
Maintenance mode: True/False
Benefit: Toggle features without code changes
Timeouts and Limits
Session timeout: 30 days
Cookie max age: 30 days
Rate limits: Per endpoint
File upload limits: Per file type
Benefit: Consistent behavior across app
Benefits of Centralization
Consistency
Same info everywhere: Phone number same on all pages
No conflicts: Single source of truth
Brand consistency: Company name always formatted correctly
Maintainability
Update once: Change in one place
No search-replace: No hunting through code
Version control: Track changes in git
Testability
Mock easily: Override constants in tests
Environment-specific: Different values per environment
Validation: Validate once at startup
Security
No hardcoded secrets: API keys in config file
Environment variables: Sensitive data from env
Audit trail: Changes tracked in git
References
Technical Concepts
-
Configuration management - Wikipedia
-
Single source of truth - Wikipedia
Related Articles
-
Translation System - Uses SUPPORTED_LANGUAGES
-
Currency Conversion - Uses CURRENCY_SYMBOLS
-
Multi-Server Architecture - Uses AWS config
Summary
Global constants ensure consistency and maintainability:
Company info:
-
✅ Names (full, short, tiny)
-
✅ Addresses (Goa, Gurgaon)
-
✅ Contact numbers (sales, support)
-
✅ Email addresses (sales, support, info)
-
✅ Legal info (CIN, registered address)
Configuration:
-
✅ Currency symbols (10 currencies)
-
✅ Supported languages (20 languages)
-
✅ AWS resources (region, buckets, tables)
-
✅ File paths (static, uploads, logs)
-
✅ API keys (secure storage)
Benefits:
-
✅ Consistency (same info everywhere)
-
✅ Maintainability (update once)
-
✅ Security (no hardcoded secrets)
-
✅ Testability (easy mocking)
This centralized approach eliminates duplication and ensures consistency across the entire application.