# itspankajrepo/cashrichassignment architecture

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

- Interactive diagram: https://gitdiagram.com/itspankajrepo/cashrichassignment
- Repository: https://github.com/itspankajrepo/cashrichassignment

## Overview

##### Project type and purpose
- This is a Spring-Boot based monolithic REST API service (“cashRichAssignment”) that exposes four endpoints: user sign-up, login, update profile, and fetch latest cryptocurrency quotes.
- There is no separate frontend; it is a backend service intended to be consumed by a client or mobile app.

##### File structure
- Top‐level files: pom.xml (Maven build), mvnw scripts, README.md, .mvn wrapper.
- src/main/java/com/assignment/cashRich:
- CashRichApplication.java – SpringBoot main class
- controller/… – REST controllers (CryptoController, UserController)
- handler/… – Business‐logic handlers (separating raw service logic)
- service/… – Service interfaces and implementations (UserService, TokenService)
- repository/… – Spring Data JPA repositories for User, UserToken, UserFetchingLatestQuotes
- entity/… – JPA entities
- config/ProjectSecurityConfig.java – Spring Security configuration
- filter/RestControllerRequestFilter.java – Pre‐authentication request filter
- advice/RestTemplateResponseErrorHandler.java and exception/… – Global exception handling
- util/validation and generic utility classes
- src/main/resources/application.properties – DB & external API configuration, message bundles.
- src/test – Integration/unit tests.

##### README for additional insights
- Describes the four APIs, required HTTP headers, and sample cURL commands.
- Indicates authenticated endpoints use JWT Bearer tokens.
- One endpoint calls an external cryptocurrency quotes API via RestTemplate.

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["Client"]:::external
    CryptoAPI["External Crypto API"]:::external

    subgraph "Spring Boot Application"
        Main["CashRichApplication"]:::app
        subgraph "Security Layer"
            Config["ProjectSecurityConfig"]:::security
            Filter["RestControllerRequestFilter"]:::security
        end
        subgraph "Controllers"
            UserCtrl["UserController"]:::controller
            CryptoCtrl["CryptoController"]:::controller
        end
        subgraph "Handlers"
            UserH["UserHandler"]:::handler
            CryptoH["CryptoHandler"]:::handler
        end
        subgraph "Service Layer"
            USvc["UserServiceImp"]:::service
            TSvc["TokenServiceImp"]:::service
        end
        subgraph "Data Access Layer"
            UserRepo["UserRepository"]:::repository
            TokenRepo["UserTokenRepository"]:::repository
            QuoteRepo["UserFetchingLatestQuotesRep"]:::repository
        end
        subgraph "Error Handling"
            ExpH["CashRichExceptionHandler"]:::error
            RespErr["RestTemplateResponseErrorHandler"]:::error
        end
        subgraph "DTOs"
            ApiResp["ApiResponse"]:::dto
            SignDto["SignUpUserRequestDto"]:::dto
            LoginDto["LoginUserRequestDto"]:::dto
            UpdateDto["UpdateUserRequestDto"]:::dto
            FetchDto["FetchCryptoQuotesRequestDto"]:::dto
        end

        Main --> Config
        Config --> Filter
        Client -->|HTTP Request| Filter
        Filter -->|validates JWT| UserCtrl
        Filter -->|validates JWT| CryptoCtrl
        UserCtrl -->|calls| UserH
        CryptoCtrl -->|calls| CryptoH
        UserH -->|uses| USvc
        UserH -->|uses| TSvc
        CryptoH -->|uses| USvc
        CryptoH -->|uses RestTemplate| RespErr
        CryptoH -->|calls| CryptoAPI
        USvc -->|reads/writes| UserRepo
        TSvc -->|reads/writes| TokenRepo
        USvc -->|records fetch| QuoteRepo
        UserRepo -->|CRUD| DB[(Database)]:::repository
        TokenRepo -->|CRUD| DB
        QuoteRepo -->|CRUD| DB
        UserCtrl -.->|exception| ExpH
        CryptoCtrl -.->|exception| ExpH

    end

    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef app fill:#ADD8EEC,stroke:#333,stroke-width:1px
    classDef security fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef controller fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef handler fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef service fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef repository fill:#98FB98,stroke:#333,stroke-width:1px
    classDef error fill:#F5DEB3,stroke:#333,stroke-width:1px
    classDef dto fill:#EEEEEE,stroke:#333,stroke-width:1px

    click Main "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/CashRichApplication.java"
    click Config "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/config/ProjectSecurityConfig.java"
    click Filter "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/filter/RestControllerRequestFilter.java"
    click UserCtrl "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/controller/UserController.java"
    click CryptoCtrl "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/controller/CryptoController.java"
    click UserH "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/handler/UserHandler.java"
    click CryptoH "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/handler/CryptoHandler.java"
    click USvc "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/service/UserServiceImp.java"
    click TSvc "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/service/TokenServiceImp.java"
    click UserRepo "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/repository/UserRepository.java"
    click TokenRepo "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/repository/UserTokenRepository.java"
    click QuoteRepo "https://github.com/itspankajrepo/cashrichassignment/blob/main/src/main/java/com/assignment/cashRich/repository/UserFetchingLatestQuotesRep.java"
```
