KHEIREDDINE RIAHI

Practical case: design a credit management platform with the C4 model

AI ARCHITECTURE · REFERENCE DOCUMENT

Summary

1. From generative AI to agentic AI

2. The building blocks of an agentic architecture

3. Practical case: banking credit application platform

4. Embeddings, chunking and RAG

5. C4 architecture: from context to code

6. Details of containers and components

7. Development workspace: hardware and software

8. Starter kit and organization of sources

9. Start-up, validation and implementation trajectory

10. Security, reliability and limits of the proposal

11. Gallery of images generated during the session

1. From generative AI to agentic AI

1.1 Generative AI

A generative AI produces content from an instruction and a context: text, summary, code, image or response. It mainly responds to a request, without necessarily leading a series of business actions itself.

1.2 Agentic AI

An agentic AI is a system in which one or more agents pursue a goal, break down the work into steps, choose tools, observe the results and adapt their execution. The language model contributes to reasoning and production, while the surrounding software controls workflows, permissions, data, and side effects.

Dimension

Generative AI

Agentic AI

Purpose

Generate a response or content

Achieve a goal through steps and actions

Interaction

Often query → response

Plan → act → observe → adjust loop

Tools

Optional, usually called on demand

Workflow integrated and governed

Status

Conversation context

Task status, history, checkpoints and results

Credit example

Summarize a file

Collect documents, analyze, query services and prepare a recommendation

1.3 Operating loop

Receive a business objective or event.

Analyze the context and determine the necessary steps.

Select an authorized agent or tool.

Execute the action and retrieve its result.

Update workflow status and decide what to do next.

Terminate, request human validation, or report an error.

Point of vigilance: the agent is not an autonomous decision-maker without limits. Business policies, access rights, confidence thresholds, human validations and deterministic controls remain the responsibility of the application.

2. The bricks of an agentic architecture

Brick

Role in the platform

LLM

Interpretation, assisted reasoning, structured extraction and generation of summaries.

Orchestrator

Controls steps, transitions, agents and restarts.

Specialized agents

Perform targeted tasks: client, documents, financial analysis, risk, compliance.

Memory / state

Retains useful context and execution state; does not replace the business database.

Tools

Allow business services to be called in a controlled manner.

RAG

Retrieves relevant passages in a documentary corpus to contextualize the responses.

Event broker

Decouples processing and transports asynchronous events.

Observability

Tracks traces, metrics, logs, costs, errors and workflow decisions.

2.1 Role of LangGraph

LangGraph is used as an agentic workflow engine. It allows you to represent steps as nodes, define transitions, transport shared state and resume execution from checkpoints. Technical checkpoints should not be confused with the official status of a credit file.

2.2 Role of MCP

The Model Context Protocol standardizes the exposure of tools and resources to an agentic client. In the case studied, the MCP Tool Server exposes operations such as customer consultation, simulation, part recovery or rule consultation. MCP does not replace REST or Kafka: it organizes the agent's access to the tools.

2.3 REST, Kafka and MCP: do not confuse them

Mechanism

Mode

Usage

REST / HTTPS

Synchronous, request-response

The portal submits a request to the Credit API.

Kafka

Asynchronous, event-driven

Credit API publishes a request; the orchestrator consumes it.

MCP

Standardized tool call

The agent requests the MCP Server to perform an authorized business operation.

3. Practical case: banking platform for credit applications

The common theme of the session is a platform for managing and preparing credit applications. The client or advisor submits a request; the platform orchestrates AI-assisted analytics and interrogates existing banking systems.

3.1 External actors and systems

Individual or professional client: submits a request and consults their file.

Bank advisor: supports the client, checks the elements and participates in validation.

IS administrator: governs agents, models, tools and configurations.

CRM: Provides customer relationship information.

Core Banking: Provides financial data and account information.

GED / ECM: contains supporting documents and documents.

Rules repository: contains credit policies and compliance rules.

LLM Provider: provides the language model, in the cloud or on private infrastructure.

3.2 End-to-end scenario

The client enters their request in the React Web Portal.

The portal calls the Spring Boot Credit API in REST/HTTPS.

The Credit API validates the data, logs the request, and publishes a Kafka event.

The Agent Orchestrator Python/LangGraph consumes the event and starts the workflow.

Specialized agents collect and analyze the necessary information.

The orchestrator calls the tools exposed by the MCP Tool Server.

The MCP Tool Server interacts with banking services via secure APIs.

The RAG retrieves useful passages in indexed policies and documents.

