The API that turns learners’ notes into cards and keeps track of what is due next.
The StudyDeck web app calls this API to save the learner’s rating and schedule the next review.
As a deck grows, working through it in order gives familiar cards the same attention as difficult ones. StudyDeck serves the cards that are due and uses each recall rating to decide when that card should return. It can also index source documents and propose flashcards for the learner to check before importing.
- Decks, notes, and cards. Keep cards grouped by topic and generate one or more cards from a note.
- Spaced repetition. Review due cards with FSRS or SM-2, and persist the next due date and the review log after each rating.
- Import and export. Validate and preview an import before writing it, or export an existing deck.
- Document retrieval. Split source text into chunks, embed them locally, and retrieve relevant excerpts from PostgreSQL with pgvector.
- AI drafting and chat. With a configured chat model, return schema-validated flashcard drafts or answer questions using retrieved context.
- Account and session APIs. Provision learners from JWT claims and integrate with Keycloak for session management.
Install Docker with Compose for the bundled stack, or use JDK 25 and the checked-in Gradle wrapper to run the app on the host. CI uses JDK 25; the Dockerfile builds and runs on JDK 26 while targeting Java 25 bytecode.
git clone https://github.com/diegnghtmr/studydeck-backend.git
cd studydeck-backend
docker compose up -d
curl http://localhost:8080/actuator/healthThe default Compose stack starts PostgreSQL and the API on port 8080 in the dev profile. Use docker compose logs -f backend to follow startup. To run Spring on the host instead, start only postgres with docker compose up -d postgres, then run SPRING_PROFILES_ACTIVE=dev ./gradlew :app:bootRun.
The base stack accepts development JWTs for direct API calls. For browser sign-in, run docker compose -f compose.yaml -f compose.idp.yaml up -d instead. It starts Keycloak at http://localhost:8081 and imports the local studydeck realm. The prod profile requires a real OIDC issuer.
docker compose down stops the stack without removing its named database volume.
The API is a hexagonal monolith. HTTP controllers call application services through input ports; output ports keep JPA, identity, and AI adapters outside the framework-free domain and application layers.
flowchart LR
Web["studydeck-frontend"] -->|"HTTP / JSON"| Rest["Spring REST controllers"]
Web -->|"OIDC sign-in"| IdP["Keycloak"]
Rest -->|"Input ports"| Rules["Use cases and domain rules"]
Rules -->|"Persistence adapters"| DB["PostgreSQL 17 + pgvector"]
Rules -->|"Retrieved context"| AI["Configured chat model"]
Rules -->|"Session management"| IdP
The canonical contract is openapi.yaml, served in development at GET /v3/api-docs.yaml. See the API reference for route and authentication details.
| Layer | Technology |
|---|---|
| HTTP and security | Java 25, Spring Boot 4.1, Spring MVC, OAuth2 Resource Server |
| Persistence | Spring Data JPA, Flyway, PostgreSQL 17, pgvector |
| Retrieval and model adapters | Spring AI, local ONNX embeddings, optional Ollama or OpenAI chat |
| Build and checks | Gradle 9.6.0, JUnit 5, Testcontainers, ArchUnit, Spotless, JaCoCo |
Run with JDK 25 and Docker for the Testcontainers-backed tests:
./gradlew checkCI checks formatting, compiles, runs Testcontainers and ArchUnit, and verifies JaCoCo coverage. Its container job validates Compose and builds the image without pushing it. See the individual Gradle commands for formatting or running targeted tests.
app/src/main/java/com/studydeck/
├── domain/ # Models, scheduling, input and output ports
├── application/ # Framework-free use cases
└── infrastructure/ # HTTP, persistence, identity, AI and Spring wiring
app/src/main/resources/db/migration/ # Flyway migrations, starting with pgvector and core tables
cli/ # Java command-line client
openapi.yaml # API contract
- Backend reference — API contract, development JWTs and local Keycloak, environment variables, Flyway migrations, Docker operations, and Gradle checks.
- Backup and restore runbook — preserve and recover PostgreSQL data.
| Repository | Role |
|---|---|
| studydeck-frontend | Browser app, with a typed Axios client generated from the backend contract |
Released under the MIT License.
