Skip to content

kfrural/norman-compliance-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Norman Compliance Engine

Spring Boot Java PostgreSQL Docker License Engineering NBR

πŸ—οΈ Civil Engineering Specialized System - Automated Compliance Analysis with Brazilian Standards using AI and RAG

πŸ“‹ Overview

Norman was specifically developed to solve the MAJOR BOTTLENECK for civil engineers: the excessive time spent manually verifying compliance with Brazilian technical standards.

🎯 Real Civil Engineering Problem

Civil engineers spend up to 30% of their time reviewing documents searching for specific standard sections (NBRs). Human errors in this phase can cause structural failures, heavy fines from regulatory bodies, or construction project delays.

✨ Specialized Solution

Civil engineering focused compliance analysis engine that uses RAG (Retrieval-Augmented Generation) to instantly validate structural projects (memorials, calculations, specifications) against Brazilian Regulatory Standards (NBRs), providing exact references to standard items.

🎯 Problem Resolved

Engineers spend up to 30% of their time reviewing documents to ensure safety and technical standards are followed. Human errors in this phase can cause structural failures, heavy fines, or construction schedule delays.

✨ Solution

Robust backend in Spring Boot 3 that processes Brazilian technical standards, stores them in Vector Database (Vector DB) and uses Google Gemini Pro to automatically audit civil engineering projects, providing exact norm references and saving valuable professional time.


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Document      β”‚    β”‚   Vector Store   β”‚    β”‚   AI Services   β”‚
β”‚   Processing    │───▢│   (PGVector)     │───▢│   (Gemini/OpenAI)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                        β”‚
         β–Ό                       β–Ό                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   PDF Chunking  β”‚    β”‚ Semantic Search  β”‚    β”‚  Audit Engine   β”‚
β”‚   & Embeddings  β”‚    β”‚ & Similarity     β”‚    β”‚  Analysis       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Java 21+ (LTS)
  • Docker & Docker Compose
  • Maven 3.9+
  • API Keys:
    • Google Gemini API (required)
    • OpenAI API (optional, fallback)

1. Clone and Configure

git clone https://github.com/kfrural/norman-compliance-engine.git
cd norman-compliance-engine

# Configure environment variables
cp .env.example .env
# Edit .env with your API keys

2. Start Infrastructure

# Start all services (PostgreSQL, Redis, Prometheus, Grafana)
docker-compose up -d

# Wait for services to be ready
docker-compose ps

3. Run Application

# Compile and run
./mvnw spring-boot:run

# Or build Docker
docker build -t norman-engine .
docker run -p 8080:8080 norman-engine

4. Access Interfaces


πŸ“ Project Structure

src/main/java/com/norman/engine/
β”œβ”€β”€ config/           # Configurations (AI, Database, Monitoring)
β”œβ”€β”€ controller/       # REST Endpoints
β”œβ”€β”€ service/          # Business Logic
β”‚   β”œβ”€β”€ ai/          # AI Strategies (Strategy Pattern)
β”‚   β”œβ”€β”€ audit/       # Audit Engine
β”‚   └── vector/      # Vector Search
β”œβ”€β”€ domain/          # JPA Entities
β”œβ”€β”€ dto/             # Data Transfer Objects
β”œβ”€β”€ repository/      # Spring Data Repositories
β”œβ”€β”€ exception/       # Error Handling
└── util/            # Utilities

src/main/resources/
β”œβ”€β”€ application.yml  # Main Configurations
└── static/          # Static Resources

docker/               # Docker Configurations
β”œβ”€β”€ postgres/       # SQL Scripts
β”œβ”€β”€ prometheus/     # Metrics Configuration
β”œβ”€β”€ grafana/        # Dashboards
└── nginx/          # Reverse Proxy

docs/                 # Documentation
β”œβ”€β”€ api/            # API Documentation
└── architecture/   # Architecture and Design

scripts/             # Automation Scripts
β”œβ”€β”€ dev/           # Development Scripts
└── prod/          # Production Scripts

πŸ”§ Technologies Used

Component Technology Version
Framework Spring Boot 3.3.2
Language Java 21 (LTS)
Database PostgreSQL + PGVector 16+
AI/LLM Google Gemini Pro v1
Vector Store Spring AI + PGVector 1.0.0-M1
Cache Redis 7.2
Monitoring Prometheus + Grafana 2.48+
Tracing Jaeger 1.51
File Storage MinIO Latest
Reverse Proxy Nginx 1.25
Tests Testcontainers 1.20+

πŸ“Š Execution Flow

1. Standards Ingestion

