# real-dev-squad/skill-tree-backend architecture

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

- Interactive diagram: https://gitdiagram.com/real-dev-squad/skill-tree-backend
- Repository: https://github.com/real-dev-squad/skill-tree-backend

## Overview

##### Main System Components

a) External Systems:
- GitHub Authentication
- RDS Backend Service (external dependency)
- Frontend Application

b) Core Application Components:
- Authentication Layer
- API Controllers
- Service Layer
- Repository Layer
- Database Layer

##### Architectural Patterns to Highlight

The project follows several clear patterns that should be represented:

a) Layered Architecture:
- Controllers (APIs) Layer (`apis` package)
- Service Layer (`services` package)
- Repository Layer (`repositories` package)
- Model Layer (`models` package)

b) Security Architecture:
- JWT Authentication
- Role-based Access Control
- Custom Security Filters

**[Frontend Client] ←→ [Load Balancer/API Gateway]**
- ↓
**[Authentication Layer]**
- JWT Filter
- Security Config
- Auth Entry Point
- ↓
**[API Layer]**
- Skills API
- Endorsements API
- Health API
- ↓
**[Service Layer]**
- Skill Service
- Endorsement Service
- Metric Service
- RDS Service (External)
- ↓
**[Repository Layer]**
- Skill Repository
- Endorsement Repository
- User Skill Repository
- ↓
**[Database Layer]**
- PostgreSQL (indicated by migrations)

**[External Services]**
- RDS Backend
- GitHub Auth

##### Important Details

a) Authentication Flow:
- GitHub OAuth flow
- JWT token validation path
- Role-based access control

b) Data Flow:
- Skill creation/management flow
- Endorsement flow
- User skill status updates

c) Cross-cutting Concerns:
- Exception handling
- Metrics collection
- Logging

##### Environment Configurations
- Different deployment environments (dev, staging, production)
- Docker container boundaries

##### Technical Stack Indicators

- Java 17
- Spring Boot
- Maven
- PostgreSQL
- Docker
- GitHub Actions (CI/CD)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#a8d1ff,stroke:#333
    classDef security fill:#ffe0a8,stroke:#333
    classDef api fill:#a8ffc1,stroke:#333
    classDef service fill:#d4a8ff,stroke:#333
    classDef repository fill:#ffa8a8,stroke:#333
    classDef database fill:#e0e0e0,stroke:#333
    classDef external fill:#ffcca8,stroke:#333

    %% External Systems
    Frontend["Frontend Client"]:::frontend
    GitHub["GitHub Auth"]:::external
    RDSBackend["RDS Backend Service"]:::external

    %% Authentication Layer
    subgraph AuthLayer["Authentication Layer"]
        JWTFilter["JWT Filter"]
        SecurityConfig["Security Config"]
        AuthEntry["Auth Entry Point"]
    end

    %% API Layer
    subgraph APILayer["API Layer"]
        SkillsAPI["Skills API"]
        EndorsementsAPI["Endorsements API"]
        HealthAPI["Health API"]
    end

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        SkillService["Skill Service"]
        EndorsementService["Endorsement Service"]
        MetricService["Metric Service"]
        RDSService["RDS Service"]
    end

    %% Repository Layer
    subgraph RepoLayer["Repository Layer"]
        SkillRepo["Skill Repository"]
        EndorsementRepo["Endorsement Repository"]
        UserSkillRepo["User Skill Repository"]
    end

    %% Database Layer
    PostgreSQL[(PostgreSQL)]:::database

    %% Connections
    Frontend --> AuthLayer
    Frontend --> GitHub
    GitHub --> AuthLayer
    AuthLayer --> APILayer
    APILayer --> ServiceLayer
    ServiceLayer --> RepoLayer
    RepoLayer --> PostgreSQL
    RDSService --> RDSBackend

    %% Click Events
    click JWTFilter "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/utils/JWTAuthenticationFilter.java"
    click SecurityConfig "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/config/SecurityConfig.java"
    click AuthEntry "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/Authentication/AuthEntryPoint.java"
    click SkillsAPI "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/apis/SkillsApi.java"
    click EndorsementsAPI "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/apis/EndorsementsApi.java"
    click HealthAPI "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/apis/HealthApi.java"
    click SkillService "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/services/SkillService.java"
    click EndorsementService "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/services/EndorsementService.java"
    click MetricService "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/services/MetricService.java"
    click RDSService "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/services/external/RdsService.java"
    click SkillRepo "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/repositories/SkillRepository.java"
    click EndorsementRepo "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/repositories/EndorsementRepository.java"
    click UserSkillRepo "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/java/com/RDS/skilltree/repositories/UserSkillRepository.java"
    click PostgreSQL "https://github.com/Real-Dev-Squad/skill-tree-backend/blob/develop/src/main/resources/db/migrations/V1__initial_setup.sql"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Security_L["Security"]:::security
        API_L["API"]:::api
        Service_L["Service"]:::service
        Repository_L["Repository"]:::repository
        Database_L["Database"]:::database
        External_L["External"]:::external
    end
```
