- Replace RedisOperation error variant with DatabaseError in new/get/list_map/add/remove methods
- Update 5 map_err calls to use DatabaseError for SQLx operation failures
- Replace float division with integer arithmetic in calculate_usage_cost for data/voice conversions
- Add checked_add overflow protection for usage accumulation in apply_charging_rules and process_usage
- Replace String-based charging rules with ChargingRule enum variants
- Add Datelike import and implement billing period filtering in generate_invoice
- Replace blocking KEYS command with SCAN cursor iteration
- Replace unwrap_or(0) with map_err for get operation in deduct_credit
- Replace unwrap_or(0) with ? operator in check_credit
- Add RedisOperation error mapping for current_balance retrieval
- Remove dead_code attributes from get_balance/add_credit/start/stop/uptime/rating plan methods in credit_management and engine
- Remove dead_code attributes from calculate_usage_cost in rating_billing
- Remove dead_code attributes from get/list_map/deactivate methods in rating_plans_repo and row_to_plan function
- Remove dead_code attributes from get_performance_metrics/start_background_sync in monitoring modules
- Add POST /v1/usage/calculate-cost endpoint to calculate usage cost for events
- Add POST /v1/usage/rate endpoint to rate usage events
- Add POST /v1/usage/process endpoint for full rating and billing processing
- Add GET /v1/invoice/:imsi/:period endpoint to generate invoices for billing periods
- Add list_map call to list_rating_plans handler for internal lookups
- Add session_id validation to all usage endpoints using validate_session_id helper
- Move all handler functions from api.rs to new handlers.rs module
- Add 20+ handler functions for credit management, subscriber accounts, rating plans, user blocking, system stats, metrics, engine control, error stats, sync control, and health checks
- Add input validation using validate_ip/validate_bytes/validate_amount/validate_session_id helpers
- Add error context and logging to all handlers using with_context and log
- Add error mapping to list_rating_plans in engine.rs
- Add dead_code attributes to get/list_map/deactivate methods in rating_plans_repo and row_to_plan function
- Add list method to RatingPlansRepo returning Vec<RatingPlan>
- Add dead_code attribute to validate_imsi in helpers
- Add UsageBlocked and ConfigurationError variants to ChargingError with Display/IntoResponse implementations
- Add Default
- Move create_router function from api.rs to new routes.rs module
- Move routing imports (delete/get/post/put/Router/CorsLayer) from api to routes
- Add handler function imports to routes module
- Move AppState from api to models module
- Remove validation comments from check_credit/deduct_credit/add_credit/get_balance/record_usage handlers
- Add IntoResponse import to api module
- Add GET /v1/errors endpoint to retrieve error statistics (total/types/last error)
- Add POST /v1/sync/start endpoint to start background sync
- Add GET /v1/health/detailed endpoint for detailed health checks (redis/sync/memory status)
- Add GET /v1/errors endpoint to retrieve error statistics
- Add POST /v1/sync/start endpoint for sync control
- Add GET /v1/health/detailed endpoint for detailed health checks
- Fix balance field type from u64 to i64 in update_subscriber
- Add status and last_updated fields to SubscriberAccount in update_subscriber
- Add PUT /v1/subscriber/:imsi endpoint to update subscriber account details (balance/data/voice/sms usage and limits)
- Add GET /v1/metrics endpoint to retrieve performance metrics (connected clients/memory/commands/RPS/response time)
- Add POST /v1/engine/start and POST /v1/engine/stop endpoints for engine lifecycle management
- Add GET /v1/engine/uptime endpoint to retrieve engine uptime in seconds
- Add put to
- Add GET/POST /v1/rating-plans and GET/DELETE /v1/rating-plans/:id endpoints for rating plan CRUD operations
- Add POST /v1/block/:ip, POST /v1/unblock/:ip, and GET /v1/blocked/:ip endpoints for user blocking management
- Add GET /v1/stats endpoint to retrieve system statistics (accounts/sessions/blocked users/alerts/uptime)
- Add delete to routing imports and remove unused IntoResponse/warn imports
- Add RatingPlan
- Add GET /v1/subscriber/:imsi endpoint to retrieve subscriber account details
- Add POST /v1/usage endpoint to record usage events with session validation
- Remove unused validate_imsi import and dummy validation calls from check_credit
- Add validate_amount call for bytes_used in deduct_credit
- Add balance retrieval logging and fix IP clone in get_balance response
- Add IMSI/session_id validation and error handling for missing fields in record_usage
- Return subscriber
- Add validate_imsi/validate_session_id/validate_amount/log_error imports to api/credit_management/rating_billing/sync modules
- Add validation calls for IMSI in get_subscriber_account and session_id in record_usage_event
- Add dummy validation calls in check_credit to prevent unused function removal
- Add validate_amount call after cost calculation in calculate_usage_cost
- Add log_error call in check
- Add redis::FromRedisValue/ToRedisArgs/ToSingleRedisArg imports
- Implement FromRedisValue for SubscriberAccount with JSON deserialization and ParsingError mapping
- Implement ToRedisArgs for SubscriberAccount with JSON serialization
- Implement ToSingleRedisArg for SubscriberAccount
- Implement FromRedisValue for UsageEvent with JSON deserialization and ParsingError mapping
- Implement ToRedisArgs for UsageEvent with JSON serial
- Replace context with map_err for InternalError on Postgres connection
- Replace context with map_err for RedisOperation on schema migration/fetch/list/upsert/deactivate operations
- Remove RatingPlan import and update get_rating_plan call to async with await
- Update generate_invoice to use get_multiplexed_async_connection instead of get_async_connection
- Replace context error handling with map_err for RedisConnection/RedisOperation errors
- Add explicit redis::AsyncCommands trait qualification for keys/get/set operations
- Update apply_monthly_fees to use async get_rating
- Replace in-memory HashMap rating plans with RatingPlansRepo for Postgres-backed storage
- Update constructor to accept RatingPlansRepo and remove hardcoded default plans (basic/premium/enterprise)
- Make redis_client/plans/sync_interval/startup_time fields public(crate) for module access
- Convert get_rating_plan/add_rating_plan/remove_rating_plan/list_rating_plans to async methods using
- Update all Redis operations to use get_multiplexed_async_connection instead of get_async_connection for better connection pooling
- Replace context error handling with map_err for RedisConnection/RedisOperation errors
- Add explicit redis::AsyncCommands trait qualification for all Redis operations (get/set/del/incr/decr/expire)
- Add ChargingSession import to types
- Add RatingPlansRepo import from charging module
- Add DATABASE_URL environment variable requirement for rating plans
- Connect to Postgres via RatingPlansRepo::connect and seed default rating plans
- Pass plans_repo to ChargingEngine::new constructor
- Add info log for Postgres connection and default rating plans
- Update all Redis operations to use get_multiplexed_async_connection instead of get_async_connection for better connection pooling
- Replace context error handling with map_err for RedisConnection/RedisOperation errors
- Add explicit redis::AsyncCommands trait qualification for all Redis operations (keys/get/set/del/ttl/expire)
- Add chrono::Datelike import
- Add ChargingError import from super::types
- Add ErrorContext<T> implementation for anyhow::Result<T> with with_context method that maps errors to ChargingError::InternalError with formatted context message
- Add RatingPlansRepo struct with PgPool for Postgres-backed rating plan storage
- Add connect method with max_connections=10 and idempotent schema creation for rating_plans table with plan_id/name/data_rate/voice_rate/sms_rate/monthly_fee/data_limit/voice_limit/sms_limit/is_active/created_at/updated_at columns
- Add seed_defaults with basic/premium/enterprise plans (data
- Replace placeholder uptime with actual elapsed time since startup using startup_time
- Add fallback to UNIX epoch time if system time goes backwards
- Implement get_process_memory to read actual memory from /proc/self/status on Linux
- Add estimate_memory_usage fallback for non-Linux systems (35MB base estimate)
- Add get_redis_memory_usage to query Redis memory info as secondary fallback
- Update get_memory_usage to use
- Add SystemTime import from std::time
- Add startup_time field to ChargingEngine struct
- Initialize startup_time with SystemTime::now() during engine creation
- Replace placeholder uptime calculation with actual elapsed time since startup
- Add fallback to current time if system time goes backwards
- Implement get_process_memory to read actual memory from /proc/self/status on Linux
- Add estimate_memory_usage fallback for non-Linux systems (35MB base estimate)
- Add get_redis_memory_usage to query Redis memory info as secondary fallback
- Update get_memory_usage to use layered fallback approach (
- Alias charging_new as charging and errors_new as errors
- Add new charging module imports (charging_types, charging_engine, credit_management, rating_billing, monitoring_sync, sync_operations, monitoring)
- Add new error module imports (error_types, error_helpers)
- Prepare for gradual migration from monolithic to modular structure
- Add AppState struct to hold shared ChargingEngine instance
- Add CreditCheckRequest and CreditCheckResponse for credit validation
- Add DeductRequest for byte usage deduction
- Add AddCreditRequest for credit top-up operations
- Add BalanceResponse for IP address balance queries
- Add HealthResponse with default implementation for health check endpoint
- Derive Serialize/Deserialize traits for API request/response types
- Add Go-based API server and carrier connector services
- Add Rust-based charging engine and packet gateway services
- Add Docker Compose configuration for local development
- Add comprehensive documentation (API, Architecture, Deployment)
- Add development scripts for Redis, MongoDB, and environment setup
- Add workspace configuration for Go modules and pnpm
- Remove unnecessary documentation files from web-dashboard
- Add project build configuration (Makefile, Cargo.toml)
This commit establishes the foundational microservices architecture for the sovereign Telecom-as-a-Service platform.