Results are consolidated; a recommendation is prepared and human validation may be required.

The result is returned to the Credit API, then the file is updated.

The platform assists in the analysis and preparation of the file. It should not entrust the final credit decision or regulatory calculation to an LLM without explicit business rules, traceability and appropriate control.

4. Embeddings, chunking and RAG

4.1 Chunking

Chunking consists of cutting a document into smaller, usable fragments. A credit policy document can be separated by headings, sections, paragraphs or windows of controlled size. Metadata (source, date, version, page, document type) must be preserved.

4.2 Embeddings

An embedding is a digital vector representation of a text. Texts close in meaning can have close vectors in vector space. These vectors facilitate semantic search, but are neither summaries nor documentary fragments.

Notion

Question to which it answers

Example

Chunking

How to split the content?

Separate a credit policy into sections.

Embedding

How to represent the meaning?

Transform each section into a digital vector.

Vector store

Where to find the vectors?

Store vectors and metadata in pgvector.

RAG

How to provide reliable context to the LLM?

Find the relevant passages and include them in the prompt.

4.3 Envisioned RAG Pipeline

EDM/PDF/DOCX
|
Text Extraction/OCR
|
Metadata Cleansing and Enrichment
|
Chunking
|
Embeddings Model
|
PostgreSQL + pgvector (or dedicated vector store)
|
Semantic search at the time of the question
|
Selected passages + question
|
LLM: contextualized answer with references

The RAG is a document processing chain. MCP can provide the agent with a RAG search tool, but MCP and RAG are two separate concepts.

5. C4 architecture: from context to code

The C4 model describes a software architecture with several zoom levels. In this session, the diagrams were built around the Agentic Credit platform.

Level

View

What we represent

C1 — Context

System context

The system studied, the users and external systems.

C2 — Container

Application containers

Deployable applications or services, their technologies and their exchanges.

C3 — Component

Components

The internal blocks of a container and their responsibilities.

C4 — Code

Code

Classes, interfaces, methods and relationships, usually for a focused part.

In C4, the word “container” designates an executable/deployable application unit in the C4 sense; it does not necessarily mean a Docker container.

5.1 C1 — Context

The C1 diagram places Agentic Credit at the center. It shows clients, advisors and administrators as well as CRM, Core Banking, EDM, rules repository and LLM provider.

5.2 C2 — Container

Container

Technology

Responsibility

Web Portal

React

User interaction, creation and tracking of requests.

Credit API

Spring Boot

Request management, business validations and data access.

Agent Orchestrator

Python + LangGraph

Agent orchestration and AI workflows.

MCP Tool Server

Spring Boot + MCP

Controlled exposure of business tools.

Event Broker

Apache Kafka

Asynchronous exchanges by events.

Credit Database

PostgreSQL

Business data, tracking and persistence.

5.3 C3 — Component

The C3 of the Agent Orchestrator has been detailed around three families:

Orchestration: Workflow Controller, Graph Engine, Supervisor, State Manager, Checkpointer and Event Handler.

Specialized agents: Customer/Identity Agent, Document Agent, Financial Agent, Risk Agent, Compliance Agent and Decision Agent.

Shared Services: LLM Client, MCP Client, RAG Service, Vector Store Client, Event Publisher and Monitoring.

A second C3 details the Credit API: Controller layer, Application/Service, Domain, Repository, Event Publisher, Event Consumer and Security Layer.

5.4 C4 — Code

The proposed code diagram focuses on the orchestrator. In particular, it presents the classes CreditWorkflow, WorkflowState, SupervisorAgent, CustomerAgent, DocumentAgent, FinancialAgent, RiskAgent, ComplianceAgent, DecisionAgent, LLMClient, MCPClient, RAGService, CheckpointRepository, EventPublisher, CreditApiClient and HumanApprovalService.

CreditWorkflow
├── WorkflowState
├── SupervisorAgent
│ ├── CustomerAgent
│ ├── DocumentAgent
│ ├── FinancialAgent
│ ├── RiskAgent
│ ├── ComplianceAgent
│ └── DecisionAgent
├── CheckpointRepository
├── EventPublisher
└── CreditApiClient

Agents -> LLMClient / MCPClient / RAGService
DecisionAgent -> HumanApprovalService

These names represent a design proposal, not classes imposed by LangGraph. The C4 Code diagram is useful when zooming in on the code provides real value; it is not necessary to document every class of every service.

5.5 Don't confuse C4 Code and deployment view

One of the first infographics generated placed Kubernetes in a section called C4 Code. This representation is useful as an infrastructure/deployment view, but it does not constitute a C4 Code diagram in the strict sense. The C4 Code describes the structure of the code; Kubernetes describes where and how containers run.

6. Details of containers and components

6.1 Agent Orchestrator — Python / LangGraph

Internal component

Responsibility

Workflow Controller

Starts, controls and terminates workflows.

Supervisor Agent

Schedules tasks and coordinates specialist agents.

Graph Engine

Runs LangGraph nodes and transitions.

State Manager

Manages the shared state of the workflow.

Checkpoint Repository

Saves and reloads checkpoints.

MCP Client

Calls the MCP Tool Server tools.

LLM Client

Calls the language model.

RAG Service

Researches and prepares documentary extracts.

Event Handler / Publisher

Consumes and publishes Kafka events.

6.2 Credit API — Spring Boot

Controller Layer: REST endpoints and HTTP request validation.

Application Layer: orchestration of use cases and application rules.

Domain Layer: business objects and deterministic rules for managing the file.

Repository Layer: persistence of business data.

Event Publisher: Publish events to Kafka.

Event Consumer: processing analysis results and updating the file.

Security Layer: authentication, authorization and access control.

6.3 MCP Tool Server — Spring Boot + MCP

The server brings together a tool registry and adapters to the CRM, Core Banking, EDM and rules repository APIs. Each tool should have a clear contract, parameter validation, explicit rights, rate limits, and logging.

6.4 Kafka and PostgreSQL

Kafka transports events such as CreditApplicationSubmitted, DocumentReceived, ValidationCompleted or CreditAnalysisCompleted. PostgreSQL preserves business data; pgvector can host the embeddings of the documentary corpus. It is recommended to logically isolate business schemas, RAG data and checkpoints from the orchestrator.

7. Development workspace: hardware and software

7.1 Hardware

Resource

Practical minimum

Recommended

CPU

4 cores

8 cores or more

RAM

16 GB

32 GB

Storage

50 GB free

100 GB Free SSD

GPU

Not required with cloud LLM

Useful for local model

32 GB RAM recommendation is intended to run multiple Docker services, IDE, browser and testing tools simultaneously. A GPU is not necessary if the LLM provider is remote.

7.2 Software

Tool

Proposal reference version

Usage

Docker Desktop / Engine + Compose V2

Recent version

Local execution of services.

Java JDK

21

Spring Boot Applications.

Maven

3.9+

Java compilation and dependencies.

Python

3.12

Agent Orchestrator.

Node.js

22 LTS

Frontend React.

Git

2.x

Source code management.

VS Code / IntelliJ IDEA

Recent version

Development and debugging.

Postman / Bruno

Recent version

REST and MCP tests according to the client.

7.3 Proposed local ports

Service

Local port

Access

React / Web Portal

3000

http://localhost:3000

Credit API

8080

http://localhost:8080

Agent Orchestrator

8000

http://localhost:8000/health

MCP Tool Server

8081

http://localhost:8081

Kafka

9092

localhost:9092

PostgreSQL

5432

localhost:5432

Ports and versions are reference values for the starter kit. They must be checked and adjusted according to the versions of the dependencies and the constraints of the position.

8. Starter kit and organization of sources

A starter workspace has been generated in the form of a ZIP archive. It contains 23 core files divided between the frontend, Java services, Python orchestrator and local infrastructure.

agentic-credit-workspace/
├── frontend/
│ ├── src.jsx
│ ├── style.css
│ ├── package.json
│ └── Dockerfile
├── credit-api/
│ ├── src/main/java/
│ ├── src/main/resources/application.yml
│ ├── pom.xml
│ └── Dockerfile
├── agent-orchestrator/
│ ├── app/main.py
│ ├── requirements.txt
│ └── Dockerfile
├── mcp-tool-server/
│ ├── src/main/java/
│ ├── src/main/resources/application.yml
│ ├── pom.xml
│ └── Dockerfile
├── infra/postgres/init.sql
├── docker-compose.yml
├── .env.example
└── README.md

8.1 What the skeleton contains

Module

Elements provided

Frontend

React credit request form and REST call to the Credit API.

Credit API

Spring Boot project, Kafka submission and publishing endpoint.

Agent Orchestrator

FastAPI API, simple LangGraph and demo nodes.

MCP Tool Server

Spring AI MCP Project and Loan Indicative Simulation Tool.

Infrastructure

Docker Compose, Kafka, PostgreSQL/pgvector and SQL init script.