sequenceDiagram
    participant U as User
    participant API as API
    participant DP as DocumentProcessor
    participant VS as VectorStore
    participant AI as EmbeddingAI

    U->>API: Upload Standard PDF
    API->>DP: Process Document
    DP->>DP: Extract Text (PDFBox)
    DP->>DP: Split into Chunks
    DP->>AI: Generate Embeddings
    AI-->>DP: 768-dimension vectors
    DP->>VS: Store with Metadata
    VS-->>API: Confirmation
    API-->>U: Standard Processed
Loading

2. Audit Process

sequenceDiagram
    participant U as User
    participant API as API
    participant AE as AuditEngine
    participant VS as VectorStore
    participant AI as AuditAI
    participant DB as Database

    U->>API: POST /api/v1/audit
    API->>AE: Start Audit
    AE->>VS: Search Relevant Context
    VS-->>AE: Top-5 Similar Segments
    AE->>AI: Analyze with Context
    AI-->>AE: Structured Findings
    AE->>DB: Save Results
    DB-->>AE: Confirmation
    AE-->>API: Audit Complete
    API-->>U: Compliance + Metrics
Loading

🎯 Technical Differentiators

1. Multi-Provider Strategy Pattern

  • Switch between Gemini, OpenAI without code changes
  • Automatic fallback when service fails
  • Real-time health checking

2. Self-Correction Loop

  • Automatic invalid JSON detection
  • Re-processing without manual intervention
  • Success rate metrics

3. Advanced Semantic Search

  • IVFFlat indexing for performance
  • Configurable similarity threshold
  • Metadata filtering (category, version)

4. Complete Observability

  • Distributed tracing with Jaeger
  • Custom metrics in Prometheus
  • Automated Grafana dashboards

πŸ§ͺ Tests

Run Tests

# Unit Tests
./mvnw test

# Integration Tests
./mvnw test -P integration-test

# Coverage Report
./mvnw jacoco:report

# Check Coverage
open target/site/jacoco/index.html

Testcontainers

All integration tests use Testcontainers to create isolated environments:

  • PostgreSQL with PGVector
  • Redis for cache
  • Mock servers for external APIs

πŸ“ˆ Metrics and Monitoring

Key KPIs

  • Vector Search Latency: < 100ms (P95)
  • AI Success Rate: > 95%
  • Cost per Audit: Tracked in tokens
  • Throughput: Audits/hour
  • Cache Hit Ratio: > 80%

Available Dashboards

  1. Performance Overview

    • Endpoint latency
    • Service error rate
    • Resource consumption
  2. AI Operations

    • Tokens consumed per model
    • Self-correction rate
    • Response time by provider
  3. Compliance Metrics

    • Compliance rate by category
    • Severity distribution
    • Main non-compliances

πŸ”’ Security

Authentication & Authorization

  • JWT Tokens (next version)
  • Role-based access control
  • Rate limiting per IP/user

Data Protection

  • Sensitive data encryption
  • Logs without private information
  • Automated backup

πŸš€ Deploy

Production with Docker

# Build and deploy
docker-compose -f docker-compose.prod.yml up -d

# Health checks
curl http://localhost:8080/actuator/health

Kubernetes

# Deployment example
apiVersion: apps/v1
kind: Deployment
metadata:
  name: norman-engine
spec:
  replicas: 3
  selector:
    matchLabels:
      app: norman-engine
  template:
    spec:
      containers:
      - name: norman
        image: norman-engine:1.0.0
        ports:
        - containerPort: 8080

🀝 Contribution

Developer Setup

# Install pre-commit hooks
./scripts/setup-dev.sh

# Format code
./mvnw spotless:apply

# Check style
./mvnw checkstyle:check

Pull Request Guidelines

  1. Fork and create feature branch
  2. Tests passing (>90% coverage)
  3. Semantic commits
  4. Filled PR template

πŸ“„ License

This project is licensed under MIT License - see LICENSE file for details.


πŸ™‹β€β™€οΈ Get in Touch

Have questions, suggestions, or want to contribute? I'd be happy to chat!


πŸ™ Acknowledgments

  • Spring Team for excellent Spring AI framework
  • Google for Gemini API
  • PostgreSQL for PGVector extension
  • Docker Community for containerization tools

⚑ Start right now: docker-compose up -d && ./mvnw spring-boot:run

πŸ“š Complete documentation: Project Wiki

πŸ› Report issues: Issues

About

AI-powered compliance analysis engine for civil engineering that automatically validates Brazilian Technical Standards (NBRs), saving engineers 30% of their time by eliminating manual document verification while preventing structural failures and regulatory fines.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors