# alexmatika-code/reci-pa-ispeci architecture

> Architecture diagram of the GitHub repository alexmatika-code/reci-pa-ispeci, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexmatika-code/reci-pa-ispeci
- Repository: https://github.com/alexmatika-code/reci-pa-ispeci

## Overview

##### Main System Components

a) Frontend Layer (React Application)
- User Interface Components
- State Management (Contexts)
- Route Management
- Component Hierarchy

b) Backend Layer (Spring Boot Application)
- REST Controllers
- Service Layer
- Data Access Layer
- Security Layer
- WebSocket Services

c) External Services
- OAuth 2.0 Authentication
- OpenAI Integration
- PostgreSQL Database

##### Component Relationships and Interactions

a) Frontend Structure (Top Section):
**[React Components] → [Context Management] → [REST API Clients]**
- ↓
**[WebSocket Clients] → [Chat Services]**

b) Backend Structure (Middle Section):
**[Controllers] → [Services] → [Repositories]**
- ↓
**[Security Config] → [WebSocket Handlers]**

c) Database Layer (Bottom Section):
**[PostgreSQL Database]**
- Person
- Recipe
- Ingredient
- Rating
- Role

##### Specific Implementation Details

Frontend Components:
- Main pages (Home, Profile, Recipe, Ingredients)
- Chat functionality (LiveChat and AiChat)
- User management components

Backend Services:
- REST controllers
- Service implementations
- WebSocket configurations
- Security layers

##### Data Flow Indicators

- User authentication flow
- Recipe creation and approval process
- Chat message routing
- Database operations

##### Architecture Patterns

Following patterns:
- MVC architecture
- DTO pattern
- Repository pattern
- Service layer pattern

This system design should emphasize the modern web application architecture with real-time features (chat), AI integration, and secure user management, which are key aspects of this culinary community platform.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef database fill:#9b59b6,color:white
    classDef security fill:#e74c3c,color:white
    classDef external fill:#f1c40f,color:black
    
    %% Frontend Layer
    subgraph Frontend
        UI[UI Components]:::frontend
        SM[State Management]:::frontend
        RT[Route Management]:::frontend
        CH[Chat Components]:::frontend
        WSC[WebSocket Client]:::frontend
        RAC[REST API Client]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        RC[REST Controllers]:::backend
        SL[Service Layer]:::backend
        DAL[Data Access Layer]:::backend
        WSH[WebSocket Handlers]:::backend
        DTO[Data Transfer Objects]:::backend
        SC[Security Config]:::security
        OAI[OpenAI Service]:::backend
    end

    %% Database Layer
    subgraph Database
        DB[(PostgreSQL)]:::database
    end

    %% External Services
    OAuth[OAuth 2.0]:::external
    OpenAI[OpenAI API]:::external

    %% Relationships
    UI --> SM
    SM --> RAC
    UI --> WSC
    CH --> WSC
    WSC --> WSH
    RAC --> RC
    RC --> SL
    SL --> DAL
    DAL --> DB
    SC --> RC
    WSH --> SL
    SL --> OAI
    OAI --> OpenAI
    SC --> OAuth
    SL --> DTO

    %% Click Events
    click UI "https://github.com/alexMatika-code/Reci-pa-ispeci/tree/main/dev/teams-frontend/teams-frontend/src/components/"
    click SM "https://github.com/alexMatika-code/Reci-pa-ispeci/blob/main/dev/teams-frontend/teams-frontend/src/Contexts.jsx"
    click RT "https://github.com/alexMatika-code/Reci-pa-ispeci/blob/main/dev/teams-frontend/teams-frontend/src/App.jsx"
    click RC "https://github.com/alexMatika-code/Reci-pa-ispeci/tree/main/dev/teams-backend/teams-backend/src/main/java/hr/fer/progi/teams_backend/rest/"
    click SL "https://github.com/alexMatika-code/Reci-pa-ispeci/tree/main/dev/teams-backend/teams-backend/src/main/java/hr/fer/progi/teams_backend/service/"
    click DAL "https://github.com/alexMatika-code/Reci-pa-ispeci/tree/main/dev/teams-backend/teams-backend/src/main/java/hr/fer/progi/teams_backend/dao/"
    click SC "https://github.com/alexMatika-code/Reci-pa-ispeci/blob/main/dev/teams-backend/teams-backend/src/main/java/hr/fer/progi/teams_backend/config/WebSecurityBasic.java"
    click WSH "https://github.com/alexMatika-code/Reci-pa-ispeci/tree/main/dev/teams-backend/teams-backend/src/main/java/hr/fer/progi/teams_backend/utils/"
    click OAI "https://github.com/alexMatika-code/Reci-pa-ispeci/blob/main/dev/teams-backend/teams-backend/src/main/java/hr/fer/progi/teams_backend/service/OpenAiService.java"
    click CH "https://github.com/alexMatika-code/Reci-pa-ispeci/tree/main/dev/teams-frontend/teams-frontend/src/components/Chat/"
    click DTO "https://github.com/alexMatika-code/Reci-pa-ispeci/tree/main/dev/teams-backend/teams-backend/src/main/java/hr/fer/progi/teams_backend/domain/dto/"
```
