Skip to content

Sen2pi/TCMTreino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

37 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TCM Treino Logo

TCM Treino – Treasury & Collateral Management

Spring Boot React Kafka Docker PostgreSQL License: MIT

A modern, enterprise-grade platform for managing Treasury and Collateral operations, built with Spring Boot, React, Kafka, and PostgreSQL.


Table of Contents


πŸš€ Key Features

πŸ’° Treasury Management

  • Full CRUD for treasury accounts (create, update, delete, view)
  • Advanced filtering by status, type, currency, bank
  • Fund transfers between accounts with validation
  • Real-time balance and available balance tracking
  • Low balance alerts and summary reports

πŸ›‘οΈ Collateral Management

  • Full CRUD for collaterals (bonds, stocks, real estate, etc.)
  • Dynamic valuation, haircut calculation, eligibility engine
  • Expiry monitoring, risk analytics, and high-risk detection
  • Advanced search and reporting (by type, rating, currency, etc.)
  • Real-time eligible value and risk exposure calculation

πŸ‘€ User & Security

  • JWT authentication with role-based access (ADMIN, TREASURY, COLLATERAL, USER)
  • Registration, login, logout, and profile endpoints
  • Password encryption (BCrypt)
  • User enable/disable, role management, and audit events

πŸ“Š Analytics & Dashboard

  • Modern dashboard with KPIs (total balance, eligible collaterals, etc.)
  • Interactive charts (bar, pie) for account and collateral distribution
  • Real-time updates via Kafka event-driven architecture

πŸ›°οΈ Event-Driven & Integrations

  • Apache Kafka for event streaming (user, treasury, collateral, audit, notification)
  • Microservices-ready modular backend
  • RESTful API with CORS and rate limiting
  • Docker Compose for local development (PostgreSQL, Kafka, Zookeeper)

πŸ› οΈ Technology Stack

Backend

  • Spring Boot 3.2+ (Docs)
  • Spring Security (Docs)
  • Spring Data JPA (Docs)
  • Apache Kafka (Docs)
  • JWT (jjwt) (Docs)
  • PostgreSQL (Docs)
  • H2 Database (for dev/testing)
  • Lombok (Docs)

Frontend

DevOps & Tooling


πŸ—οΈ System Architecture

graph TD
    subgraph "Frontend"
        A[React SPA] --> B[MUI Components]
        B --> C[Axios HTTP Client]
    end
    subgraph "API Gateway"
        D[Spring Boot API]
        E[JWT Auth]
        F[CORS]
    end
    subgraph "Business Layer"
        G[Treasury Service]
        H[Collateral Service]
        I[User Service]
        J[Risk Engine]
    end
    subgraph "Data Layer"
        K[JPA Repositories]
        L[PostgreSQL]
    end
    subgraph "Messaging"
        M[Kafka Producer]
        N[Kafka Consumer]
        O[Event Store]
    end
    C --> D
    D --> E
    D --> F
    D --> G
    D --> H
    G --> K
    H --> K
    K --> L
    G --> M
    H --> M
    N --> J
    M --> O
Loading

πŸ“¦ Project Structure

TCMTreino/
β”œβ”€β”€ backend/           # Spring Boot API (Java)
β”‚   β”œβ”€β”€ src/main/java/com/treasury/kpstreasury/
β”‚   β”‚   β”œβ”€β”€ controllers/   # REST endpoints
β”‚   β”‚   β”œβ”€β”€ services/      # Business logic
β”‚   β”‚   β”œβ”€β”€ repositories/  # Data access
β”‚   β”‚   β”œβ”€β”€ models/        # Entities & DTOs
β”‚   β”‚   β”œβ”€β”€ config/        # Security, Kafka, JWT
β”‚   β”‚   β”œβ”€β”€ events/        # Kafka event models
β”‚   β”‚   └── utils/         # Mappers
β”‚   β”œβ”€β”€ src/main/resources/
β”‚   β”‚   └── application.properties
β”‚   └── pom.xml
β”œβ”€β”€ frontend/          # React SPA (JS)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # UI components
β”‚   β”‚   β”œβ”€β”€ pages/         # Main pages (Dashboard, Treasury, Collateral, Auth)
β”‚   β”‚   β”œβ”€β”€ services/      # API clients
β”‚   β”‚   β”œβ”€β”€ contexts/      # Auth context
β”‚   β”‚   └── theme/         # MUI theme
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yml # Local dev stack (Kafka, Postgres)
└── README.md

⚑ Quick Start Guide

Prerequisites

1. Start Infrastructure (Kafka, Postgres)

docker-compose up -d

2. Start Backend (Spring Boot)

cd backend
mvn clean install
mvn spring-boot:run

3. Start Frontend (React)

cd frontend
npm install
npm start

πŸ›‘οΈ API Overview

Authentication

  • POST /api/auth/login – User login (JWT)
  • POST /api/auth/register – User registration
  • POST /api/auth/logout – Logout
  • GET /api/auth/me – Get current user
  • GET /api/auth/validate-token – Validate JWT

Treasury

  • GET /api/treasury – List all accounts
  • POST /api/treasury – Create account
  • PUT /api/treasury/{id} – Update account
  • DELETE /api/treasury/{id} – Delete account
  • POST /api/treasury/transfer – Transfer funds
  • GET /api/treasury/reports/total-balance – Total balance by currency/status
  • ...and more (see code/docs)

Collateral

  • GET /api/collateral – List all collaterals
  • POST /api/collateral – Create collateral
  • PUT /api/collateral/{id} – Update collateral
  • DELETE /api/collateral/{id} – Delete collateral
  • GET /api/collateral/reports/total-eligible-value – Total eligible value
  • ...and more (see code/docs)

Users

  • GET /api/users – List users (admin)
  • PUT /api/users/{id} – Update user
  • PUT /api/users/{id}/change-password – Change password
  • ...and more

Full API details: See Spring Boot Controller code or Swagger UI if enabled.


πŸ–₯️ Frontend Overview

  • Login/Register: Secure authentication, registration, and JWT session management
  • Dashboard: KPIs, charts, and quick stats for treasury and collateral
  • Treasury: Manage accounts, transfer funds, view balances, filter/search
  • Collateral: Manage collaterals, eligibility, risk, and reporting
  • Responsive UI: Modern Material-UI design, dark/light mode, animated transitions

πŸ§ͺ Testing

Backend

cd backend
mvn test

Frontend

cd frontend
npm test

🀝 Contributing

We welcome contributions! Please fork the repo, create a feature branch, and submit a pull request.


πŸ“„ License

This project is licensed under the MIT License. See LICENSE for details.


Built with passion for modern financial systems.