A modern, feature-rich web application built with Angular 19 for creating, managing, and viewing database reports. This application provides a visual, no-code interface for building complex reports from multiple database sources without writing SQL.
- Purpose
- Features
- Technology Stack
- Prerequisites
- Installation & Setup
- Configuration
- Usage
- Architecture
- Project Structure
- Development
- Testing
- API Integration
- Troubleshooting
The Reports Web Application enables users to:
- Connect to multiple database types (SQL Server, MySQL, PostgreSQL, Oracle) without writing connection strings
- Build reports visually using an intuitive drag-and-drop interface - no SQL knowledge required
- Create complex queries with field selection, filtering, grouping, sorting, and aggregations
- Preview reports in real-time before saving to ensure data accuracy
- Export reports to Excel for further analysis and sharing
- Manage report templates for quick report creation
- View and interact with reports with dynamic filtering and formatting options
This application serves as the frontend companion to the Reports API, providing a complete solution for enterprise report management.
- Connect to SQL Server, PostgreSQL, MySQL, and Oracle databases
- Create and manage multiple data source connections
- Automatic database schema introspection
- Schema filtering and object type selection
- Secure credential storage
-
5-Step Wizard Interface:
- Data Source Selection - Choose or create a database connection
- Field Selection - Select fields from tables with hierarchical view
- Filter Builder - Add complex filter conditions (equals, contains, between, etc.)
- Group & Sort - Configure data grouping and sorting
- Format & Preview - Set layout, formatting, and preview results
-
Advanced Features:
- Drag-and-drop field selection
- Related table field selection
- Field aggregation (Sum, Average, Count, Min, Max)
- Complex filter logic with multiple conditions
- Multiple grouping levels
- Multi-field sorting
- Field formatting (currency, dates, numbers)
- Table view with virtual scrolling for large datasets
- Chart previews (bar, line, pie, area, column)
- Widget previews (metrics, KPIs, trends)
- Real-time data preview updates
- Responsive layout preview
- List all saved reports with search and sort
- Report templates for quick creation
- View, edit, and delete reports
- Dynamic filter modification at runtime
- Report metadata display (grouping, aggregations, sorting)
- Export reports to Excel (.xlsx) format
- Client-side Excel generation using
xlsxlibrary - Formatted data export with proper types
- Framework: Angular 19 (Standalone Components)
- Language: TypeScript 5.7
- UI Framework: Angular Material 19
- Icons: FontAwesome 5
- HTTP Client: Angular HttpClient (RxJS Observables)
- Excel Export: xlsx 0.18.5
- State Management: RxJS (BehaviorSubject, Observable)
- Routing: Angular Router
- Build Tool: Angular CLI
- Testing: Jasmine + Karma
Before you begin, ensure you have the following installed:
- Node.js (v18.x or higher) - Download
- npm (v9.x or higher) - Comes with Node.js
- Angular CLI (v19.x or higher) - Install globally:
npm install -g @angular/cli - Reports API - The backend API must be running (see Reports API README)
git clone <repository-url>
cd reports-webnpm installCreate or update the environment configuration file:
src/environments/environment.ts (for development):
export const environment = {
production: false,
apiUrl: 'http://localhost:3000/api' // Your Reports API URL
};src/environments/environment.prod.ts (for production):
export const environment = {
production: true,
apiUrl: 'https://your-api-domain.com/api' // Production API URL
};npm start
# or
ng serveThe application will be available at http://localhost:4200/
- Open
http://localhost:4200/in your browser - Ensure the Reports API is running and accessible
- Try creating a new report to verify API connectivity
The application communicates with the Reports API. Configure the API URL in the environment files:
// src/environments/environment.ts
export const environment = {
production: false,
apiUrl: 'http://localhost:3000/api' // Update to match your API
};If you encounter CORS errors, ensure the Reports API has CORS enabled for your development domain (http://localhost:4200).
Supported database types:
sqlserver- Microsoft SQL Serverpostgresql- PostgreSQLmysql- MySQLoracle- Oracle Database
-
Navigate to Reports List
- Click "New Report" or go to
/builder
- Click "New Report" or go to
-
Step 1: Choose Data Source
- Select an existing data source or create a new one
- For new data sources:
- Enter database connection details (server, port, database, credentials)
- Click "Fetch Schema" to introspect the database
- Click "Save" to store the connection
-
Step 2: Select Fields
- Browse the schema in hierarchical or flat view
- Click fields to add them to the report
- Configure aggregations for numeric fields (Sum, Avg, Count, etc.)
- Select fields from related tables using the relationship dialog
- Configure field formatting (currency, dates, etc.)
-
Step 3: Add Filters
- Click "Add Filter" to create filter conditions
- Select field, operator (equals, contains, between, etc.), and value
- Add multiple filters and combine with AND/OR logic
- Filters are validated based on field data types
-
Step 4: Group & Sort
- Add fields for grouping (creates grouped rows)
- Add sort fields with direction (ascending/descending)
- Multiple sort levels are supported
-
Step 5: Format & Preview
- Enter report name and description
- Configure layout settings (table, chart, widgets)
- Preview the report data in real-time
- Click "Save Report" to persist the configuration
-
From Reports List
- Click on a report card to view it
- Or click the "View" icon
-
In Report Viewer
- See report data in table format
- Modify filters dynamically
- View report metadata (grouping, aggregations)
- Export to Excel
- Edit the report
- From Reports List or Report Viewer, click "Edit"
- The report builder opens with existing configuration
- Modify any step of the report
- Save changes
- In Report Viewer, click "Export to Excel"
- The report data is generated client-side
- Excel file downloads automatically
// 1. Create Data Source
{
name: "Sales Database",
type: "sqlserver",
server: "sales-db.company.com",
database: "SalesDB",
username: "report_user",
password: "***"
}
// 2. Select Fields
- Orders.OrderDate
- Orders.TotalAmount (with SUM aggregation)
- Customers.CustomerName
- Products.ProductName
// 3. Add Filters
- OrderDate >= '2024-01-01'
- TotalAmount > 1000
// 4. Group & Sort
- Group by: Customers.CustomerName, Products.ProductName
- Sort by: Orders.OrderDate (descending)
// 5. Save as "Q1 2024 Sales Report"The application follows Angular's component-based architecture with a feature-based folder structure:
app/
├── core/ # Shared core functionality
│ ├── models/ # TypeScript interfaces and types
│ └── utils/ # Utility functions and validators
├── features/ # Feature modules
│ ├── report-builder/ # Report creation wizard
│ ├── report-viewer/ # Report viewing and interaction
│ └── reports-list/ # Reports listing and management
├── layout/ # Layout components
└── shared/ # Shared reusable components
-
Service Layer (
ReportBuilderService)- Handles all HTTP communication with the API
- Manages application state using RxJS Observables
- Provides methods for CRUD operations
-
Component Layer
- Presentation and user interaction
- Delegates data operations to services
- Manages local component state
-
Model Layer
- TypeScript interfaces define data structures
- Models ensure type safety across the application
- RxJS Observables for reactive data flow
- BehaviorSubject for current report state
- Component-level state for UI interactions
- Service-level state for shared data
reports-web/
├── src/
│ ├── app/
│ │ ├── core/
│ │ │ ├── models/ # Type definitions
│ │ │ │ ├── data-source-info.model.ts
│ │ │ │ ├── preview-result.model.ts
│ │ │ │ ├── report.models.ts
│ │ │ │ └── schema-info.model.ts
│ │ │ └── utils/ # Utility functions
│ │ │ ├── model-validators.ts
│ │ │ ├── model-transforms.ts
│ │ │ └── index.ts
│ │ ├── features/
│ │ │ ├── report-builder/ # Report creation wizard
│ │ │ │ ├── components/
│ │ │ │ │ ├── chart-preview/
│ │ │ │ │ ├── datasource-selector/
│ │ │ │ │ ├── field-format-dialog/
│ │ │ │ │ ├── field-selector/
│ │ │ │ │ ├── filter-builder/
│ │ │ │ │ ├── group-sorting/
│ │ │ │ │ ├── preview-panel/
│ │ │ │ │ ├── related-field-dialog/
│ │ │ │ │ └── widget-preview/
│ │ │ │ ├── report-builder.component.ts
│ │ │ │ └── services/
│ │ │ │ └── report-builder.service.ts
│ │ │ ├── report-viewer/ # Report viewing
│ │ │ │ └── report-viewer.component.ts
│ │ │ └── reports-list/ # Reports listing
│ │ │ └── reports-list.component.ts
│ │ ├── layout/ # Layout components
│ │ │ ├── layout-preview/
│ │ │ └── layout-settings-dialog/
│ │ ├── shared/ # Shared components
│ │ │ └── components/
│ │ │ ├── help-tooltip/
│ │ │ └── smart-search/
│ │ ├── app.component.ts # Root component
│ │ ├── app.routes.ts # Route configuration
│ │ └── app.config.ts # App configuration
│ ├── environments/
│ │ ├── environment.ts # Development config
│ │ └── environment.prod.ts # Production config
│ └── assets/ # Static assets
├── angular.json # Angular CLI configuration
├── package.json # Dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # This file
npm start
# or
ng serveNavigate to http://localhost:4200/. The app will automatically reload if you change any source files.
npm run build
# or
ng build --configuration productionThe build artifacts will be stored in the dist/ directory.
Generate new components, services, and more using Angular CLI:
# Generate a new component
ng generate component component-name
# Generate a new service
ng generate service service-name
# Generate with options
ng generate component feature/component-name --skip-testsThe project follows Angular style guide best practices:
- Standalone components
- OnPush change detection where applicable
- RxJS operators for reactive programming
- TypeScript strict mode
- Comprehensive JSDoc documentation
npm test
# or
ng testThis will execute unit tests via Karma and watch for file changes.
ng test --code-coverageCoverage reports will be generated in the coverage/ directory.
- Unit tests use Jasmine and Karma
- Tests are co-located with source files (
.spec.ts) - Core utilities have comprehensive test coverage (80%+)
describe('ReportBuilderService', () => {
let service: ReportBuilderService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ReportBuilderService);
});
it('should retrieve reports', () => {
service.getReports().subscribe(reports => {
expect(reports).toBeDefined();
});
});
});The ReportBuilderService provides methods for all API interactions:
// Reports
getReports(): Observable<ReportDefinition[]>
getReport(id: string): Observable<ReportDefinition>
saveReport(report: ReportDefinition): Observable<ReportDefinition>
deleteReport(id: string): Observable<void>
// Data Sources
getDataSources(): Observable<DataSourceInfo[]>
createDataSource(dataSource: DataSourceInfo): Observable<DataSourceInfo>
updateDataSource(id: string, dataSource: DataSourceInfo): Observable<DataSourceInfo>
deleteDataSource(id: string): Observable<void>
// Schema
getSchema(dataSourceId: string): Observable<SchemaInfo>
introspectSchema(dataSource: DataSourceInfo): Observable<SchemaInfo>
// Preview
previewReport(report: ReportDefinition): Observable<PreviewResult>
exportToExcel(report: ReportDefinition): Observable<Blob>import { ReportBuilderService } from './services/report-builder.service';
constructor(private reportService: ReportBuilderService) {}
// Load all reports
this.reportService.getReports().subscribe({
next: (reports) => {
this.reports = reports;
},
error: (error) => {
console.error('Failed to load reports:', error);
}
});
// Create a data source
const newDataSource: DataSourceInfo = {
name: 'My Database',
type: 'sqlserver',
server: 'localhost',
database: 'MyDB',
username: 'user',
password: 'pass'
};
this.reportService.createDataSource(newDataSource).subscribe({
next: (dataSource) => {
console.log('Data source created:', dataSource.id);
}
});Problem: Browser blocks API requests with CORS errors.
Solution:
- Ensure Reports API has CORS enabled for
http://localhost:4200 - Check API configuration in Reports API project
Problem: Cannot connect to the Reports API.
Solution:
- Verify
apiUrlinenvironment.tsmatches your API server - Ensure Reports API is running
- Check network connectivity
- Verify firewall settings
Problem: Schema introspection fails or takes too long.
Solution:
- Verify database connection credentials
- Check database server accessibility
- Ensure database user has schema read permissions
- Try reducing schema filtering (use
includedSchemasto limit scope)
Problem: TypeScript compilation errors.
Solution:
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear Angular cache
ng cache cleanProblem: ng serve fails with port 4200 already in use.
Solution:
# Use a different port
ng serve --port 4201
# Or kill the process using port 4200
# Windows
netstat -ano | findstr :4200
taskkill /PID <PID> /F
# Mac/Linux
lsof -ti:4200 | xargs kill-
Browser DevTools
- Check Network tab for API request failures
- Use Console for error messages
- Inspect Angular component state in Elements tab
-
Angular DevTools
- Install Angular DevTools browser extension
- Inspect component tree and state
-
API Logs
- Check Reports API server logs
- Verify API endpoints are responding
- Angular Documentation
- Angular Material
- RxJS Documentation
- TypeScript Handbook
- Reports API Documentation
UNLICENSED