# kevinfd95/bibliapp architecture

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

- Interactive diagram: https://gitdiagram.com/kevinfd95/bibliapp
- Repository: https://github.com/kevinfd95/bibliapp

## Overview

##### Project type and purpose
- Bibliapp is a full-stack, cross-platform mobile application. The frontend is implemented in React Native (Android/iOS) and the backend is a Flask (Python) REST API. Its purpose is to let users organize, search, read and purchase books/ebooks, with features like collections management, advanced search, recommendations, user profiles and PDF/EPUB viewing.

##### File structure
- Top-level:
- frontend/ → React Native app organized by assets, src (components, views, controllers, api, context, services, styles)
- backend/ → Flask project with MVC folders: controllers, models, services, routes, validations, database connection, migrations, commands, feeders, tests
- database/ → raw SQL schema
- MVC pattern in the backend:
- routes → HTTP endpoints
- controllers → business logic entry points
- services → reusable logic (API responses, file converters, notifications)
- models → ORM/mapping objects
- database → connection & query utilities
- feeders & migrations → schema evolution & seeding
- Configuration/build: requirements.txt, package.json, migration scripts, secret key generator, test fixtures.

##### README for additional insights
- Confirms MVC pattern, tech stack (React Native, Flask, MySQL), JWT for auth, encryption via Bcrypt/SSL, integration points (Firebase/AWS S3 for storage).
- Outlines key modules: collection management, search/filters, recommendation engine, user management, ebook viewer.

