Introduction
The Justina Backend API provides a comprehensive set of RESTful endpoints and WebSocket channels for managing surgical simulations, user authentication, and real-time telemetry streaming. Built with Spring Boot 4.0.2 and Java 21, the API follows clean architecture principles and hexagonal design patterns.Base URL
All REST API endpoints are accessible at:localhost:8080 with your deployed server address.
Authentication
The API uses JWT (JSON Web Token) authentication for secure access control. Authentication is required for most endpoints except public authentication routes (/auth/login and /auth/register).
Authentication Methods
-
Authorization Header (Recommended)
-
HttpOnly Cookie
The login endpoint automatically sets a secure
jwt-tokencookie that can be used for subsequent requests from web clients.
WebSocket connections require JWT authentication via query parameter:
?token=<your-jwt-token>Available Endpoints
Authentication
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST | /auth/login | Authenticate user and receive JWT | No |
POST | /auth/register | Register new surgeon account | No |
GET | /auth/me | Get current authenticated user info | Yes |
Surgery Management
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET | /surgeries/{id}/trajectory | Retrieve surgery trajectory data | Yes (SURGEON or AI) |
POST | /surgeries/{id}/analysis | Submit AI analysis for surgery | Yes (AI only) |
WebSocket Channels
Real-time communication is handled through WebSocket connections:| Endpoint | Purpose | Role Required |
|---|---|---|
/ws/simulation | Stream surgical telemetry data | SURGEON |
/ws/ai | Receive surgery completion notifications | AI |
Role-Based Access Control
The API implements role-based authorization with two primary roles:- ROLE_SURGEON (
ROLE_CIRUJANO) - Surgeons who perform simulations - ROLE_AI (
ROLE_IA) - AI systems that analyze surgical data
Response Format
All API responses use JSON format with appropriate HTTP status codes:200 OK- Successful request201 Created- Resource created successfully204 No Content- Successful request with no response body400 Bad Request- Invalid request data or validation errors401 Unauthorized- Missing or invalid authentication403 Forbidden- Insufficient permissions404 Not Found- Resource not found500 Internal Server Error- Server-side error
API Documentation
Interactive API documentation is available via Swagger UI:- JSON:
http://localhost:8080/v3/api-docs - YAML:
http://localhost:8080/v3/api-docs.yaml
Rate Limiting
Currently, the API does not implement rate limiting. However, WebSocket connections are limited to one active session per surgeon for the/ws/simulation endpoint.
CORS Policy
Cross-Origin Resource Sharing (CORS) is enabled for all origins (*) to support frontend applications. In production, configure specific allowed origins in the security settings.
Next Steps
Authentication
Learn about JWT authentication flow and token management
Auth Endpoints
Detailed documentation for login, register, and user endpoints
Surgery Endpoints
Access trajectory data and submit AI analysis
WebSocket Overview
Real-time communication setup and authentication