Skip to content

Aniket762/ch-backend-ms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CH – Backend Microservice

A Spring Boot–based backend service implementing a custom Transformer-decoder chatbot for healthcare insurance guideline validation.

Use Case
Doctors, clinics, and hospital staff query the system to verify whether a medical procedure aligns with published insurance coverage guidelines (UnitedHealthcare), reducing claim denials.


📁 Project Folder Structure

aniket762.combinehealth
├── api/
│   ├── TrainController.java
│   ├── ChatController.java
│   └── StatusController.java
│
├── service/
│   ├── ModelService.java
│   ├── TrainingService.java
│   └── InferenceService.java
│
├── nn/
│   ├── Config.java
│   ├── Matrix.java
│   ├── MatrixOps.java
│   ├── Embedding.java
│   ├── Attention.java
│   ├── MultiHeadAttention.java
│   ├── FeedForward.java
│   ├── DecoderBlock.java
│   └── TransformerDecoder.java
│
├── training/
│   ├── Trainer.java
│   ├── Loss.java
│   └── Optimizer.java
│
├── tokenizer/
│   ├── Tokenizer.java
│   └── BPETrainer.java
│
├── rag/
│   ├── DocumentChunk.java
│   ├── SimpleEmbedder.java
│   ├── VectorStore.java
│   └── Retriever.java
│
├── store/
│   ├── CheckpointManager.java
│   └── RagStore.java
│
├── startup/
│   └── StartupTrainer.java
│
├── util/
│   └── Utils.java
│
└── CombineHealthApplication.java

🧠 Model Design (Transformer Decoder)

Input Tokens
   ↓
Token Embedding + Positional Encoding
   ↓
N × Decoder Block
   ├── Masked Multi-Head Self Attention
   ├── Add & LayerNorm
   ├── Feed Forward Network
   ├── Add & LayerNorm
   ↓
Linear Projection
   ↓
Softmax (Vocabulary Size)

🏗️ High-Level Architecture (HLD)

┌────────────────────────┐
│        Client          │
│ (Web / Postman / UI)   │
└───────────┬────────────┘
            │ REST API
            ▼
┌────────────────────────┐
│ Spring Boot Controllers│
│  ├── /train            │
│  ├── /status           │
│  └── /ask              │
└───────────┬────────────┘
            ▼
┌──────────────────────────────┐
│        ModelService          │
│  (Training + Inference)      │
│                              │
│  ┌────────────────────────┐ │
│  │ Tokenizer (BPE)        │ │
│  └───────────┬────────────┘ │
│              ▼              │
│  ┌────────────────────────┐ │
│  │ Transformer Decoder    │ │
│  │ (Neural Core)          │ │
│  └───────────┬────────────┘ │
│              ▼              │
│  ┌────────────────────────┐ │
│  │ Trainer / Optimizer    │ │
│  └────────────────────────┘ │
│                              │
│  ┌────────────────────────┐ │
│  │ RAG Pipeline           │ │
│  │ (VectorStore + Search) │ │
│  └────────────────────────┘ │
└──────────────────────────────┘

⚙️ Low-Level Architecture (LLD – Decoder Internals)

Input Tokens (int[])
      │
      ▼
┌────────────────────────┐
│ Token Embedding        │
│ + Positional Encoding │
└───────────┬────────────┘
            ▼
┌────────────────────────┐
│ Decoder Block × N      │
│                        │
│ ┌───────────────────┐ │
│ │ Masked Self-Attn  │ │
│ │ (Causal)          │ │
│ └─────────┬─────────┘ │
│           ▼           │
│ ┌───────────────────┐ │
│ │ Add + LayerNorm   │ │
│ └─────────┬─────────┘ │
│           ▼           │
│ ┌───────────────────┐ │
│ │ Feed Forward NN   │ │
│ │ Linear → ReLU →   │ │
│ │ Linear            │ │
│ └─────────┬─────────┘ │
│           ▼           │
│ ┌───────────────────┐ │
│ │ Add + LayerNorm   │ │
│ └───────────────────┘ │
└───────────┬────────────┘
            ▼
┌────────────────────────┐
│ Linear Projection      │
│ → Vocabulary Size     │
└───────────┬────────────┘
            ▼
      Token Probabilities

🔌 API Endpoints

The backend exposes REST APIs for model training, status monitoring, and chatbot inference. All endpoints are documented via Swagger (OpenAPI).

🤖 Chat API

POST /api/agent/chat
Accepts a user query and returns a model-generated response using the trained Transformer decoder and RAG pipeline.

  • Request Body: Plain text question
  • Response: Answer string

🧠 Model Management API

POST /api/model/train
Triggers model training from an external guideline source.

  • Request Body: { "url": "<guideline-article-url>" }
  • Response: { "status": "training_started" }

GET /api/model/status
Returns the current training state of the model.

  • Response: { "status": "READY | TRAINING | FAILED", "error": "" }

Refer to the Swagger UI screenshot below for interactive API exploration.

image

💪CURL for Query -> Response

image

About

Combine Health Backend Service + Rest Endpoint

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages