# tilacl/readcycle architecture

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

## Overview

##### Project Type and Purpose
- ReadCycle is a hybrid mobile and web marketplace for used books.
- It’s built using Ionic Angular for the frontend with Capacitor for native Android (and potentially iOS) support.
- Firebase is used for data storage and user authentication, and there are integrations with external APIs (WhatsApp API for direct communications and PayPal API for optional donations).

##### File Structure
- There are clear separations between mobile-native code (the “android” directory) and the Angular frontend code (the “src” folder).
- The Angular project is set up with multiple pages/components (login, profile, publication, details, favorites, etc.) and a service layer (in the “src/services” directory) which encapsulates business logic such as authentication, image uploading, geocoding, and publication management.
- Configuration and build files (e.g., capacitor.config.ts, angular.json, firebase.json, package.json) are present to support different parts of the deployment and development process.
- The directories and naming conventions (e.g., “tabs”, “login”, “publicar”, “detalles-publicacion”) indicate an MVC (or MVVM) style where UI components are supported by services that manage data and business rules.

a. Main Components:
- Frontend (Ionic Angular application):
- Contains UI components/pages (login, home/inicio, publication, detail views, etc.)
- Uses Angular modules and routing (see app-routing.module.ts and tabs-routing.module.ts)
- Includes assets and styling (global.scss, theme files)
- Service Layer:
- Angular Services (auth, image-upload, geocoding, publication, usuario) that encapsulate business logic and integrate with external systems.
- Native Layer via Capacitor:
- “android” folder shows native Android configuration and code integration.
- This layer enables native functionalities (push notifications, file access, etc.) and provides the bridge between the web code and mobile platform (via Capacitor).
- Backend / External Integrations:
- Firebase: used for data storage, authentication, and real-time updates.
- Third-Party APIs:
▪ WhatsApp API for direct messaging interactions.
▪ PayPal API for donation processing and managing certain transactions.

b. Relationships and Interactions:
- The Ionic Angular frontend communicates with the service layer to perform business operations (e.g., user authentication, image upload).
- These services in turn interact with Firebase for storage and authentication.
- When required, the service layer also makes API calls to external services such as WhatsApp and PayPal.
- Capacitor acts as a connector between the web-based code and the native device functionalities (notably visible in the “android” folder for native integration).

c. Architectural Patterns/Design Principles:
- Separation of concerns: UI components are kept distinct from business logic services.
- Modular design: Angular modules are structured by feature (e.g., login, profile, publication) which aids in maintenance and scalability.
- Hybrid mobile approach: Using Capacitor ensures that the same core web code can run both as a progressive web app and as a native mobile app.
- Integration with Backend as a Service (Firebase) offloads many backend concerns to a managed service.

d. Technologies and Frameworks:
- Ionic Angular (for UI and frontend development)
- Angular (framework for application structure and routing)
- Capacitor (for native device feature integration)
- Firebase (for authentication, database, and possibly file storage)
- External APIs (WhatsApp and PayPal)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        UI1["Ionic Angular UI Components"]:::frontend
        UI2["Angular Routing & Modules"]:::frontend
    end

    subgraph "Services Layer"
        SERVICES["Services / Business Logic"]:::services
    end

    subgraph "Native Layer (Capacitor Integration)"
        CAPCONFIG["Capacitor Config"]:::native
        ANDROID["Android Native"]:::native
    end

    subgraph "External Services"
        FIREBASE["Firebase Backend"]:::external
        WHATSAPP["WhatsApp API"]:::external
        PAYPAL["PayPal API"]:::external
    end

    UI1 -->|"callsServices"| SERVICES
    UI2 -->|"routesToServices"| SERVICES
    SERVICES -->|"callsFirebase"| FIREBASE
    SERVICES -->|"callsWhatsApp"| WHATSAPP
    SERVICES -->|"callsPayPal"| PAYPAL
    UI1 -->|"nativeInvoke"| CAPCONFIG
    UI1 -->|"nativeInvoke"| ANDROID

    click UI1 "https://github.com/tilacl/readcycle/tree/main/src/app"
    click UI2 "https://github.com/tilacl/readcycle/blob/main/src/app/app-routing.module.ts"
    click SERVICES "https://github.com/tilacl/readcycle/tree/main/src/services"
    click CAPCONFIG "https://github.com/tilacl/readcycle/blob/main/capacitor.config.ts"
    click ANDROID "https://github.com/tilacl/readcycle/tree/main/android"
    click FIREBASE "https://github.com/tilacl/readcycle/blob/main/firebase.json"

    classDef frontend fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef services fill:#ABEBC6,stroke:#2E8B57,stroke-width:2px;
    classDef native fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
