# osmancan23/questapp architecture

> Architecture diagram of the GitHub repository osmancan23/questapp, 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/osmancan23/questapp
- Repository: https://github.com/osmancan23/questapp

## Overview

##### Main System Components

a) Client Layer:
- iOS Mobile Application (SwiftUI)
- MVVM architecture within the mobile app
- Features (Feed, Auth, Profile, Post Management)

b) API Gateway/Backend Layer:
- Spring Boot Application
- Security Layer (JWT Authentication)
- REST Controllers
- Service Layer
- Repository Layer

c) Database Layer:
- MySQL Database
- Entity Relationships

##### Component Relationships and Data Flow

a) Mobile Client → Backend:
- HTTP/REST calls with JWT authentication
- File upload streams for images
- Real-time error handling paths

b) Backend Internal Flow:
- Controller → Service → Repository pattern
- Security filter chain for JWT validation
- Exception handling flow

##### Detailed Component Breakdown

For the Mobile Application:
**┌─ iOS Application ─────────────────┐**
- ┌─ Features ─────────────────┐    │
- Auth (Login/Register)    │    │
- Feed                     │    │
- Post Management         │    │
- Profile                 │    │
- ┘    │
- ┌─ Core Services ───────────┐    │
- Network Layer          │    │
- Auth Manager           │    │
- Local Storage         │    │
- ┘    │
- ┘

For the Backend:
**┌─ Spring Boot Application ────────┐**
- ┌─ Security Layer ──────────┐   │
- JWT Authentication      │   │
- Security Filters       │   │
- ┘   │
- ┌─ Controllers ───────────┐    │
- Auth                  │    │
- Post                  │    │
- Comment               │    │
- Like                  │    │
- ┘   │
- ┌─ Services ─────────────┐     │
- Business Logic       │     │
- File Storage        │     │
- ┘   │
- ┘

##### Additional Elements

a) Cross-cutting concerns:
- Error handling flows
- Authentication flows
- File storage paths

b) External integrations:
- File storage system
- JWT token management

c) Database schema overview:
- User
- Post
- Comment
- Like
- Relationships between entities

##### Specific Implementation Details

Technical implementations:
- MVVM pattern in iOS
- Repository pattern in Spring
- JWT token flow
- File upload mechanism
- Error handling strategy

Remember to show the clear separation between the mobile and backend components while illustrating how they interact through the REST API layer, all protected by JWT authentication.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#a8d1f0,stroke:#333
    classDef backend fill:#90EE90,stroke:#333
    classDef security fill:#FFE5B4,stroke:#333
    classDef database fill:#D3D3D3,stroke:#333
    classDef service fill:#98FB98,stroke:#333
    classDef error fill:#FFB6C1,stroke:#333

    %% iOS Application
    subgraph iOS
        Features["Features"]
        CoreServices["Core Services"]

        subgraph Features
            Auth["Auth (Login/Register)"]
            Feed["Feed"]
            PostMgmt["Post Management"]
            Profile["Profile"]
        end

        subgraph CoreServices
            Network["Network Layer"]
            AuthMgr["Auth Manager"]
            Storage["Local Storage"]
        end
    end

    %% Backend Application
    subgraph Backend
        SecurityLayer["Security Layer"]
        Controllers["Controllers"]
        Services["Services"]
        DataLayer["Data Layer"]

        subgraph SecurityLayer
            JWT["JWT Authentication"]
            SecConfig["Security Config"]
        end

        subgraph Controllers
            AuthCtrl["Auth Controller"]
            PostCtrl["Post Controller"]
            UserCtrl["User Controller"]
            CommentCtrl["Comment Controller"]
        end

        subgraph Services
            UserSvc["User Service"]
            PostSvc["Post Service"]
            FileSvc["File Storage Service"]
        end

        subgraph DataLayer
            Entities["Entities"]
            Repos["Repositories"]
            DB[(MySQL Database)]
        end

        ExHandler["Global Exception Handler"]
    end

    %% Relationships
    Features --> CoreServices
    CoreServices --> SecurityLayer
    SecurityLayer --> Controllers
    Controllers --> Services
    Services --> DataLayer
    DataLayer --> DB
    Controllers --> ExHandler

    %% Click Events
    click Feed "https://github.com/osmancan23/QuestApp/tree/main/mobile/QuestApp/QuestApp/Features/Feed/"
    click Auth "https://github.com/osmancan23/QuestApp/tree/main/mobile/QuestApp/QuestApp/Features/Login/"
    click Profile "https://github.com/osmancan23/QuestApp/tree/main/mobile/QuestApp/QuestApp/Features/Profile/"
    click PostMgmt "https://github.com/osmancan23/QuestApp/tree/main/mobile/QuestApp/QuestApp/Features/Post/"
    click Network "https://github.com/osmancan23/QuestApp/tree/main/mobile/QuestApp/QuestApp/Core/Network/"
    click AuthMgr "https://github.com/osmancan23/QuestApp/blob/main/mobile/QuestApp/QuestApp/Core/Auth/AuthManager.swift"
    click Storage "https://github.com/osmancan23/QuestApp/blob/main/mobile/QuestApp/QuestApp/Core/LocaleStorage/LocaleStorage.swift"
    click AuthCtrl "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/controllers/AuthController.java"
    click PostCtrl "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/controllers/PostController.java"
    click UserCtrl "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/controllers/UserController.java"
    click CommentCtrl "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/controllers/CommentController.java"
    click JWT "https://github.com/osmancan23/QuestApp/tree/main/backend/src/main/java/com/osmncnn/questApp/security/"
    click SecConfig "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/security/SecurityConfig.java"
    click UserSvc "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/services/UserService.java"
    click PostSvc "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/services/PostService.java"
    click FileSvc "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/services/FileStorageService.java"
    click Entities "https://github.com/osmancan23/QuestApp/tree/main/backend/src/main/java/com/osmncnn/questApp/entities/"
    click Repos "https://github.com/osmancan23/QuestApp/tree/main/backend/src/main/java/com/osmncnn/questApp/repos/"
    click ExHandler "https://github.com/osmancan23/QuestApp/blob/main/backend/src/main/java/com/osmncnn/questApp/exceptions/GlobalExceptionHandler.java"

    %% Style Applications
    class Features,CoreServices,Auth,Feed,PostMgmt,Profile,Network,AuthMgr,Storage frontend
    class SecurityLayer,Controllers,Services,DataLayer,JWT,SecConfig,AuthCtrl,PostCtrl,UserCtrl,CommentCtrl backend
    class UserSvc,PostSvc,FileSvc service
    class DB database
    class ExHandler error
```
