# 95902/freereads architecture

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

- Interactive diagram: https://gitdiagram.com/95902/freereads
- Repository: https://github.com/95902/freereads

## Overview

##### Main Components

A. Frontend Layer:
- Twig templates structure (/templates)
- Asset management (Webpack Encore, Tailwind CSS)
- JavaScript controllers (Stimulus)

B. Application Layer:
- Controllers hierarchy (especially Admin vs. Regular controllers)
- Security components (Authentication/Authorization)
- Services layer (GoogleBooksApiService, ProfileService)
- Form handling

C. Data Layer:
- Entity relationships
- Doctrine repositories
- Database structure

##### Key Architectural Elements

**[Client Layer]**
- ↓ ↑
**[Web Layer]**
- ↓ ↑
**[Application Layer]**
- ↓ ↑
**[Data Access Layer]**
- ↓ ↑
**[Database]**

##### Specific Components to Highlight

a. Client-Side:
- Asset pipeline (Webpack, Tailwind)
- Template structure with base.html.twig as the parent
- JavaScript controllers for interactive features

b. Application Core:
- EasyAdmin integration for admin interface
- Security layer with AppAuthenticator
- Command line tools (CreateAdminCommand)
- Service layer for business logic

c. Data Structure:
- Entity relationships between Book, Author, Publisher, User, and UserBook
- Repository layer for data access
- Doctrine migrations

##### External Integrations
- Google Books API integration
- Any authentication providers
- Asset delivery system

##### Important Relationships
- User authentication flow
- Book management flow
- Admin dashboard access
- API integration points

##### Technical Details
- Symfony 6.x framework
- Doctrine ORM
- EasyAdmin
- Webpack Encore
- Tailwind CSS
- Stimulus JS

For this specific application, emphasize the book management features, user interaction flows, and admin capabilities, as these are core to the application's purpose.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        Assets["Asset Layer (JS/CSS)"]:::frontend
        Templates["Twig Templates"]:::frontend
    end

    subgraph "Application Layer"
        RequestHandler["Request Handler"]:::app
        Security["Security Layer"]:::security
        
        subgraph Controllers
            AdminControllers["Admin Controllers"]:::controller
            RegularControllers["Regular Controllers"]:::controller
            ProfileControllers["Profile Controllers"]:::controller
        end
        
        subgraph Services
            GoogleAPI["Google Books API Service"]:::service
            ProfileService["Profile Service"]:::service
            AdminService["Create Admin Service"]:::service
        end
    end

    subgraph "Data Layer"
        subgraph Entities
            User["User"]:::entity
            Book["Book"]:::entity
            Author["Author"]:::entity
            Publisher["Publisher"]:::entity
            UserBook["UserBook"]:::entity
            Status["Status"]:::entity
            Invitation["Invitation"]:::entity
        end
        
        subgraph Repositories
            UserRepo["User Repository"]:::repo
            BookRepo["Book Repository"]:::repo
        end
        
        Database[(Database)]:::database
    end

    subgraph "External Services"
        GoogleBooksAPI["Google Books API"]:::external
    end

    %% Relationships
    Browser --> Assets
    Browser --> Templates
    Templates --> Controllers
    
    RequestHandler --> Security
    Security --> Controllers
    
    Controllers --> Services
    GoogleAPI --> GoogleBooksAPI
    Services --> Repositories
    Repositories --> Database
    
    %% Entity Relationships
    User --- UserBook
    Book --- UserBook
    Book --- Author
    Book --- Publisher
    User --- Invitation
    Status --- UserBook

    %% Click Events
    click Templates "https://github.com/95902/freereads/tree/master/templates/"
    click Assets "https://github.com/95902/freereads/tree/master/assets/"
    click AdminControllers "https://github.com/95902/freereads/tree/master/src/Controller/Admin/"
    click RegularControllers "https://github.com/95902/freereads/blob/master/src/Controller/HomeController.php"
    click ProfileControllers "https://github.com/95902/freereads/blob/master/src/Controller/Profile/ProfileController.php"
    click Security "https://github.com/95902/freereads/blob/master/src/Security/AppAuthenticator.php"
    click GoogleAPI "https://github.com/95902/freereads/blob/master/src/Service/GoogleBooksApiService.php"
    click ProfileService "https://github.com/95902/freereads/blob/master/src/Service/ProfileService.php"
    click AdminService "https://github.com/95902/freereads/blob/master/src/Service/CreateAdminService.php"
    click User "https://github.com/95902/freereads/blob/master/src/Entity/User.php"
    click Book "https://github.com/95902/freereads/blob/master/src/Entity/Book.php"
    click Author "https://github.com/95902/freereads/blob/master/src/Entity/Author.php"
    click Publisher "https://github.com/95902/freereads/blob/master/src/Entity/Publisher.php"
    click UserBook "https://github.com/95902/freereads/blob/master/src/Entity/UserBook.php"
    click Status "https://github.com/95902/freereads/blob/master/src/Entity/Status.php"
    click Invitation "https://github.com/95902/freereads/blob/master/src/Entity/Invitation.php"

    %% Styles
    classDef frontend fill:#3498db
    classDef app fill:#2ecc71
    classDef security fill:#e74c3c
    classDef controller fill:#27ae60
    classDef service fill:#16a085
    classDef entity fill:#f1c40f
    classDef repo fill:#f39c12
    classDef database fill:#95a5a6
    classDef external fill:#9b59b6

    %% Legend
    subgraph Legend
        L1["Frontend"]:::frontend
        L2["Application"]:::app
        L3["Security"]:::security
        L4["Controller"]:::controller
        L5["Service"]:::service
        L6["Entity"]:::entity
        L7["Repository"]:::repo
        L8["Database"]:::database
        L9["External"]:::external
    end
```
