A minimal FastAPI service that translates 1EdTech CASE 1.1 JSON documents to:
- IEEE SCD JSON-LD format
- ASN-CTDL JSON-LD format
-
Install Python 3.11 (if not already installed)
-
Create a virtual environment (recommended):
python3.11 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
Start the server:
python main.pyOr using uvicorn directly:
uvicorn main:app --reloadThe service will be available at http://localhost:8000
- Web UI:
http://localhost:8000/(serves the interactive translator) - API docs:
http://localhost:8000/docs - Health check:
http://localhost:8000/health - Translate endpoints:
POST /translate/case-to-ieee(IEEE SCD output, JSON body)POST /translate/case-to-asn(ASN-CTDL output, JSON body)POST /translate/upload-file(File upload endpoint, accepts .json file)
- Field mapping:
GET /field-mapping(JSON endpoint with 3-way comparison)
A simple web interface is available for interactive translation:
-
Start the API server (see "Running the Service" above)
-
Open the web UI: Navigate to
http://localhost:8000/in your browser -
Features:
-
Translator Tab:
- Format selector: Choose between IEEE SCD or ASN-CTDL output format
- File upload: Upload a JSON file directly - automatically loads into editor and translates
- Left panel: Editable CASE 1.1 JSON input (pre-loaded with example data)
- Right panel: Read-only JSON-LD output (format depends on selection)
- Translate button: Sends POST request to the appropriate API endpoint
- Progress indicators: Shows "Parsing CASE", "Building graph", "Emitting JSON-LD"
- Request/Response details: Expandable section showing HTTP status, request payload, and response payload
- Syntax highlighting: JSON is color-coded for readability
- Error display: Clear error messages shown in UI
- Keyboard shortcut: Ctrl/Cmd + Enter to translate
-
Field Mapping Tab:
- Complete 3-way mapping table: CASE 1.1 ↔ IEEE SCD ↔ ASN-CTDL
- Shows mapped fields (with corresponding field names in each format)
- Shows partially mapped fields (available in one format but not the other)
- Shows format-specific fields (added during translation)
- Organized by entity type: CFDocument, CFItem, CFAssociation
- Color-coded badges for quick status identification
-
Test that the API is running:
curl http://localhost:8000/healthExpected response:
{"status":"healthy","service":"CASE to IEEE SCD Translator"}curl -X POST "http://localhost:8000/translate/case-to-ieee" \
-H "Content-Type: application/json" \
-d @example_case.jsonSave output to file:
curl -X POST "http://localhost:8000/translate/case-to-ieee" \
-H "Content-Type: application/json" \
-d @example_case.json \
-o output_ieee_scd.jsoncurl -X POST "http://localhost:8000/translate/case-to-asn" \
-H "Content-Type: application/json" \
-d @example_case.jsonSave output to file:
curl -X POST "http://localhost:8000/translate/case-to-asn" \
-H "Content-Type: application/json" \
-d @example_case.json \
-o output_asn_ctdl.jsoncurl -X POST "http://localhost:8000/translate/upload-file" \
-F "file=@example_case.json" \
-F "target_format=ieee_scd"Save output to file:
curl -X POST "http://localhost:8000/translate/upload-file" \
-F "file=@example_case.json" \
-F "target_format=ieee_scd" \
-o output_ieee_scd.jsoncurl -X POST "http://localhost:8000/translate/upload-file" \
-F "file=@example_case.json" \
-F "target_format=asn_ctdl"Save output to file:
curl -X POST "http://localhost:8000/translate/upload-file" \
-F "file=@example_case.json" \
-F "target_format=asn_ctdl" \
-o output_asn_ctdl.jsonGet the complete field mapping reference:
curl http://localhost:8000/field-mapping | python -m json.toolOr save to file:
curl http://localhost:8000/field-mapping -o field_mappings.jsonReplace example_case.json with your own CASE file:
# Translate your file to IEEE SCD
curl -X POST "http://localhost:8000/translate/upload-file" \
-F "file=@your_case_file.json" \
-F "target_format=ieee_scd" \
-o your_output_ieee.json
# Translate your file to ASN-CTDL
curl -X POST "http://localhost:8000/translate/upload-file" \
-F "file=@your_case_file.json" \
-F "target_format=asn_ctdl" \
-o your_output_asn.jsonThe API returns valid JSON-LD that can be directly uploaded to systems expecting:
- IEEE SCD format: Systems using the Skill Credential vocabulary
- ASN-CTDL format: Systems using the CASE/ASN vocabulary
Output structure:
{
"@context": {
"scd": "https://w3id.org/skill-credential/",
"@vocab": "https://w3id.org/skill-credential/"
},
"@graph": [
{
"@id": "...",
"@type": "scd:CompetencyFramework",
...
},
...
]
}This format is ready for direct import into systems that accept JSON-LD with @context and @graph.
Once the server is running, visit:
- Interactive API Docs:
http://localhost:8000/docs - Alternative Docs:
http://localhost:8000/redoc
These provide interactive forms to test the API directly in your browser.
See example_case.json for a sample CASE document structure.
- CFDocument →
scd:CompetencyFramework - CFItems →
scd:CompetencyDefinition - CFAssociations →
scd:ResourceAssociation - Association Type Mappings:
isChildOf→hasPartprecedes→precedeshasSkillLevel→competencyLevel
- CFDocument →
ceasn:CompetencyFramework - CFItems →
ceasn:Competency - CFAssociations → Direct properties on
ceasn:Competencyobjects - Association Type Mappings:
isChildOf→ceasn:isChildOf(direct property)precedes→ceasn:prerequisiteAlignmenthasSkillLevel→asn:hasProgressionLevel
Both formats preserve identifiers as @id IRIs and output valid JSON-LD documents with @context and @graph.