# pierrick74/carflow-user-service architecture

> Architecture diagram of the GitHub repository pierrick74/carflow-user-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pierrick74/carflow-user-service
- Repository: https://github.com/pierrick74/carflow-user-service

## Overview

##### Project type and purpose
- This is a single-purpose backend microservice—CarFlow User Service—built with Spring Boot. It handles user registration, authentication, profile CRUD and JWT token management as part of a larger CarFlow ecosystem.
- It is not a full-stack app; it is an identity/auth service that likely communicates with other CarFlow services (e.g., vehicle management, billing).

##### File structure
- Top-level: pom.xml, mvnw scripts, .gitignore.
- src/main/java/com/PulseLabs/carflow_user_service:
- web/controller: UserController (REST endpoints).
- services: UserService, LicenseService (business logic, external‐service calls).
- db: UserRepository (JPA repository).
- model: User, UserDTO.
- Error: custom exceptions + ErrorHandler (global exception mapping).
- CarflowUserServiceApplication.java (Spring Boot bootstrap).
- src/main/resources: application.properties (DB URL, JWT secrets, Spring Security settings).
- src/test: basic smoke test.

##### README
- Core responsibilities: register/login, profile management, JWT issuance & validation.
- Tech stack: Java 21+, Spring Boot 3.5.7, Spring Security, JPA (MySQL/PostgreSQL), JJWT.
- Main REST endpoints listed.
- Mentions external communications (to-be-documented)—you already see a LicenseService component.

##### Detail and granularity
- Flows: “Controller → Service (validate credentials) → Security Component (JWT creation) → Response”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers and Components
    subgraph "Client"
        A["Clients (Web/Mobile/Other Services)"]
    end

    subgraph "API Layer"
        direction TB
        UC["UserController"]:::internal
    end

    subgraph "Service Layer"
        direction TB
        US["UserService"]:::internal
        LS["LicenseService"]:::internal
    end

    subgraph "Persistence Layer"
        direction TB
        UR["UserRepository"]:::internal
        DB["User DB"]:::persistent
    end

    subgraph "Security Module"
        direction TB
        SM["JWT Generator / Validator"]:::security
    end

    subgraph "Error Handling"
        direction TB
        EH["ErrorHandler"]:::security
    end

    subgraph "External Dependencies"
        direction TB
        EL["Driver-License Service"]:::external
    end

    %% Connections
    A -->|HTTP POST/GET/PUT/DELETE /api/users| UC
    UC -->|calls| SM
    UC -->|invokes| US
    SM -->|validates/generates JWT| US
    US -->|calls| LS
    LS -->|REST call to license-api| EL
    US -->|CRUD operations| UR
    UR -->|JPA queries| DB
    UC -->|errors| EH
    US -->|errors| EH
    LS -->|errors| EH

    %% Click Events
    click UC "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/web/controller/UserController.java"
    click US "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/services/UserService.java"
    click LS "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/services/LicenseService.java"
    click UR "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/db/UserRepository.java"
    click DB "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/resources/application.properties"
    click SM "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/resources/application.properties"
    click EH "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/Error/ErrorHandler.java"
    click EL "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/services/LicenseService.java"
    click CarflowUserServiceApplication "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/CarflowUserServiceApplication.java"
    click User "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/model/User.java"
    click UserDTO "https://github.com/pierrick74/carflow-user-service/blob/master/src/main/java/com/PulseLabs/carflow_user_service/model/UserDTO.java"
    click CarflowUserServiceApplicationTests "https://github.com/pierrick74/carflow-user-service/blob/master/src/test/java/com/PulseLabs/carflow_user_service/CarflowUserServiceApplicationTests.java"

    %% Legend
    subgraph "Legend"
        direction TB
        I["Internal Components"]:::internal
        P["Persistent Store"]:::persistent
        E["External Service"]:::external
        S["Security / Cross-Cutting"]:::security
    end

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef persistent fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef security fill:#DDA0DD,stroke:#333,stroke-width:1px
```
