# phoebey05/reading-records architecture

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

- Interactive diagram: https://gitdiagram.com/phoebey05/reading-records
- Repository: https://github.com/phoebey05/reading-records

## Overview

##### Project Type and Purpose
- Project Type: A full-stack web application built using Flask. It manages and displays a reading record of unpublished books (from sites like Wattpad and 晋江文学城).
- Purpose: To track reading statuses, categorize books (Completed, Unfinished, To Be Read), and offer user-specific functionality (login, personal book lists, timeline views, search, etc.).

##### File Structure
- Key Files and Directories:
- app.py: Main Flask application file, handling routes and core logic.
- books.db: SQLite database storing data related to books and user information.
- templates/: Contains Jinja2 HTML templates (e.g., home, login, register, book lists, etc.) which serve as the view.
- static/: Contains static assets such as CSS styling (e.g., styles.css).
- requirements.txt: Lists dependencies (Flask, Jinja2, SQLite libraries, etc.).
- README.md: Provides a high-level overview, usage instructions, and some feature details.
- Architectural Hints:
- The separation between view templates and business logic in app.py hints at an MVC-like pattern.
- Static assets are clearly separated from dynamic content.
- The inclusion of a database file (books.db) suggests persistence and data layering.

##### README for Additional Insights
- The README outlines features such as login functionality, categorizing books into different statuses, search functionality, and timeline views.
- It lists technologies used (Flask, Jinja, SQLite, etc.), which helps in labeling technology stacks in the system design.

a. Main Components to Represent:
- Frontend Client (Browser/View Layer): Represent HTML/CSS/JavaScript components rendered via Jinja templates. This is where users interact with forms (login, search, view book lists, etc.).
- Application Server (Backend): The Flask “app.py” acts as the controller handling HTTP requests, processing business logic, and rendering templates.
- Database: The SQLite database (books.db) storing user information, book records and statuses.
- Static Assets: Folder (static/) containing CSS and possibly JavaScript files, ensuring the look-and-feel.
- Optional: External dependencies or integrations (e.g., Bootstrap, used for UI design).

b. Relationships and Interactions:
- User Interface (Browser) sends HTTP requests to the Flask application.
- Flask app (in app.py) processes these requests: authenticates user (login/register), queries the SQLite database, and renders appropriate HTML via the Jinja templates.
- The static assets are served to style and add client-side interactivity.
- Requests flow from client browser to application server.
- Data flows between the application server and the SQLite database.
- Data is rendered through the view (templates) back to the browser.

c. Architectural Patterns and Principles:
- MVC-like Pattern: Although not explicitly named, the project separates concerns with:
- Model: The SQLite database (books.db).
- View: HTML templates (under templates/) enhanced by static files.
- Controller: Flask routes and logic in app.py.
- Emphasis on RESTful principles for handling different pages and actions (login, register, add books, searches, etc.).

d. Technologies to Include:
- Flask: For application server (routing, request handling, business logic).
- Jinja2: For dynamic HTML rendering.
- SQLite: For persistent storage.
- HTML/CSS/JavaScript & Bootstrap: For front-end user interface and styling.
- Any session management or security layers implied by login functionality.

##### What to Highlight
- The entire flow: User request (e.g., login or book addition) reaches Flask backend → Processes request → Fetches/updates records in SQLite → Renders updated Jinja template → Response delivered to the user.
- Extended functionalities according to features listed in the README (e.g., timeline views, search filters, and status updating) as separate interactions or sub-components within the application server.
- If desired, note possible improvement points from the README which may later affect the design (e.g., integrating external book websites for status updates).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    ClientBrowser["Client Browser"]:::frontend
    FlaskServer["Flask Application Server"]:::backend
    Database["SQLite Database"]:::database
    Templates["Jinja Templates"]:::view
    StaticAssets["Static Assets"]:::static

    %% Flow of interactions
    ClientBrowser -->|"HTTP_Request"| FlaskServer
    FlaskServer -->|"CRUD_Operations"| Database
    Database -->|"Data_Response"| FlaskServer
    FlaskServer -->|"Render_HTML"| Templates
    Templates -->|"HTML_Response"| ClientBrowser
    FlaskServer -->|"Serve_Static"| StaticAssets
    StaticAssets -->|"Static_Content"| ClientBrowser

    %% Click Events
    click Templates "https://github.com/phoebey05/reading-records/tree/main/templates/"
    click FlaskServer "https://github.com/phoebey05/reading-records/blob/main/app.py"
    click Database "https://github.com/phoebey05/reading-records/blob/main/books.db"
    click StaticAssets "https://github.com/phoebey05/reading-records/tree/main/static/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef view fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef static fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
