π± Telecom Billing System
A modular, production-ready Telecom Billing System built with Java 21 (Jakarta EE 11) backend and SvelteKit 5.x reactive frontend. Features real-time billing, CDR processing, PDF invoicing, and comprehensive admin controls.
ποΈ Architecture Stack
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SYSTEM ARCHITECTURE β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββ ββββββββββββββββ βββββββββββββ β
β β SvelteKitβ βββ β Tomcat 11 β βββ β Java 21 β β
β β 5.x β β Embedded β β Backend β β
β ββββββββββββ ββββββββββββββββ βββββββββββββ β
β β β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β HikariCP Connection Pool β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β NeonDB Cloud β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Layer
Technology
Version
Purpose
π» Backend
Java
21
Core language
π Framework
Jakarta EE
11
Enterprise APIs
π₯οΈ Server
Tomcat
11.0.21
Embedded servlet
ποΈ Database
NeonDB
3.x
Cloud PostgreSQL
π Pool
HikariCP
6.2.1
Connection pooling
π JSON
Jackson
2.17.0
JSON processing
π Reports
JasperReports
7.0.1
PDF invoices
π¨ Frontend
SvelteKit
5.x
Reactive UI
β¨ Styling
Tailwind CSS
4.0.0
Dark mode UI
The app is configured for seamless deployment on Railway with automatic health checks and environment variable support.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RAILWAY SETUP β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π Platform β Railway (railway.app) β
β π Database β NeonDB (your project) β
β π Connection β JDBC with SSL required β
β β€οΈ Health Check β GET /health β
β π¦ Build β Docker multi-stage build β
β π Deploy β Automatic on git push β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Variable
Description
Example
DB_URL
NeonDB JDBC URL
jdbc:postgresql://your-endpoint.neondb?sslmode=require
DB_USER
Database user
(from NeonDB dashboard)
DB_PASSWORD
Database password
(from NeonDB dashboard)
CDR_INPUT_PATH
Input directory
/app/input
CDR_PROCESSED_PATH
Processed directory
/app/processed
# Health endpoint (used for deployment detection)
GET https://your-app.railway.app/health
# Response:
# {"status":"UP","timestamp":"2026-04-30T12:00:00Z"}
# 1. Install Railway CLI
npm i -g @railway/cli
# 2. Login
railway login
# 3. Init project
railway init
# 4. Set environment variables (from NeonDB dashboard)
railway variables set DB_URL=" jdbc:postgresql://..."
railway variables set DB_USER=" ..."
railway variables set DB_PASSWORD=" ..."
# 5. Deploy
railway deploy
# Or connect GitHub repo for auto-deploy:
# https://railway.app/new
# Multi-stage build for Railway
FROM maven:3.9.6-eclipse-temurin-21 AS build
WORKDIR /build
COPY pom.xml .
RUN mvn dependency:go-offline -B
COPY . .
RUN mvn package -DskipTests -B
FROM eclipse-temurin:21-jre-jammy
WORKDIR /app
# Security: Run as non-root user
RUN addgroup --system javauser && adduser --system --ingroup javauser javauser
# Install curl for health checks
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Create directories
RUN mkdir -p /app/input /app/processed && chown -R javauser:javauser /app
# Copy artifacts
COPY --from=build /build/target/Telecom-Billing-Engine.jar app.jar
COPY --from=build /build/target/lib ./lib
COPY --from=build /build/src/main/webapp ./webapp_static
COPY --from=build /build/src/main/resources/invoice.jrxml .
COPY --from=build /build/src/main/resources/logo.svg .
COPY --from=build /build/src/main/resources/Pictures ./Pictures
# Set ownership
RUN chown -R javauser:javauser /app
# Switch to non-root user
USER javauser
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Run command
ENTRYPOINT ["java" , "-Xmx1g" , "-Djava.awt.headless=true" , "-cp" , "app.jar:lib/*" , "com.billing.Main" ]
Feature
Endpoint
Description
π Dashboard
/admin
Real-time stats & metrics
π₯ Customers
/admin/customers
Full customer CRUD
π Contracts
/admin/contracts
Contract management
π° Billing
/admin/bills
Bill generation & payment
π CDR
/admin/cdr
CDR upload & viewing
π¦ Packages
/admin/service-packages
Service packages
π΅ Rate Plans
/admin/rateplans
Tariff plans
π Audit
/admin/audit
Missing bill detection
Feature
Endpoint
Description
π€ Profile
/profile
View & edit profile
π± Contracts
/profile/contracts
My contracts
π Invoices
/profile/invoices
Invoice history
π₯ Download
/profile/invoices/download
PDF downloads
π Add-ons
/customer/addons
Purchase add-ons
π Register
/register
Self-registration
Feature
Description
ποΈ CDR Engine
Java CSV parser for call records
π§ͺ CDR Generator
Test data generation
π Jasper 7
PDF with element-kind schema
π€ Automation
Server-side billing (14% tax)
β€οΈ Health
Railway-compatible /health endpoint
# 1. Configure secrets
cp .env.example .env
# 2. Edit .env with your NeonDB credentials
# DB_URL=jdbc:postgresql://your-endpoint.neondb?sslmode=require
# DB_USER=your_username
# DB_PASSWORD=your_password
# 3. Run in IntelliJ
# File β Project Structure β Run Configurations
# Select Main class β Environment β .env file
# 4. Run
com.billing.Main
# Option 1: Deploy via GitHub (recommended)
# 1. Push code to GitHub
# 2. Create project at railway.app
# 3. Connect GitHub repository
# 4. Add environment variables in Railway dashboard
# 5. Deploy automatically on push
# Option 2: Deploy via CLI
railway init
railway deploy
Production (Local Container)
# Build the JAR
./mvnw clean package -DskipTests
# Launch with Podman/Docker
podman-compose up -d --build
# Verify health
curl http://localhost:8080/health
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NEONDB CONFIGURATION β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π Service β NeonDB Cloud β
β π Endpoint β (your-project-name) β
β π Database β neondb β
β π SSL β Required (sslmode=require) β
β π Pooling β HikariCP with 10 connections β
β πΎ Type β PostgreSQL compatible β
βββββββοΏ½οΏ½βοΏ½οΏ½βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CORE TABLES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β user_account β Customers & administrators β
β rateplan β Tariff plans β
β service_package β Bundled services β
β rateplan_service_package β Rateplan β Package links β
β contract β Customer contracts β
β contract_consumptionβ Usage tracking β
β ror_contract β Applied rates β
β bill β Billing invoices β
β invoice β PDF records β
β cdr β Call detail records β
β file β CDR file tracking β
β rejected_cdr β Rejected records β
β contract_addon β Customer add-ons β
β msisdn_pool β Phone number pool β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- Core Billing
SELECT generate_bill(1 , ' 2026-04-01' );
SELECT generate_all_bills(' 2026-04-01' );
-- Contract Management
SELECT create_contract(1 , 2 , ' 201000000001' , 500 );
SELECT change_contract_status(1 , ' suspended' );
SELECT change_contract_rateplan(1 , 2 );
-- Customer
SELECT login(' username' , ' password' );
SELECT get_all_customers(' search' , 50 , 0 );
-- Add-ons
SELECT purchase_addon(1 , 3 );
SELECT get_contract_addons(1 );
Trigger
Event
Action
trg_auto_rate_cdr
AFTER INSERT
Auto-rate CDR
trg_auto_initialize_consumption
BEFORE INSERT
Init period
trg_bill_payment
AFTER UPDATE
Restore credit
Method
Endpoint
Description
π’ GET
/health
Health check
Method
Endpoint
Description
β‘ POST
/api/auth/login
User login
β‘ POST
/api/auth/register
New customer
β‘ POST
/api/auth/logout
User logout
π’ GET
/api/auth/verify
Verify session
Method
Endpoint
Description
π’ GET
/api/customer/profile
Get profile
π‘ PUT
/api/customer/profile
Update profile
π’ GET
/api/customer/contracts
My contracts
π’ GET
/api/customer/invoices
My invoices
π’ GET
/api/customer/invoices/download
Download PDF
π’ GET
/api/customer/addons
My add-ons
β‘ POST
/api/customer/addons
Purchase add-on
π’ GET
/api/onboarding/available-msisdn
Phone numbers
β‘ POST
/api/onboarding/create-contract
New contract
Method
Endpoint
Description
π’ GET
/api/admin/customers
List customers
β‘ POST
/api/admin/customers
Create customer
π’ GET
/api/admin/customers/*
Get customer
π‘ PUT
/api/admin/customers/*
Update customer
π΄ DELETE
/api/admin/customers/*
Delete customer
π’ GET
/api/admin/contracts
List contracts
β‘ POST
/api/admin/contracts
Create contract
π‘ PUT
/api/admin/contracts/*/status
Change status
π‘ PUT
/api/admin/contracts/*/rateplan
Change rateplan
π’ GET
/api/admin/cdr
List CDRs
β‘ POST
/api/admin/cdr/upload
Upload CDR
β‘ POST
/api/admin/cdr/generate
Generate test
π’ GET
/api/admin/bills
List bills
β‘ POST
/api/admin/bills/*/pay
Pay bill
β‘ POST
/api/admin/bills/generate-all
Generate all
π’ GET
/api/admin/stats
Dashboard stats
π’ GET
/api/admin/audit/missing
Missing bills
Component
Status
Description
π Identity
β
Non-root javauser
π Secrets
β
Environment variable priority
π Observability
β
/health endpoint
π§ Build
β
LICENSE/NOTICE merge
π Reporting
β
JIT caching
π Assets
β
Container-native
π Routing
β
SPA normalization
π¨ Frontend
β
State fixes
π³ Billing
β
Idempotent upsert
π Railway
β
Auto-deploy ready
Phase 3: Advanced Auditability
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CARRIER-GRADE FEATURES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β cdr_rating_detail β Per-bundle consumption audit β
β Multi-Bucket β Split across rating events β
β Itemized Logs β Millisecond-accurate trailβ
β Dual Rating β Wholesale & retail rates β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Version 2.0 | April 2026 | Production Ready ποΈπ‘οΈπ