# charithjdesilva-learning/studyfi-backend architecture

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

- Interactive diagram: https://gitdiagram.com/charithjdesilva-learning/studyfi-backend
- Repository: https://github.com/charithjdesilva-learning/studyfi-backend

## Overview

##### Project type and purpose
- This is a microservice-based backend for the “StudyFi” application. It consists of multiple Spring Boot services (each with its own Maven module) working together under a service-discovery and API-gateway layer.

##### File structure
- Top-level modules:
- apigateway – routes incoming HTTP calls
- discoveryserver – Eureka service registry
- contentandnews – manages posts, comments, likes, news
- userandgroup – handles user profiles, groups, email verification, password reset
- notification – sends notifications (email/push)
- Each service:
- src/main/java/com/... – standard Spring Boot structure (Application class, controllers, services, repositories, DTOs, models)
- src/main/resources/application.properties – service configuration
- config packages – WebClientConfig, CloudinaryConfig, MailConfig where applicable
- Shared patterns:
- Each service uses Spring Data JPA repositories
- WebClient (reactive HTTP client) configured to call other services
- Cloudinary used for media uploads in contentandnews and userandgroup
- Maven parent POM defines common dependencies

##### README
- Confirms this is the “Backend for the Study-Fi Project.”

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Edge Layer
    subgraph "Clients"
        direction TB
        WebClient["Web/Mobile Client"]
    end

    %% API Gateway Layer
    subgraph "Edge Layer"
        direction TB
        ApiGateway["API Gateway"]:::gateway
    end

    %% Discovery Layer
    subgraph "Infrastructure"
        direction TB
        Discovery["Service Registry (Eureka)"]:::discovery
    end

    %% Core Services Layer
    subgraph "Core Microservices"
        direction TB

        subgraph "Content & News Service" 
            direction TB
            ContentApp["ContentAndNews Application"]:::service
            ContentCtrl["Controller"]:::service
            ContentSvc["Service"]:::service
            ContentRepo["Repository"]:::service
            ContentDB["Content DB"]:::database
            ContentCloud["CloudinaryConfig"]:::external
            ContentWebClient["WebClientConfig"]:::service
            ContentApp --> ContentCtrl --> ContentSvc --> ContentRepo --> ContentDB
        end

        subgraph "User & Group Service"
            direction TB
            UserApp["UserAndGroup Application"]:::service
            UserCtrlU["User Controllers"]:::service
            UserCtrlG["Group Controllers"]:::service
            UserSvc["Service"]:::service
            UserRepo["Repository"]:::service
            UserDB["User DB"]:::database
            UserCloud["CloudinaryConfig"]:::external
            UserMail["MailConfig"]:::external
            UserWebClient["WebClientConfig"]:::service
            UserApp --> UserCtrlU
            UserApp --> UserCtrlG
            UserCtrlU --> UserSvc --> UserRepo --> UserDB
            UserCtrlG --> UserSvc
        end

        subgraph "Notification Service"
            direction TB
            NotificationApp["Notification Application"]:::service
            NotificationCtrl["Notification Controller"]:::service
            NotificationSvc["Service"]:::service
            NotificationRepo["Repository"]:::service
            NotificationDB["Notification DB"]:::database
            NotificationWebClient["WebClientConfig"]:::service
            NotificationApp --> NotificationCtrl --> NotificationSvc --> NotificationRepo --> NotificationDB
        end
    end

    %% External Systems
    subgraph "External Services"
        direction TB
        Cloudinary["Cloudinary"]:::external
        SMTP["SMTP/Email Provider"]:::external
    end

    %% Parent POM
    MavenPOM["Parent Maven POM"]:::external

    %% Connections
    WebClient -->|"HTTP/REST"| ApiGateway
    ApiGateway -->|"Service Discovery Lookup"| Discovery

    Discovery -->|"Service Registration"| ContentApp
    Discovery -->|"Service Registration"| UserApp
    Discovery -->|"Service Registration"| NotificationApp

    ApiGateway -->|"Route Requests"| ContentApp
    ApiGateway -->|"Route Requests"| UserApp
    ApiGateway -->|"Route Requests"| NotificationApp

    ContentSvc -->|"GET /users/{id}"| UserApp
    ContentSvc -->|"POST /notify"| NotificationApp
    UserSvc -->|"POST /notify"| NotificationApp

    ContentCloud -->|Uploads| Cloudinary
    UserCloud -->|Uploads| Cloudinary
    UserMail -->|Sends Emails| SMTP

    %% Click Events
    click ApiGateway "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/apigateway/src/main/java/com/apigateway/apigateway/ApiGatewayApplication.java"
    click Discovery "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/discoveryserver/src/main/java/com/discoveryserver/discoveryserver/DiscoveryServerApplication.java"
    click ContentApp "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/contentandnews/src/main/java/com/studyfi/contentandnews/ContentandnewsApplication.java"
    click ContentCtrl "https://github.com/charithjdesilva-learning/studyfi-backend/tree/main/contentandnews/src/main/java/com/studyfi/contentandnews/controller/"
    click ContentCloud "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/contentandnews/src/main/java/com/studyfi/contentandnews/config/CloudinaryConfig.java"
    click ContentWebClient "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/contentandnews/src/main/java/com/studyfi/contentandnews/config/WebClientConfig.java"
    click UserApp "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/userandgroup/src/main/java/com/studyfi/userandgroup/UserandgroupApplication.java"
    click UserCtrlU "https://github.com/charithjdesilva-learning/studyfi-backend/tree/main/userandgroup/src/main/java/com/studyfi/userandgroup/user/controller/"
    click UserCtrlG "https://github.com/charithjdesilva-learning/studyfi-backend/tree/main/userandgroup/src/main/java/com/studyfi/userandgroup/group/controller/"
    click UserCloud "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/userandgroup/src/main/java/com/studyfi/userandgroup/config/CloudinaryConfig.java"
    click UserMail "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/userandgroup/src/main/java/com/studyfi/userandgroup/config/MailConfig.java"
    click UserWebClient "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/userandgroup/src/main/java/com/studyfi/userandgroup/config/WebClientConfig.java"
    click NotificationApp "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/notification/src/main/java/com/studyfi/notification/NotificationApplication.java"
    click NotificationCtrl "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/notification/src/main/java/com/studyfi/notification/controller/NotificationController.java"
    click NotificationWebClient "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/notification/src/main/java/com/studyfi/notification/config/WebClientConfig.java"
    click MavenPOM "https://github.com/charithjdesilva-learning/studyfi-backend/blob/main/pom.xml"

    %% Styles
    classDef gateway fill:#FFD700,stroke:#333,stroke-width:1px
    classDef discovery fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef service fill:#98FB98,stroke:#333,stroke-width:1px
    classDef database fill:#FFFACD,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