8.2 Environment Configuration

POSTGRES_DB=agentic_credit
POSTGRES_USER=credit
POSTGRES_PASSWORD=change_me_local_only
KAFKA_BOOTSTRAP_SERVERS=kafka:9092
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4.1-mini
CREDIT_API_URL=http://credit-api:8080
MCP_SERVER_URL=http://mcp-tool-server:8081

The .env.example file is a template. You have to copy it to .env and replace the local values. Never version real secrets.

8.3 Local boot

cp .env.example .env
docker compose up --build
docker compose ps

curl http://localhost:8000/health
curl http://localhost:8080/actuator/health

The frontend is accessible on localhost:3000. The Credit API exposes the submission endpoint. The orchestrator exposes a demo/analysis endpoint. Kafka and PostgreSQL can be accessed on the specified local ports.

9. Start-up, validation and completion trajectory

Phase

Works

Exit criteria

1. Infrastructure

Docker Compose, PostgreSQL, Kafka, networks and healthchecks.

Services started and reachable.

2. Business backend

Credit API, schema, validation, persistence, Kafka publication.

A request is registered and an event is published.

3. AI Orchestration

LangGraph, state, agents, LLM and checkpoints.

A demo workflow is running and can be traced.

4. MCP

MCP server, business tools, MCP client and security.

An agent calls a business tool and uses the result.

5. RAG

Extraction, OCR, chunking, embeddings, pgvector and retrieval.

A question finds the good documentary passages.

6. Industrialization

Testing, security, observability, CI/CD and Kubernetes.

Reproducible and controlled deployment.

9.1 Tests to be planned

Java unit tests with JUnit and Python tests with pytest.

REST API testing with Postman, Bruno or automated testing.

Kafka event contract testing and schema compatibility.

Integration tests with real PostgreSQL and Kafka in local environment.

LangGraph workflow tests: nominal path, errors, recovery and human validation.

MCP tests: tool discovery, parameter validation, authorizations and errors.

RAG tests: search relevance, document freshness and source traceability.

10. Security, reliability and limits of the proposal

10.1 Security principles

Do not use real banking data in the educational workspace.

Protect APIs with authentication and authorization; apply the principle of least privilege.

Secure network connections, secrets, logs and personal data.

Control each MCP tool: calling identity, scope, parameters, quotas and audit.

Trace LLM and tool calls without exposing sensitive data in logs.

Implement human validations for sensitive decisions.

10.2 Event-driven reliability

When the database recording and Kafka publication must be consistent, the Transactional Outbox pattern is recommended. Consumers must be idempotent; transient errors should be handled by retry with bounds, then Dead Letter Topic if necessary. Events must have correlation IDs and schema versions.

10.3 What remains to be completed in the starter kit

Effective Kafka consumer in the orchestrator and publication of the workflow result.

Actual integration of the MCP Python client with the appropriate MCP SDK.

Complete business persistence and transactional event management.

Operational RAG: document ingestion, embeddings, search and citations.

Sustainable LangGraph checkpoint management and separation of business states.

Authentication, authorization, secrets management, auditing and observability.

Automated testing, error handling, retries, DLT and event contracts.

The generated code is an educational starting point. Library versions, Docker images, Spring AI/MCP configurations and compilation should be verified in the target environment before use. It does not constitute a production system.

11. Gallery of images generated during the session

The images below show the visual representations produced during the exchange. They are kept as discussion supports. The labels present in a generated image may include approximations; the descriptions and architectural distinctions in this document take precedence in the event of any discrepancy.

Image 1 — First overview: context, containers and components of the Agentic Credit platform.

Image 2 — Global view C1 to C4 with a Kubernetes deployment representation.

Image 3 — Detail of the internal components of the Agent Orchestrator with LangGraph.

Image 4 — LangGraph component diagram: agents, MCP Client, LLM Client, memory and events.

Image 5 — Joint detailed view of Agent Orchestrator, MCP Tool Server and Credit API.

Conclusion

The session moved the discussion from a discovery of agentic AI to a concrete application architecture: a credit platform where business services remain controlled by deterministic APIs, while LangGraph orchestrates specialized agents, MCP provides controlled access to tools, Kafka ensures asynchronous exchanges and RAG provides the documentary context.

The recommended implementation approach is incremental: first stabilize the infrastructure and the Credit API, then introduce Kafka, then LangGraph and MCP, add the RAG and finally industrialize everything on Kubernetes with security, testing, observability and governance.