A full-stack web application for RDF data generation, validation, and SHACL shape constraint checking, focusing on reference material datasets for creep properties of single crystal Ni-based superalloys.
This project develops a framework for reference material data sets using creep properties of single crystal Ni-based superalloy as an example. The framework provides:
- (i) Tools for evaluating and validating experimental/modeling methods and their uncertainties
- (ii) Systems for assessing the performance of analysis, modeling, and simulation tools
- (iii) Comprehensive material descriptions through metadata schemas and ontologies
The application implements community-driven processes for the definition, identification, and curation of reference material data sets, including metadata, raw data, processed data, and quality assessment routines.
This is a monorepo containing:
- Frontend: Next.js 14 (React 18) with TypeScript and Tailwind CSS
- Backend: FastAPI (Python) with RDF/SHACL validation capabilities
- Data: Sample datasets, schemas, and mapping documents
IUC02_NextJS/
βββ frontend/ # Next.js web application
βββ backend/ # FastAPI REST API
βββ data/ # Sample data files and schemas
βββ README.md # This file
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Interface β
β (Next.js 14 + React 18) β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββ
β β
β HTTP/REST API β WebSocket (Future)
β β
ββββββββββββββΌβββββββββββββββββββββββββββββββββββββΌββββββββββββββββ
β Frontend Layer β
β βββββββββββββββ ββββββββββββββββ βββββββββββββββββββββββ β
β β Components β β API Routes β β Chat Assistant β β
β β β β β β (OpenAI GPT-4o) β β
β β - Navigationβ β - /api/chat β β β β
β β - ChatBox β β β β β’ Rate Limiting β β
β β - Workflow β β β β β’ Response Cache β β
β β - Validationβ β β β β’ Topic Filtering β β
β βββββββββββββββ ββββββββββββββββ βββββββββββββββββββββββ β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β Axios HTTP Client
β
ββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend Layer β
β (FastAPI + Python) β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β RDF Processor β β File Manager β β
β β (rdflib) β β β β
β β β β β’ Serve Files β β
β β β’ Parse Turtle β β β’ List Files β β
β β β’ Validate β β β’ Download β β
β β β’ JSON-LD β β β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β β
β β pyshacl β
β β β
β ββββββββββΌβββββββββββββββββββββββββββββββββ β
β β SHACL Validation Engine β β
β β (pyshacl 0.25.0) β β
β β β β
β β β’ Constraint Checking β β
β β β’ Validation Reports β β
β β β’ Conformance Testing β β
β ββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β File System Access
β
ββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Data Layer β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββ β
β β RDF Graphs β β SHACL Shapes β β Metadata Schemas β β
β β (.ttl) β β (.ttl) β β (.json) β β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Creep Experiment Data (.LIS) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
External Services:
ββββββββββββββββββββββββ
β OpenAI API β
β (GPT-4o-mini) β
β β
β β’ Natural Language β
β β’ Context-Aware β
β β’ Rate Limited β
ββββββββββββββββββββββββ
Validation Workflow:
User Upload β Frontend Validation β Backend API β RDF Parser
β
SHACL Validator
β
Validation Report (JSON)
β
Frontend Display
Chat Assistant Workflow:
User Question β ChatBox Component β Rate Limiter β Cache Check
β
Cache Miss?
β
OpenAI API
β
Store in Cache (5 min TTL)
β
Return Response
- π Interactive Workflow Visualization - Visual representation of the data generation and validation workflow
- π File Management - Browse and download example datasets, schemas, and mapping documents
- β RDF/SHACL Validation - Upload or use example RDF data graphs and SHACL shapes for validation
- π€ AI Chat Assistant - OpenAI-powered chatbot to help with RDF, SHACL, and workflow questions
- π¨ Modern UI - Responsive design with Tailwind CSS and smooth animations
- π± Mobile Friendly - Fully responsive interface
- π RDF Validation - Validate RDF data against SHACL shapes using pyshacl
- π File API - Serve example data files from the data directory
- π JSON-LD Conversion - Convert RDF graphs to JSON-LD format
- π Fast & Async - Built with FastAPI for high performance
- π‘ CORS Enabled - Configured for frontend integration
- Node.js 18.x or higher
- Python 3.9 or higher
- npm or yarn package manager
- Git
git clone https://github.com/teman67/IUC02_NextJS.git
cd IUC02_NextJS# Navigate to backend directory
cd backend
# Create and activate virtual environment
python -m venv backend
.\backend\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the backend server
uvicorn main:app --reload --port 8000The backend API will be available at http://localhost:8000
# Navigate to frontend directory (in a new terminal)
cd frontend
# Install dependencies
npm install
# Configure OpenAI API (for AI chat assistant)
# Create .env.local file and add your OpenAI API key:
# OPENAI_API_KEY=your_openai_api_key_here
# Get your key from: https://platform.openai.com/api-keys
# Run the development server
npm run devThe frontend application will be available at http://localhost:3000
- Click the chat icon (blue button) in the bottom-right corner
- Ask questions about:
- RDF data generation and concepts
- SHACL validation and shapes
- Application workflow and navigation
- Schema requirements and metadata
- Features:
- Context-aware responses about IUC02 framework
- Rate limiting (5 messages per 2 minutes)
- Response caching for instant repeated answers
- Focused on semantic web and materials science topics
- Navigate to Data Generation page
- Browse available files:
- Creep experiment input files (
.LIS) - Metadata schemas (
.json) - RDF graphs (
.ttl) - SHACL shapes (
.ttl) - Mapping documents
- Creep experiment input files (
- Preview and download files as needed
- Navigate to Data Validation page
- Choose either:
- Upload your own files (RDF Data Graph and SHACL Shape Graph)
- Use example files from the data directory
- Click Validate to run SHACL validation
- View validation results:
- Conformance status (β Valid / β Invalid)
- Detailed validation report
- JSON-LD representation of the data graph
Visit http://localhost:8000/docs for interactive API documentation (Swagger UI)
Available endpoints:
GET /- API health checkGET /api/health- Detailed health statusPOST /api/validate- Validate RDF against SHACL shapesGET /api/files/{filename}- Retrieve file content from data directoryGET /api/files- List all available files
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- HTTP Client: Axios
- AI Integration: OpenAI API (GPT-4o-mini)
- UI Components: Custom React components
- Framework: FastAPI
- Language: Python 3.9+
- RDF Processing: rdflib 7.0.0
- SHACL Validation: pyshacl 0.25.0
- Data Validation: Pydantic
- Server: Uvicorn
- RDF: Turtle (
.ttl) - Metadata: JSON Schema
- Validation: SHACL shapes
- Serialization: JSON-LD
frontend/
βββ src/
β βββ app/ # Next.js App Router pages
β β βββ page.tsx # Home page
β β βββ about/ # About page
β β βββ data-generation/ # Data generation workflow
β β βββ data-validation/ # Validation interface
β β βββ api/
β β βββ chat/ # AI chat API route
β βββ components/ # Reusable React components
β β βββ Navigation.tsx # Navigation bar
β β βββ ChatBox.tsx # AI chat assistant
β β βββ WorkflowDiagram.tsx
β β βββ BackgroundLogo.tsx
β β βββ WarningMessage.tsx
β βββ lib/
β βββ chatCache.ts # Caching & rate limiting
βββ public/ # Static assets
βββ CHATBOX_SETUP.md # AI chat setup guide
βββ CHAT_PROTECTION.md # Protection features docs
βββ package.json # Dependencies and scripts
backend/
βββ main.py # FastAPI application
βββ requirements.txt # Python dependencies
βββ backend/ # Virtual environment
data/
βββ 2024-09_Schema_IUC02_v1.json # Metadata schema
βββ mapping document.json # Mapping document
βββ rdfGraph_smallExample.ttl # Example RDF data
βββ shaclShape_smallExample.ttl # Example SHACL shapes
βββ Vh5205_C-95.LIS # Creep experiment data
βββ Vh5205_C-95_translated.json # Translated metadata
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint# Run with auto-reload
uvicorn main:app --reload
# Run on specific port
uvicorn main:app --port 8000
# Run with custom host
uvicorn main:app --host 0.0.0.0 --port 8000Create .env.local in the frontend directory:
NEXT_PUBLIC_API_URL=http://localhost:8000
OPENAI_API_KEY=your_openai_api_key_hereNote:
- The
OPENAI_API_KEYis required for the AI chat assistant feature - Get your API key from OpenAI Platform
- Keep this file private and never commit it to version control
-
Rate Limiting Test:
- Send 6 messages rapidly
- 6th message should trigger rate limit error
- Wait 2 minutes for reset
-
Cache Test:
- Ask "What is RDF?" (takes 1-2 seconds)
- Ask the exact same question (instant response)
- Check browser console for cache indicators
-
Topic Enforcement Test:
- Ask off-topic question (e.g., "What's the weather?")
- Should politely redirect to IUC02 topics
You can test the validation endpoint using curl:
curl -X POST "http://localhost:8000/api/validate" \
-H "Content-Type: application/json" \
-d '{
"rdf_content": "@prefix ex: <http://example.org/> . ex:subject ex:predicate ex:object .",
"shacl_content": "@prefix sh: <http://www.w3.org/ns/shacl#> ..."
}'Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is part of the NFDI-MatWerk initiative.
- Git Repository: https://git.rwth-aachen.de/nfdi-matwerk/iuc02
- NFDI-MatWerk: National Research Data Infrastructure for Materials Science & Engineering
For questions and support, please refer to the main IUC02 repository.
This project uses data from:
- PP18 BAM: Bundesanstalt fΓΌr Materialforschung und -prΓΌfung
- PP01 SFB/TR103: Collaborative Research Centre on Ni-based superalloys
Built with β€οΈ for materials science research and data standardization