# codecortex/microservicecompose architecture

> Architecture diagram of the GitHub repository codecortex/microservicecompose, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codecortex/microservicecompose
- Repository: https://github.com/codecortex/microservicecompose

## Overview

This repository documents a containerized expense-management microservices system. Clients enter through Kong, which routes requests to authentication, user, expense, or data-science services; signup and AI-extracted expenses then flow asynchronously through Kafka to their respective services. The README also documents service-specific MySQL databases, Redis caching, and a custom Kong authentication plugin. Application-service source is absent from the tree, so those nodes have no source path; their relationships reflect documented flows, not inspected implementations.

Main entry points: [`kong.yml`](https://github.com/codecortex/microservicecompose/blob/main/kong.yml) (Kong gateway), [`docker-compose.yml`](https://github.com/codecortex/microservicecompose/blob/main/docker-compose.yml) (Kafka), [`mysql/init.sql`](https://github.com/codecortex/microservicecompose/blob/main/mysql/init.sql) (MySQL), [`kong/plugins/custom-auth/handler.lua`](https://github.com/codecortex/microservicecompose/blob/main/kong/plugins/custom-auth/handler.lua) (Custom auth plugin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Gateway and auth"]
  node_kong["Kong gateway<br/>[kong.yml]"]
  node_auth_plugin["Custom auth plugin<br/>[handler.lua]"]
  node_auth["Auth service"]
end

subgraph group_business["Business services"]
  node_user["User service"]
  node_expense["Expense service"]
end

subgraph group_infra["Messaging and data"]
  node_kafka["Kafka<br/>[docker-compose.yml]"]
  node_mysql[("MySQL<br/>[init.sql]")]
  node_redis[("Redis<br/>[docker-compose.yml]")]
end

subgraph group_ai["AI extraction"]
  node_ds["Data science service"]
end

node_client(("Client"))
node_groq["Groq LLM"]

node_client -->|"sends requests"| node_kong
node_kong -->|"invokes auth"| node_auth_plugin
node_kong -->|"routes auth"| node_auth
node_kong -->|"routes user"| node_user
node_kong -->|"routes expense"| node_expense
node_kong -->|"routes messages"| node_ds
node_auth -->|"publishes users"| node_kafka
node_kafka -->|"delivers users"| node_user
node_ds -->|"extracts expenses"| node_groq
node_ds -->|"publishes expenses"| node_kafka
node_kafka -->|"delivers expenses"| node_expense
node_auth -->|"stores credentials"| node_mysql
node_user -->|"stores profiles"| node_mysql
node_expense -->|"stores expenses"| node_mysql
node_user -->|"caches users"| node_redis
node_expense -->|"caches expenses"| node_redis
node_ds -->|"caches results"| node_redis

click node_kong "https://github.com/codecortex/microservicecompose/blob/main/kong.yml"
click node_auth_plugin "https://github.com/codecortex/microservicecompose/blob/main/kong/plugins/custom-auth/handler.lua"
click node_kafka "https://github.com/codecortex/microservicecompose/blob/main/docker-compose.yml"
click node_mysql "https://github.com/codecortex/microservicecompose/blob/main/mysql/init.sql"
click node_redis "https://github.com/codecortex/microservicecompose/blob/main/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_kong,node_auth_plugin,node_auth,node_client toneBlue
class node_user,node_expense toneAmber
class node_kafka,node_mysql,node_redis toneMint
class node_ds toneRose
class node_groq toneIndigo
```

## Components

### Gateway and auth

- [Kong gateway](https://github.com/codecortex/microservicecompose/blob/main/kong.yml): `kong.yml`
- [Custom auth plugin](https://github.com/codecortex/microservicecompose/blob/main/kong/plugins/custom-auth/handler.lua): `kong/plugins/custom-auth/handler.lua`
- **Auth service**

### Business services

- **User service**
- **Expense service**

### Messaging and data

- [Kafka](https://github.com/codecortex/microservicecompose/blob/main/docker-compose.yml): `docker-compose.yml`
- [MySQL](https://github.com/codecortex/microservicecompose/blob/main/mysql/init.sql): `mysql/init.sql`
- [Redis](https://github.com/codecortex/microservicecompose/blob/main/docker-compose.yml): `docker-compose.yml`

### AI extraction

- **Data science service**

### Other components

- **Client**
- **Groq LLM**

## Connections

- Client → Kong gateway: sends requests
- Kong gateway → Custom auth plugin: invokes auth
- Kong gateway → Auth service: routes auth
- Kong gateway → User service: routes user
- Kong gateway → Expense service: routes expense
- Kong gateway → Data science service: routes messages
- Auth service → Kafka: publishes users
- Kafka → User service: delivers users
- Data science service → Groq LLM: extracts expenses
- Data science service → Kafka: publishes expenses
- Kafka → Expense service: delivers expenses
- Auth service → MySQL: stores credentials
- User service → MySQL: stores profiles
- Expense service → MySQL: stores expenses
- User service → Redis: caches users
- Expense service → Redis: caches expenses
- Data science service → Redis: caches results
