Commit Graph
64 Commits
Author SHA1 Message Date
nutcas3 c39ea181bf feat: Add authentication handler with login, registration, user management, and JWT token operations
- Add AuthHandler struct with authService dependency and NewAuthHandler constructor
- Add LoginRequest/LoginResponse/RegisterRequest/ChangePasswordRequest structs with validation tags
- Add Login method with username/password validation, token generation, and user response
- Add Register method with email/password/role validation and user creation
- Add RefreshToken method with JWT refresh token validation
2026-04-22 20:57:34 +03:00
nutcas3 721f4450c2 feat: Update dependencies with JWT auth, Swagger docs, Kubernetes client, Casbin RBAC, and testing utilities
- Add golang-jwt/jwt/v5 v5.2.2, stretchr/testify v1.11.1, and vektah/gqlparser/v2 v2.5.32
- Add swaggo/swag v1.16.6, swaggo/gin-swagger v1.6.1, and swaggo/files v1.0.1 for API documentation
- Add k8s.io/client-go v0.35.4, k8s.io/api v0.35.4, and k8s.io/apimachinery v0.35.4 for Kubernetes integration
- Add casbin/casbin/v3 v3.8.1, casbin/gorm-adapter/v3 v3.41.0, and casbin/govaluate v1.10
2026-04-22 13:44:09 +03:00
nutcas3 ae24b7a1c6 feat: Add millisToDuration utility function for converting milliseconds to time.Duration with zero handling 2026-04-22 13:35:20 +03:00
nutcas3 1fd8a9db18 feat: Add cached database wrapper with query caching, invalidation, and statistics support
- Add CachedDatabase struct wrapping Database with cache.Cache field and NewCachedDatabase constructor
- Add CachedFind method with cache key generation from query/args, cache hit deserialization, database fallback on miss, and 5-minute TTL
- Add CachedFirst method with same caching pattern as CachedFind for single record queries
- Add InvalidateCache method for clearing all cache entries and InvalidateCacheKey
2026-04-22 13:20:04 +03:00
nutcas3 9e1a508769 feat: Add configuration store service with database-backed runtime settings, validation, and sensitive value masking
- Add ConfigStoreService struct with database dependency and NewConfigStoreService constructor
- Add List method with optional section filtering, section/key ordering, and sensitive value masking (********)
- Add UpsertConfigInput struct with section/key/value/type/sensitive/description/updated_by fields and required validation
- Add Upsert method with section+key lookup, default
2026-04-21 11:08:06 +03:00
nutcas3 648f7e59f5 feat: Add centralized error handling with typed error codes, validation support, and enhanced parsing utilities
- Add error code constants for validation/auth/resource/system/business logic errors (VALIDATION_FAILED/UNAUTHORIZED/NOT_FOUND/INTERNAL_ERROR/etc)
- Add EnhancedErrorResponse with error/code/details/context/timestamp/request_id fields and ValidationErrorResponse with field-specific errors array
- Add handleError function with gorm.ErrRecordNotFound/ErrDuplicatedKey/ErrInvalidData handling
2026-04-21 11:07:29 +03:00
nutcas3 021742a488 feat: Add Casbin RBAC service with policy management, permission checking, and default role configurations
- Add CasbinService struct with enforcer/db fields and NewCasbinService constructor with GORM adapter initialization
- Add Casbin model configuration with request_definition/policy_definition/role_definition/policy_effect/matchers for RBAC
- Add initializeDefaultPolicies with admin (full access), operator (manage services/monitoring), and viewer (read-only) role permissions
- Add CheckPermission method
2026-04-21 11:06:24 +03:00
nutcas3 f8d218448d refactor: Replace interface{} with any and add comprehensive plugin service tests with benchmarks
- Replace interface{} with any in sendDeactivationRequest method signature in es2_helpers.go
- Add plugin_service_test.go with setupPluginTest helper using in-memory SQLite and gorm.AutoMigrate
- Add TestPluginService_List with test cases for all/enabled/disabled/by-type filtering and no matches
- Add TestPluginService_Install with tests for successful install, duplicate prevention, and missing fields
2026-04-20 20:08:23 +03:00
nutcas3 f42a753372 feat: Add Swagger documentation models for API endpoints with comprehensive field annotations
- Add Subscriber model with IMSI/MSISDN/email/status/plan_id/profile_status fields and validation examples
- Add Service model with name/namespace/replicas/ready_replicas/available_replicas/creation_timestamp fields
- Add Deployment model with service/version/status/started_at/completed_at/metadata fields and status enum
- Add Plugin model with name/version/author/description/enabled/config fields
- Add Automation model with name/description/trigger/
2026-04-20 20:06:37 +03:00
nutcas3 14ca3d00e7 feat: Add deployment service with CRUD operations, rollback support, and status tracking
- Add DeploymentService struct with database dependency and NewDeploymentService constructor
- Add DeploymentFilter struct with Service/Environment/Status/Limit/Offset fields for query filtering
- Add List method with context support, filter application (service/environment/status), pagination (default limit: 20), and DESC ordering by created_at
- Add Get method with gorm.ErrRecordNotFound handling and formatted
2026-04-20 20:06:09 +03:00
nutcas3 dfa23fde3c feat: Add WebSocket handler with hub management, client connections, and real-time broadcasting
- Add websocket.Upgrader with CheckOrigin allowing all origins in development
- Add Message struct with type/data/timestamp fields for WebSocket messages
- Add Client struct with conn/send/mutex/closed fields and readPump/writePump/Close methods
- Add Hub struct with clients map, broadcast/register/unregister channels, and sync.RWMutex
- Add NewHub constructor and Run method with client registration/
2026-04-20 20:05:40 +03:00
nutcas3 4875fa7c88 feat: Add Kubernetes service with deployment management, scaling, restart, logs, and pod status monitoring
- Add KubernetesService struct with kubernetes.Clientset/namespace and NewKubernetesService constructor with in-cluster/kubeconfig fallback
- Add getInClusterNamespace helper with /var/run/secrets/kubernetes.io/serviceaccount/namespace reading
- Add Deployment struct with name/namespace/creationTimestamp/labels/replicas/readyReplicas/availableReplicas/updatedReplicas/unavailableReplicas fields
- Add ListDeployments method with AppsV1().Deployments().
2026-04-20 20:05:23 +03:00
nutcas3 501c558b9f feat: Add plugin service with CRUD operations, filtering, and enable/disable functionality
- Add PluginService struct with database dependency and NewPluginService constructor
- Add PluginFilter struct with Enabled/Type/Category fields for query filtering
- Add List method with context support, filter application (enabled/type/category), and DESC ordering by installed_at
- Add Get method with gorm.ErrRecordNotFound handling and formatted error messages
- Add InstallPluginInput struct with name/
2026-04-20 20:04:19 +03:00
nutcas3 a6ec720df3 feat: Add Prometheus service client with instant query execution, alert retrieval, and health checking
- Add PrometheusService struct with baseURL/http.Client (10s timeout) and PROMETHEUS_URL env config (default: http://prometheus:9090)
- Add Available method with /-/ready endpoint health check
- Add Query method with instant PromQL execution via /api/v1/query, URL escaping, error handling
- Add promResponse/promVectorData/PromVectorSample structs for query result parsing with metric/value fields
2026-04-20 18:10:36 +03:00
nutcas3 0e28b8a1ac feat: Add comprehensive API server with REST endpoints, WebSocket support, RBAC, monitoring, and service integrations
- Add server.go with Swagger documentation endpoint, WebSocket handler, health/ready/live monitoring endpoints
- Add global middleware: rate limiting, performance optimization, security headers, CORS, request size (10MB), timeout (30s)
- Add performance metrics endpoint with 100ms threshold monitoring
- Add authentication service initialization with JWT, WebSocket hub, health monitor
2026-04-20 18:09:53 +03:00
nutcas3 4a74483044 feat: Add cache package with in-memory implementation, LRU eviction, and multi-cache management
- Add CacheItem struct with key/value/expiration/createdAt/accessCount/lastAccess fields and IsExpired method
- Add Cache interface with Get/Set/Delete/Clear/Keys/Size/Stats methods
- Add CacheStats struct with hits/misses/hitRate/size/evictions/totalItems metrics
- Add MemoryCache with sync.RWMutex, maxSize limit, automatic cleanup goroutine, LRU eviction, and access tracking
- Add RedisCache placeholder
2026-04-20 18:09:26 +03:00
NutcaseandGitHub 1b2b9d2412 Revert "Revert "App layer"" (#5) 2026-04-17 16:08:27 +03:00
NutcaseandGitHub efed7e936c Revert "App layer" 2026-04-17 15:59:31 +03:00
nutcas3 dd15ecdb93 feat: Replace placeholder data with database queries in charging service methods
- Update GetSystemStats to query active sessions, total accounts, blocked users, and low balance alerts from database
- Update GetHealthStatus to check database connectivity and set ActiveSync status
- Update GetUsageStats to query usage events by IMSI and period with trend calculation comparing to previous period
- Update GetRealTimeUsage to query current session and today's usage from database
- Update ListUsageEvents to query usage events with
2026-04-17 15:55:41 +03:00
nutcas3 cea79ef825 feat: Add PaymentMethodDetails struct for token-based payment method retrieval
- Add PaymentMethodDetails with payment method ID, type, card details (last4, brand, expiry), fingerprint, and creation timestamp
- Support structured response for payment method token processing
2026-04-17 15:55:32 +03:00
nutcas3 04846c8564 feat: Add chaos engineering service with experiment execution and HTTP middleware
- Add ChaosService with experiment management and concurrent execution tracking
- Add experiment types: latency, kill, crash, partition, flush, and load with configurable duration/probability
- Add experiment status tracking: idle, running, completed, and failed states
- Add RunExperiment to start chaos experiments in background goroutines with automatic cleanup
- Add experiment executors: injectLatency, killConnections, crashService
2026-04-17 15:55:21 +03:00
nutcas3 3332edf9ca feat: Add payment webhook handler with Stripe integration and transaction processing
- Add WebhookHandler with Stripe webhook validation and event processing
- Add webhook event handlers: payment succeeded, failed, canceled, and dispute created
- Update transaction status and subscriber balance on successful payments
- Create alerts for failed payments and disputes with appropriate severity levels
- Add sendTopUpNotification to create notifications for successful top-ups
- Add PaymentController
2026-04-17 15:53:57 +03:00
nutcas3 ed04533db6 feat: Add Balance field to Subscriber model with default value of 0
- Add Balance float64 field to Subscriber struct with JSON and GORM tags
- Set default value to 0 in database schema
- Align PlanID and Status field formatting
2026-04-17 15:53:29 +03:00
nutcas3 d5ca53030c feat: Replace placeholder card details with Stripe API integration in AddPaymentMethod
- Add stripeGW field to SubscriberService and initialize in NewSubscriberService with API key and webhook secret
- Add processPaymentToken to call Stripe API and retrieve payment method details from token
- Update AddPaymentMethod to call processPaymentToken and use real card details (last4, brand, expiry dates) from Stripe
- Update AddPaymentMethod to use req.IsDefault instead of hardcoded false value
- Import
2026-04-17 15:53:20 +03:00
nutcas3 2fa56f0d83 feat: Add InfluxDB time-series storage with usage, system, and charging metrics tracking
- Add TimeSeriesStorage with InfluxDB client, write API, and query API for org/bucket
- Add metric types: MetricPoint, UsageMetrics, SystemMetrics, ChargingMetrics with subscriber/IMSI/transaction fields
- Add StoreUsageMetrics, StoreSystemMetrics, StoreChargingMetrics, and StorePacketMetrics to write metrics to InfluxDB
- Add GetUsageStats to query subscriber usage statistics for time range with last aggreg
2026-04-17 15:53:06 +03:00
nutcas3 a1222025e0 feat: Add Prometheus metrics collector with comprehensive telecom system monitoring
- Add MetricsCollector with HTTP middleware, subscriber tracking, and system uptime monitoring
- Add HTTP request metrics: total requests counter and duration histogram by method/endpoint/status
- Add subscriber metrics: total, active, and suspended subscriber gauges
- Add usage metrics: data bytes, voice seconds, and SMS count counters by subscriber
- Add charging metrics: credit balance gauge and payment transaction counter by
2026-04-17 15:52:53 +03:00
nutcas3 547abf1889 feat: Add database methods for transactions, payment methods, alerts, and notifications
- Add CreateTransaction to insert new transaction records
- Add UpdateSubscriberBalance to increment/decrement balance using SQL expression
- Add CreatePaymentMethod, GetPaymentMethod, DeletePaymentMethod, and ListPaymentMethods for payment method CRUD
- Add GetTransaction, GetTransactionByGatewayID, GetTransactionByChargeID to query transactions by different IDs
- Add UpdateTransaction to save transaction changes
- Add List
2026-04-17 15:52:41 +03:00
nutcas3 d24aa2cef0 feat: Add RetrievePaymentMethodFromToken to extract card details from Stripe tokens
- Add RetrievePaymentMethodFromToken to create payment method from token and extract card details
- Import paymentmethod package from stripe-go/v82
- Import payment package for PaymentMethodDetails type
- Return PaymentMethodDetails with ID, type, last4, brand, expiry dates, fingerprint, and creation timestamp
- Add error handling for payment method creation and missing card details
2026-04-17 15:51:50 +03:00
nutcas3 3d0f0188fb feat: Add Stripe payment gateway with customer management, invoicing, and webhook validation
- Add StripeGateway with secret key, webhook secret, and HTTP client with 30s timeout
- Add ProcessPayment to create payment intents with amount conversion to cents and metadata
- Add CreateCustomer to create Stripe customers with subscriber details and IMSI metadata
- Add ProcessRefund to process full or partial refunds via payment intent ID
- Add GetPaymentStatus to retrieve payment intent status and details
2026-04-17 15:50:03 +03:00
nutcas3 cbfe5a4b9f feat: Implement real-time subscription polling for subscriber and alert updates
- Update SubscribeToSubscriberUpdates to poll database every 3 seconds for subscriber changes since last update
- Add buffered channel (size 5) to prevent blocking on subscriber updates
- Track lastUpdatedAt timestamp to query only new subscriber changes
- Add SubscribeToAlertUpdates to poll database every 2 seconds for new alerts
- Add buffered channel (size 10) for alert updates with ID-based filtering
- Support optional
2026-04-17 15:47:47 +03:00
nutcas3 9d2e5b7175 feat: Remove comment separators and fix AlertUpdates severity parameter conversion
- Remove comment separators for mutations, subscriptions, filter helpers, and GraphQL handler sections
- Update AlertUpdates to convert AlertSeverity enum to string pointer for service call
- Add inline comment explaining severity conversion in AlertUpdates resolver
2026-04-17 15:46:55 +03:00
nutcas3 9ce03cf81e feat: Replace placeholder data with database queries in subscriber service methods
- Update GetAccount to query actual usage events and balance from database instead of returning zeros
- Update ListInvoices to query invoices with filters, pagination, and preload subscriber data
- Update GetInvoice to query invoice by ID with line items and subscriber preloading
- Update ListRatingPlans to query active rating plans ordered by monthly fee
- Update GetRatingPlan to query rating plan by ID with active
2026-04-17 15:44:59 +03:00
nutcas3 7cbd3b89b6 feat: Add payment gateway with Stripe integration, transaction processing, and webhook validation
- Add PaymentGateway interface with ProcessPayment, RefundPayment, GetPaymentStatus, CreatePaymentMethod, DeletePaymentMethod, and ValidateWebhook methods
- Add payment request/response types: PaymentRequest, PaymentResponse, RefundResponse, PaymentStatus, CreatePaymentMethodRequest, PaymentMethod
- Add payment status types: PENDING, PROCESSING, COMPLETED, FAILED, REFUNDED, CANCELLED
- Add payment method types
2026-04-17 15:44:41 +03:00
nutcas3 adbdb40066 feat: Add charging engine HTTP client with credit management and health monitoring
- Add ChargingEngineClient with base URL and HTTP client with configurable timeout
- Add CheckCredit to verify subscriber credit availability by IP with bytes requested
- Add DeductCredit to deduct bytes from subscriber credit balance
- Add AddCredit to add bytes to subscriber credit balance
- Add GetBalance to retrieve current credit balance for subscriber by IP
- Add HealthCheck to verify charging engine availability
2026-04-17 15:43:53 +03:00
nutcas3 99bff17756 feat: Add charging service with usage tracking, system monitoring, and real-time statistics
- Add ChargingService with database and charging engine client dependencies
- Add GetSystemStats to retrieve active sessions, accounts, blocked users, and uptime metrics
- Add GetHealthStatus to check Redis connection, sync status, and memory usage
- Add GetUsageStats to get subscriber usage statistics with data/voice/SMS volumes, costs, and trends
- Add GetRealTimeUsage to track current session and today's usage metrics
2026-04-17 15:41:11 +03:00
nutcas3 d248b9b5e5 feat: Add invoice service with monthly invoice generation, payment tracking, and automated billing
- Add InvoiceService with database dependency for invoice management operations
- Add GenerateMonthlyInvoice to create invoices with plan fees and usage charges from billing period
- Add SendInvoice to update invoice status to pending (email integration TODO)
- Add MarkInvoiceAsPaid to update invoice payment status
- Add GetOverdueInvoices to query invoices past due date with pending status
- Add GetSubscriber
2026-04-17 15:40:57 +03:00
nutcas3 72d5a9c8e0 feat: Add account management models with billing, payments, alerts, and system monitoring types
- Add SubscriberAccount with balance, usage limits (data/voice/SMS), and status tracking
- Add UsageEvent for tracking usage sessions with volume, rate, and cost
- Add Invoice with line items and status (DRAFT, PENDING, PAID, OVERDUE, CANCELLED)
- Add RatingPlan with rate definitions for data/voice/SMS and monthly fees
- Add Alert with types (LOW_BALANCE, HIGH_USAGE, PAYMENT_FAILED, SYSTEM_ERROR) and severity levels
- Add Pay
2026-04-17 15:38:47 +03:00
nutcas3 565052e406 feat: Add configuration for payment processing, charging engine, metrics, and time-series storage
- Add PaymentConfig with Stripe API key and webhook secret fields
- Add ChargingEngineConfig with base URL and timeout settings
- Add InfluxDBConfig with URL, token, org, and bucket fields
- Add MetricsPort field to ServerConfig for Prometheus metrics endpoint
- Set default values: MetricsPort 9090, ChargingEngine localhost:3001, InfluxDB localhost:8086
- Update Config struct to include Payment, ChargingEngine, and Infl
2026-04-17 15:36:44 +03:00
nutcas3 764e95619b feat: Add GraphQL, Prometheus, InfluxDB, and Stripe dependencies to API server
- Add gqlgen v0.17.89 for GraphQL server implementation
- Add prometheus/client_golang v1.23.2 for metrics collection
- Add influxdata/influxdb-client-go/v2 v2.14.0 for time-series metrics storage
- Add stripe/stripe-go/v82 v82.5.1 for payment processing
- Update go.mongodb.org/mongo-driver/v2 from v2.5.0 to v2.5.1
- Add supporting dependencies: gqlparser, oapi-codegen/runtime, line-protocol, prometheus client_model/
2026-04-17 15:36:14 +03:00
nutcas3 ccd50ac79e feat: Add API server main entry point with GraphQL, metrics collection, and system monitoring
- Add main server setup with Gin router, GraphQL handler, and graceful shutdown
- Initialize database connection and metrics collectors (Prometheus and InfluxDB time-series)
- Add HTTP middleware for Prometheus metrics collection
- Add /metrics endpoint for Prometheus scraping and /health endpoint for health checks
- Implement periodic metrics collection (30s interval) for subscribers, sessions, and system
2026-04-17 15:35:33 +03:00
nutcas3 bcc42ae4c3 feat: Add subscriber service methods for account management, invoicing, alerts, and payment operations
- Add GetAccount to retrieve subscriber account information with balance and usage limits
- Add ListInvoices/GetInvoice for invoice management with line items
- Add ListRatingPlans/GetRatingPlan for rating plan queries
- Add ListAlerts/CreateAlert/ResolveAlert for alert management
- Add SearchSubscribers for subscriber search functionality
- Add SubscribeToSubscriberUpdates/SubscribeToAlertUpdates
2026-04-17 15:35:22 +03:00
nutcas3 129a61c826 test: Add unit tests for GraphQL resolver helper functions
- Add parseID tests for valid IDs, invalid format, and zero values
- Add encodeCursor/decodeCursor tests for base64 cursor encoding/decoding with valid and invalid inputs
- Add buildUsageFilterWhere tests for empty filters, usage type filtering, and cost range filtering
- Add ResolverRoot method tests to verify Query/Mutation/Subscription return receiver
- Include helper function implementations (encodeCursor, decodeCursor, buildUsageFilterWhere)
2026-04-17 15:21:38 +03:00
nutcas3 eef5f21717 feat: Add GraphQL code generation scaffolding with comprehensive type definitions and resolver interfaces
- Add custom GraphQL types and enums: SubscriberStatus, ProfileStatus, UsageType, SessionStatus, PaymentMethodType, InvoiceStatus, AlertType, AlertSeverity, SubscriberSort, UsagePeriod, TrendDirection
- Define input types: SubscriberFilter, UsageEventFilter, CreateSubscriberInput, UpdateSubscriberInput, TopUpInput, UsageStatsInput, PaymentMethodInput, CreateAlertInput
- Define output types: Page
2026-04-17 15:21:21 +03:00
nutcas3 1383e08645 feat: Implement GraphQL resolvers for subscriber management, charging operations, and real-time monitoring
- Add Resolver struct with database, subscriber, charging, and ES2 service dependencies
- Implement query resolvers: Subscriber, SubscriberByImsi, Subscribers, SubscriberAccount, UsageEvents, UsageStats, RealTimeUsage, Invoices, Invoice, RatingPlans, RatingPlan, Alerts, SystemStats, HealthStatus, SearchSubscribers, SearchUsageEvents
- Implement mutation resolvers: CreateSubscriber, UpdateSubscriber, DeleteSubscriber, TopUpBalance, Suspend
2026-04-17 15:21:03 +03:00
nutcas3 86141062fe feat: Add comprehensive GraphQL schema for subscriber management and charging operations
- Add custom scalars (DateTime, JSON) for complex data types
- Define enums for subscriber status, profile status, usage types, session status, payment methods, invoice status, and alert types
- Add core types: Subscriber, SubscriberAccount, UsageEvent, RatingPlan, ChargingSession, PaymentMethod, Invoice, Alert
- Add system monitoring types: SystemStats, HealthStatus
- Implement Relay-style pagination with Connection
2026-04-17 15:18:06 +03:00
nutcas3 a335c6754e refactor: Split subscriber service into separate files for better code organization
- Move IMSI allocation logic to subscriber_imsi.go
- Move authentication key generation (generateAuthKeys, getOperatorVariant, generateOPc) to subscriber_auth.go
- Move eSIM profile operations (provisionESIMProfile, deactivateESIMProfile) to subscriber_esim.go
- Keep core subscriber CRUD operations and session management in subscriber.go
- Remove unused crypto/aes, crypto/rand, encoding/hex, and os imports from main
2026-04-14 16:22:22 +03:00
nutcas3 3a3b4d93a0 refactor: Split ES2 client into separate files for better code organization
- Move ES2 request/response types to es2_types.go
- Move profile operations (download, activate, deactivate, delete, status, list) to es2_operations.go
- Move helper methods (send requests, validation, generateRequestID) to es2_helpers.go
- Keep core ES2Service struct and ProvisionProfile in es2_client.go
- Revert sendDeactivationRequest parameter type from any back to interface{}
2026-04-14 16:22:07 +03:00
nutcas3 62cdffee2b feat: Remove unused generateRequestID helper function from AMF client
- Remove generateRequestID function and its fmt/time imports
- Function was not being used in AMF client implementation
2026-04-14 16:21:43 +03:00
nutcas3 1ead99440e feat: Replace interface{} with any type alias for improved code clarity
- Remove omitempty from Plan field in Subscriber model
- Update NotifySubscriberUpdate to use any instead of interface{}
- Update sendDeactivationRequest parameter type from interface{} to any
2026-04-14 16:07:04 +03:00
nutcas3 13355a07e7 feat: Add environment-based operator variant configuration with padding support
- Add os import for environment variable access
- Update getOperatorVariant to read OP from OPERATOR_VARIANT env var
- Add fallback to default "TelecomOP1234567" for development
- Add zero-padding for OP values shorter than 16 bytes
- Update comments to reference environment variable configuration
2026-04-14 16:06:09 +03:00