# techcamp-training/pictweet_java_back architecture

> Architecture diagram of the GitHub repository techcamp-training/pictweet_java_back, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/techcamp-training/pictweet_java_back
- Repository: https://github.com/techcamp-training/pictweet_java_back

## Overview

##### Main System Components
- Web Layer (Frontend/Presentation):
- Controllers (TweetController, UserController, CommentController)
- Templates (HTML templates under “src/main/resources/templates” for tweets and users)
- Static Resources (Static CSS and images under “src/main/resources/static”)
- Business Logic Layer:
- Services (UserService, UserAuthenticationService)
- Validation components (classes under “src/main/java/in/tech_camp/pictweet/validation”)
- Data Access Layer:
- Repositories (TweetRepository, UserRepository, CommentRepository)
- Entities (TweetEntity, UserEntity, CommentEntity)
- Persistence and Configuration:
- Database Migrations (SQL scripts under “src/main/resources/db/migration”)
- Application configuration properties (in “src/main/resources/application.properties”)
- Security:
- Security Configuration (SecurityConfig.java) that likely integrates with the authentication service.
- Testing:
- Integration tests and unit tests, shown under the “src/test” directories for various areas (factories, forms, system/integration).
- Build and Deployment:
- Gradle build scripts and properties (build.gradle, gradlew, settings.gradle) to manage dependencies, building, and packaging.

##### Relationships and Data Flow
- The Web Layer (Controllers) handles HTTP requests from users and forwards them to the Service Layer.
- The Service Layer applies business logic (e.g., user authentication, tweet posting) and coordinates with the Data Access Layer.
- The Data Access Layer (Repositories) interacts with the underlying database. The database schema is evolved through migration files.
- The Security configuration is a cross-cutting concern affecting how requests are processed and authenticated.
- Static Resources and Templates are used to render the front-end UI that users interact with.

##### Architectural Patterns and Technologies
- MVC Pattern: Clear separation among controllers (handling web requests), services (business logic), and repositories/entities (data access).
- Layered Architecture: Distinguish the presentation, business, and persistence layers.
- Database versioning and migration through SQL scripts – this shows a commitment to maintainable schema management.
- Integration and Unit Testing: Indicate that each layer is testable and separated, enhancing reliability.

## Diagram (Mermaid)

```mermaid
flowchart TB
    EndUser["End-User"]:::presentation

    subgraph "Web Layer (Presentation)"
        Controllers["Controllers\n(TweetController, UserController, CommentController)"]:::presentation
        Templates["Templates"]:::presentation
        StaticResources["Static Resources"]:::presentation
    end

    subgraph "Business Logic Layer"
        Services["Services\n(UserService, UserAuthenticationService)"]:::business
        Validation["Validation Components"]:::business
    end

    subgraph "Data Access Layer"
        Repositories["Repositories"]:::data
        Entities["Entities"]:::data
    end

    subgraph "Persistence & Configuration"
        DBMigrations["DB Migrations"]:::config
        AppProperties["App Properties"]:::config
        Database["Database"]:::config
    end

    SecurityConfig["Security Configuration"]:::security

    subgraph "Build & Deployment"
        BuildDeployment["Build Scripts"]:::build
    end

    subgraph "Testing"
        TestingComponents["Testing Components"]:::testing
    end

    EndUser -->|"HTTP_Request"| Controllers
    Controllers -->|"calls"| Services
    Services -->|"invokes_Crud"| Repositories
    Repositories -->|"data_ops"| Database
    Services -->|"validates_Input"| Validation
    Templates -->|"renders_UI"| EndUser
    StaticResources -->|"provides_assets"| EndUser
    Controllers -.->|"secured_by"| SecurityConfig
    Services -.->|"secured_by"| SecurityConfig
    DBMigrations -->|"manages_schema"| Database
    AppProperties -->|"configures"| Database

    BuildDeployment -->|"builds"| Controllers
    BuildDeployment -->|"builds"| Services
    BuildDeployment -->|"builds"| Repositories

    TestingComponents -->|"tests"| Controllers
    TestingComponents -->|"tests"| Services
    TestingComponents -->|"tests"| Repositories

    classDef presentation fill:#f9e79f,stroke:#d4ac0d,stroke-width:2px;
    classDef business fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef data fill:#d5f5e3,stroke:#1e8449,stroke-width:2px;
    classDef config fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef security fill:#d7bde2,stroke:#7d3c98,stroke-width:2px;
    classDef build fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef testing fill:#d6eaf8,stroke:#3498db,stroke-width:2px;

    click Controllers "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/main/java/in/tech_camp/pictweet/controller"
    click Templates "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/main/resources/templates"
    click StaticResources "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/main/resources/static"
    click Services "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/main/java/in/tech_camp/pictweet/service"
    click Validation "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/main/java/in/tech_camp/pictweet/validation"
    click Repositories "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/main/java/in/tech_camp/pictweet/repository"
    click Entities "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/main/java/in/tech_camp/pictweet/entity"
    click DBMigrations "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/main/resources/db/migration"
    click AppProperties "https://github.com/techcamp-training/pictweet_java_back/blob/main/src/main/resources/application.properties"
    click SecurityConfig "https://github.com/techcamp-training/pictweet_java_back/blob/main/src/main/java/in/tech_camp/pictweet/SecurityConfig.java"
    click BuildDeployment "https://github.com/techcamp-training/pictweet_java_back/blob/main/build.gradle"
    click TestingComponents "https://github.com/techcamp-training/pictweet_java_back/tree/main/src/test"
```