##### Additional advice
- Every major folder as a component (e.g., converters, notifications, validations).
- Cross-cutting middleware (JWT/token_required) as an overlay or distinct path through the request flow.
- Migration & feeder tools as part of the deployment/process pipeline off to one side.
- Keep it high-level enough to fit on a single slide but detailed in showing each layer of the MVC chain and external integrations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend: React Native" 
        direction TB
        MA[("Mobile App")]:::frontend
        subgraph " API Layer" 
            direction TB
            FAPI["Frontend API Layer"]:::frontend
        end
        subgraph " Controllers" 
            direction TB
            FCTRL["Frontend Controllers"]:::frontend
        end
        subgraph " Views & Components" 
            direction TB
            FV["Frontend Views (UI Screens)"]:::frontend
            FCMP["Frontend Components"]:::frontend
        end
        subgraph " State & Validation" 
            direction TB
            FCTX["Frontend Context Providers"]:::frontend
            FVAL["Frontend Validators"]:::frontend
        end
        subgraph " Services & Styles" 
            direction TB
            FSRV["Frontend Services"]:::frontend
            FSTY["Frontend Styles & Themes"]:::frontend
        end
    end

    %% API Gateway
    APIGW["API Gateway (HTTPS)"]:::backend

    %% Backend Layer
    subgraph "Backend API (Flask)" 
        direction TB
        BR[("Routes")]:::backend
        BM[("Controllers")]:::backend
        BSVC[("Services")]:::backend
        BMDL[("Models")]:::backend
        BDBCON[("DB Connection")]:::backend
        subgraph " Middlewares" 
            direction TB
            JWT["JWT Auth Middleware"]:::backend
            ADM["Admin Check Middleware"]:::backend
        end
        HELP["Helpers"]:::backend
        CONF["Configuration & Secrets"]:::backend
        CLI["Migration & Rollback Commands"]:::backend
        MIGR["Migrations"]:::backend
        FEED["Seeders/Feeders"]:::backend
        TEST["Backend Tests"]:::backend
    end

    %% External Services
    subgraph "External Services" 
        direction TB
        DB["MySQL Database"]:::db
        AUTH["JWT Auth Provider"]:::ext
        STORAGE["AWS S3 / Firebase Storage"]:::ext
    end

    %% Flows
    MA -->|"/api/*"| APIGW
    APIGW -->|routes request| BR
    BR -->|invoke| JWT
    JWT -->|authenticate| ADM
    ADM -->|authorize| BM
    BM -->|use| BSVC
    BSVC -->|read/write| BDBCON
    BDBCON -->|query| DB
    BSVC -->|store/retrieve| STORAGE
    BSVC -->|validate token| AUTH

    MA -->|UI actions| FV
    FV -->|dispatch| FCTRL
    FCTRL -->|call| FAPI
    FAPI -->|HTTP request| APIGW
    FCTRL -->|use| FSRV
    FCTX -->|provide state| FV
    FVAL -->|validate| FAPI
    FSTY -->|style| FV & FCMP
    FCMP -->|used by| FV

    %% Auxilliary processes
    CLI -->|runs| MIGR
    CLI -->|runs| FEED
    MIGR -->|update schema| DB
    FEED -->|seed data| DB
    TEST -->|test| BM & BSVC & BMDL

    %% Click Events Frontend
    click MA "https://github.com/kevinfd95/bibliapp/tree/main/frontend/src"
    click FAPI "https://github.com/kevinfd95/bibliapp/tree/main/frontend/src/api"
    click FCTRL "https://github.com/kevinfd95/bibliapp/tree/main/frontend/src/controllers"
    click FV "https://github.com/kevinfd95/bibliapp/tree/main/frontend/src/views"
    click FCMP "https://github.com/kevinfd95/bibliapp/tree/main/frontend/src/components"
    click FCTX "https://github.com/kevinfd95/bibliapp/tree/main/frontend/src/context"
    click FSRV "https://github.com/kevinfd95/bibliapp/blob/main/frontend/src/services/docViewService.js"
    click FVAL "https://github.com/kevinfd95/bibliapp/blob/main/frontend/src/validators/registerValidation.js"
    click FSTY "https://github.com/kevinfd95/bibliapp/blob/main/frontend/src/styles/globalStyles.js"
    click FSTY "https://github.com/kevinfd95/bibliapp/blob/main/frontend/src/config/darkTheme.js"
    click FSTY "https://github.com/kevinfd95/bibliapp/blob/main/frontend/src/config/lightTheme.js"

    %% Click Events Backend
    click BR "https://github.com/kevinfd95/bibliapp/tree/main/backend/app/routes"
    click BM "https://github.com/kevinfd95/bibliapp/tree/main/backend/app/controllers"
    click BSVC "https://github.com/kevinfd95/bibliapp/blob/main/backend/app/services/api_response_service.py"
    click BSVC "https://github.com/kevinfd95/bibliapp/blob/main/backend/app/services/pdf_converter_service.py"
    click BSVC "https://github.com/kevinfd95/bibliapp/blob/main/backend/app/services/epub_converter_service.py"
    click BSVC "https://github.com/kevinfd95/bibliapp/blob/main/backend/app/services/resend_service.py"
    click BMDL "https://github.com/kevinfd95/bibliapp/tree/main/backend/app/models"
    click BDBCON "https://github.com/kevinfd95/bibliapp/blob/main/backend/app/database/connection.py"
    click BDBCON "https://github.com/kevinfd95/bibliapp/blob/main/backend/app/database/queries.py"
    click JWT "https://github.com/kevinfd95/bibliapp/blob/main/backend/app/middlewares/token_required_middleware.py"
    click ADM "https://github.com/kevinfd95/bibliapp/blob/main/backend/app/middlewares/admin_required_middleware.py"
    click HELP "https://github.com/kevinfd95/bibliapp/tree/main/backend/app/helpers"
    click MIGR "https://github.com/kevinfd95/bibliapp/tree/main/backend/migrations"
    click FEED "https://github.com/kevinfd95/bibliapp/tree/main/backend/feeders"
    click CLI "https://github.com/kevinfd95/bibliapp/tree/main/backend/commands"
    click CONF "https://github.com/kevinfd95/bibliapp/blob/main/backend/config.py"
    click CONF "https://github.com/kevinfd95/bibliapp/blob/main/backend/secretkeygenerator.py"
    click TEST "https://github.com/kevinfd95/bibliapp/tree/main/backend/tests"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ext fill:#FFD580,stroke:#000,stroke-width:1px
    classDef db fill:#FFCCCB,stroke:#000,stroke-width:1px
```
