# pavlokordunov/projecto-de-softservo architecture

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

- Interactive diagram: https://gitdiagram.com/pavlokordunov/projecto-de-softservo
- Repository: https://github.com/pavlokordunov/projecto-de-softservo

## Overview

##### Main Components
a. Frontend:
- Represented by the “frontend” directory.
- Built using Next.js (notice the “app” directory with page.tsx files, layout.tsx, providers.tsx, etc.).
- Contains authentication components (e.g., LoginWidget, OktaSignInWidget) and API integration (see “api/omdbApi” suggesting an external movie database integration).
- Manages client-side routing for pages like home, groups, posts, topics, profiles, etc.
b. Backend:
- Represented by the “backend” directory.
- A Java-based server application (Spring Boot–style) using Maven (pom.xml, mvnw) with a clear layered structure:
– Controllers (in the controller package) that expose REST endpoints for forums, chat, posts, notifications, etc.
– Services (and their implementations) for business logic such as PostService, UserService, ChatMessageService, and TMDbService, indicating use of external APIs (like TMDb for movie data).
– Repositories (using Spring Data) for data access.
– Entities (model classes) for domain objects (User, Post, Group, Notification, Tag, etc.).
– Configuration classes (e.g., SecurityConfig, H2DBConfig, PostgreSQLDBConfig) and aspects (LoggingAspect, AuthorizationAspect) that implement cross-cutting concerns like logging and security.
c. Database:
- Use of multiple data sources:
– H2 in-memory database (likely for development/test or lightweight cases as indicated by H2DBConfig and associated package structures).
– PostgreSQL for production scenarios (PostgreSQLDBConfig).
d. External / Supporting Tools:
- Allure Reports are integrated within the backend (check “backend/.allure” directory) to manage test reporting.
- A Docker Compose file in the backend (“docker-compose.yml”) points to containerized services.
- External APIs integration: TMDb (and in the frontend, OMDB API) used for movie data.
- WebSocket configuration for real-time features (evident from WebSocketConfig and frontend services/websocket.ts).

##### Relationships and Interactions
– Controllers call Services.
– Services interact with Repositories to access data stored in the Databases.
– Cross-cutting concerns like Security (via SecurityConfig) and Logging (via LoggingAspect) should be clearly indicated.
- External flows such as:
– API calls from backend services to the external TMDb service.
– OMDB API integrations from the frontend.
– Authentication flows using Okta (as observed in the frontend auth components).
- Incorporate WebSocket communications for functionalities like real-time chat (represented by both the backend’s WebSocketConfig and the frontend’s websocket service).

##### Architectural Patterns and Design Principles
- Layered/MVC Architecture in the backend (Controllers, Services, Repositories, Entities).
- Use of Aspects (for authorization and logging) as part of cross-cutting concerns.
- Separation of concerns between the frontend (client presentation, routing, authentication widget) and the backend (business logic, persistence).
- Modular integration of external services (TMDb and OMDB APIs) that enhance domain features.
- Containerization (via Docker Compose) to manage deployment and orchestration.

##### Detail and Clarity
- Key architectural elements even if some are only represented in part of the file tree.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (Next.js Web App)"]:::frontend
        FR["Pages & Routing"]:::frontend
        AC["Auth Components (LoginWidget & OktaSignInWidget)"]:::frontend
        OM["OMDB API Integration"]:::frontend
        WS["WebSocket Client"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend (Spring Boot API)"]:::backend
        Controllers["Controllers"]:::backend
        Services["Services"]:::backend
        Repositories["Repositories"]:::backend
        Entities["Entities (Domain Models)"]:::backend
        Config["Configuration (Security, DB, WebSocket, TMDb)"]:::backend
        Aspects["Aspects (Logging & Authorization)"]:::backend
        Allure["Allure Reporting"]:::backend
        Docker["Docker Compose"]:::backend
    end

    %% Database Layer
    subgraph "Databases"
        H2["H2 Database"]:::db
        PG["PostgreSQL Database"]:::db
    end

    %% External Services
    subgraph "External Services"
        TMDb["External TMDb API"]:::external
        OMDB["External OMDB API"]:::external
        Okta["Okta Authentication"]:::external
    end

    %% Frontend to Backend interactions
    FR -->|"HTTP/REST"| Controllers
    AC -->|"HTTP/REST"| Controllers
    AC -->|"auth"| Okta
    WS -->|"WebSocket"| Config
    OM -->|"HTTP/REST"| OMDB

    %% Backend internal flow
    BE --> Controllers
    Controllers -->|"calls"| Services
    Services -->|"uses"| Repositories
    Repositories -->|"persists"| H2
    Repositories -->|"persists"| PG
    Services -->|"calls"| TMDb
    Docker -->|"deploys"| BE
    BE -->|"reports"| Allure

    %% Optional: Configuration connecting to Databases
    Config -->|"connects"| H2
    Config -->|"connects"| PG

    %% Styling
    classDef frontend fill:#FCE4D6,stroke:#D35400,stroke-width:2px;
    classDef backend fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
    classDef db fill:#D5F5E3,stroke:#28B463,stroke-width:2px,stroke-dasharray: 5 5;
    classDef external fill:#FCF3CF,stroke:#B7950B,stroke-width:2px,stroke-dasharray: 3 3;

    %% Click Events for Frontend Components
    click FE "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/frontend/"
    click FR "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/frontend/app/"
    click AC "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/frontend/auth/"
    click OM "https://github.com/pavlokordunov/projecto-de-softservo/blob/master/frontend/api/omdbApi/omdbApi.tsx"
    click WS "https://github.com/pavlokordunov/projecto-de-softservo/blob/master/frontend/services/websocket.ts"

    %% Click Events for Backend Components
    click BE "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/backend/"
    click Controllers "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/backend/src/main/java/com/proj/forum/controller/"
    click Services "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/backend/src/main/java/com/proj/forum/service/"
    click Repositories "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/backend/src/main/java/com/proj/forum/repository/"
    click Entities "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/backend/src/main/java/com/proj/forum/entity/"
    click Config "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/backend/src/main/java/com/proj/forum/config/"
    click Aspects "https://github.com/pavlokordunov/projecto-de-softservo/tree/master/backend/src/main/java/com/proj/forum/aspect/"
    click Allure "https://github.com/pavlokordunov/projecto-de-softservo/blob/master/backend/.allure"
    click Docker "https://github.com/pavlokordunov/projecto-de-softservo/blob/master/backend/docker-compose.yml"
```
