# ryuichi24/iremono-old architecture

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

- Interactive diagram: https://gitdiagram.com/ryuichi24/iremono-old
- Repository: https://github.com/ryuichi24/iremono-old

## Overview

##### Project Type and Purpose
- iremono is a full‐stack application that enables users to self-host their cloud storage with advanced encryption (including zero‐knowledge encryption), supporting both SQLite and MySQL databases.
- The project is structured as a monorepo with multiple packages—including the core backend logic, an API server, a frontend web client, and a utility library.

##### File Structure and Main Components
- Frontend – packages/iremono-web:
– This contains the React-based web client including components, pages, hooks, and state management (Redux).
- Backend – packages/iremono-server:
– Contains the Express-based API server with controllers, routes, configurations, and middleware.
- Business/Core Logic – packages/iremono-backend-core:
– Implements domain-specific use cases (auth, file management, folder operations, trash management), repository interfaces, entities, and services (token services, crypto services, etc.).
- Utility Library – packages/iremono-util:
– Houses shared utility functions like logging, file-system helpers, error definitions, and other common tools.
- Other Items:
– Configuration files (Dockerfile, docker-compose files, .env.example) for deployment.
– Scripts for initializing and maintaining the database for both SQLite and MySQL.
– Testing and configuration files (jest, TS config, eslint, etc.)

##### Main Components
a. Frontend Client:
– Show “iremono-web” as the UI layer (React SPA).
– Include key elements: Components, Containers, Services, Store (Redux).
b. API Backend Server:
– Represent “iremono-server” as the Express API layer.
– Partition into areas like Controllers (for handling requests such as auth, files, folders, trash) and Routes.
– Indicate middleware (e.g., authentication, error handling, upload parser, logging).
c. Domain/Business Logic Layer:
– Show separation into layers such as “Entities”, “Use Cases”, “Repositories” (with support for both MySQL and SQLite implementations), and “Services”.
d. Utilities:
– Show “iremono-util” as a helper library that provides cross-cutting functionalities (logging, error handling, file-system operations).
e. Database and Data Access:
– Indicate the persistence layer supporting two types: MySQL and SQLite.
f. Deployment and Infrastructure:
– Include Docker/Docker Compose as the container/infrastructure layer.
– Represent configuration files like Dockerfile and docker-compose.* to illustrate the deployment aspects.

##### Relationships and Interactions
– The Frontend (iremono-web) sends HTTP/REST API calls to the Backend Server (iremono-server).
– The API server delegates business logic to the Core (iremono-backend-core) layer by invoking use cases.
– The backend-core layer communicates with the Persistence layer (either MySQL or SQLite) via data-access repositories.
– Utility services (from iremono-util) might be used across all layers, for logging, file system operations, etc.
- Authentication and encryption services (like access token, refresh token and crypto services) as key cross-cutting concerns.
- Clearly differentiate between external service dependencies (e.g., database service, Docker orchestration) and internal modules.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Divide the system into distinct layers (frontend, API layer, business logic, data access, utilities).
- Modularization: Use monorepo organization to clearly separate concerns (controllers vs. use cases vs. repositories).
- Repository Pattern: Abstract database operations to support both MySQL and SQLite.
- Service Layer: Implement business logic and encryption tokens via dedicated services.
- Client-Driven Encryption: Highlight the zero-knowledge encryption aspect by showing the flow of client encryption keys that never reach the server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["React Frontend"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        API["Express API Server"]:::api
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL["Core Business Logic (Use Cases, Entities, Repositories, Services)"]:::logic
    end

    %% Database Layer
    subgraph "Database Layer"
        DBM["MySQL Database"]:::database
        DBS["SQLite Database"]:::database
    end

    %% Utilities
    subgraph "Utilities"
        UTIL["Utility Library"]:::util
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        D1["Dockerfile"]:::deploy
        D2["docker-compose.mysql.yml"]:::deploy
        D3["docker-compose.sqlite.yml"]:::deploy
        D4[".env.example"]:::deploy
        D5["MySQL Init Scripts"]:::deploy
        D6["SQLite Init Scripts"]:::deploy
    end

    %% Main Data Flow
    FE -->|"HTTP"| API
    API -->|"delegates"| BL
    BL -->|"queries"| DBM
    BL -->|"queries"| DBS

    %% Utilities usage across layers
    FE -->|"uses"| UTIL
    API -->|"uses"| UTIL
    BL -->|"uses"| UTIL

    %% Deployment configuration flows
    D1 -->|"configures"| API
    D2 -->|"configures"| DBM
    D3 -->|"configures"| DBS
    D5 -->|"initializes"| DBM
    D6 -->|"initializes"| DBS

    %% Click Events
    click FE "https://github.com/ryuichi24/iremono-old/tree/main/packages/iremono-web"
    click API "https://github.com/ryuichi24/iremono-old/tree/main/packages/iremono-server"
    click BL "https://github.com/ryuichi24/iremono-old/tree/main/packages/iremono-backend-core"
    click UTIL "https://github.com/ryuichi24/iremono-old/tree/main/packages/iremono-util"
    click DBM "https://github.com/ryuichi24/iremono-old/tree/main/packages/iremono-backend-core/src/infra/data-access/mysql"
    click DBS "https://github.com/ryuichi24/iremono-old/tree/main/packages/iremono-backend-core/src/infra/data-access/sqlite"
    click D1 "https://github.com/ryuichi24/iremono-old/tree/main/Dockerfile"
    click D2 "https://github.com/ryuichi24/iremono-old/blob/main/docker-compose.mysql.yml"
    click D3 "https://github.com/ryuichi24/iremono-old/blob/main/docker-compose.sqlite.yml"
    click D4 "https://github.com/ryuichi24/iremono-old/blob/main/.env.example"
    click D5 "https://github.com/ryuichi24/iremono-old/tree/main/packages/iremono-backend-core/scripts/mysql"
    click D6 "https://github.com/ryuichi24/iremono-old/tree/main/packages/iremono-backend-core/scripts/sqlite"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef api fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef logic fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef util fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef deploy fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
