# isaacangyu/therapy-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/isaacangyu/therapy-chatbot
- Repository: https://github.com/isaacangyu/therapy-chatbot

## Overview

##### Main Components
- Backend Server:
- Directory clues: “therapy_chatbot” (contains asgi.py, wsgi.py, settings.py, urls.py) and “core” (Django models, views, migrations).
- Purpose: Supplies APIs, business logic, session management, and authentication features (e.g., forgot password functionality and future OAuth support).
- Frontend Client:
- Directory clues: “lib”, “android”, “ios”, “web”, “macos”, “linux”, “windows”.
- Purpose: Flutter-based UI that runs on multiple platforms (mobile, desktop, web). The “lib” directory shows separation into modules (login, journal, profile, breathing, etc.) and various widgets.
- API Configuration & Assets:
- “api” folder contains JSON configurations (for base URL, forgot password info, latest app version) to standardize API endpoints and versioning.
- Database Layer & Schema Management:
- “drift_schemas” (and corresponding “test/drift”) indicate that the application uses Drift (a Dart ORM for SQLite) to manage local persistence and DB migrations on the client side.
- DevOps / CI & Environment Setup:
- “.devcontainer”, “.github”, and “scripts” directories suggest containerized development (Docker), dependency checking, migration automation, and various startup scripts (backend/frontend/combined tests).
- Certificates & Security:
- “cert” folder includes test certificate files to support secure communications—likely for tests or encrypted operations.
- Documentation & Tooling:
- “docs” directory provides developer and project setup guidance.
- “tool” and configuration files (e.g., pubspec.yaml, requirements.txt) help manage dependencies and builds.

##### Relationships and Interactions
- The Flutter client operates across platforms (Android, iOS, Web, Desktop) with shared business logic contained in “lib”.
- Local data persistence within the Flutter client is managed by Drift, with migration scripts and schema files showing version changes.
- DevOps components (Docker config, CI scripts) are used to build, test, and deploy both client and backend.
- The “api” and “app_assets” directories are used to configure dynamic elements (such as base URLs and app version tracking) which integrate into both the mobile frontend and the backend server.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Backend (Django) is isolated from the front-end (Flutter); the two communicate via clearly defined APIs.
- Multi-Platform Development:
- The Flutter client is organized to allow for code reuse across mobile, desktop, and web platforms.
- Schema Versioning & Migrations:
- Use of Drift for managing local database state on the client side.
- Environment Isolation:
- Use of Docker (.devcontainer) and CI/CD configurations (.github, scripts) ensures standardized development environments.

##### Relevant Technologies, Frameworks, and Libraries
- Django/Python for backend API services.
- Flutter (with Dart) for the client, including separation into UI, business logic, and common utilities.
- Drift for local SQLite database management in Flutter.
- DevOps tooling such as Docker, GitHub Actions/Dependabot, and various shell scripts.
- Standard mobile platform resources (Android/iOS specific folders) for platform-specific configurations.

- Use clear, descriptive labels for each major component, e.g., “Django Backend API”, “Flutter Client – Login Module”, “Local Persistence (Drift/SQLite)”, etc.
- Another for frontend components (e.g., green shades),
- And possibly a third for shared tools/dev-ops (e.g., orange or gray).
- Notes or call-outs for future features such as OAuth integration or email sending that indicate upcoming changes in the architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Backend Section
    subgraph "Backend"
        B1["Django Project (therapy_chatbot)"]
        B2["Core App (core)"]
    end

    %% API Configuration & Assets Section
    subgraph "API & Assets"
        API1["API Config (api)"]
        API2["App Assets (app_assets)"]
    end

    %% Frontend Section
    subgraph "Frontend"
        F1["Flutter Client (lib)"]
        F2["Android (android)"]
        F3["iOS (ios)"]
        F4["Web (web)"]
        F5["Linux (linux)"]
        F6["macOS (macos)"]
        F7["Windows (windows)"]
        F8["Local Persistence (Drift/SQLite) (drift_schemas)"]
        F9["Drift Tests (test/drift)"]
    end

    %% DevOps & Tooling Section
    subgraph "DevOps & Tooling"
        D1[".devcontainer"]
        D2[".github"]
        D3["Scripts (scripts)"]
        D4["Certificates (cert)"]
        D5["Docs (docs)"]
        D6["Tooling (tool)"]
        D7["pubspec.yaml"]
        D8["requirements.txt"]
        D9["devtools_options.yaml"]
    end

    %% Relationships between components
    %% Backend internal
    B1 -->|"Uses"| B2

    %% API & Assets integrations
    API1 ---|"Configures"| B1
    API1 ---|"Configures"| F1
    API2 ---|"ProvidesAssets"| B1
    API2 ---|"ProvidesAssets"| F1

    %% Frontend platform distribution
    F1 --> F2
    F1 --> F3
    F1 --> F4
    F1 --> F5
    F1 --> F6
    F1 --> F7

    %% Frontend local persistence
    F1 -->|"UsesLocalDB"| F8
    F8 -->|"ValidatedBy"| F9

    %% Client to Backend communication
    F1 -->|"APICalls"| B1

    %% DevOps & Tooling integration with both Backend and Frontend
    D1 -->|"ContainerDev"| B1
    D1 -->|"ContainerDev"| F1
    D2 -->|"CI/CD"| B1
    D2 -->|"CI/CD"| F1
    D3 -->|"Automation"| B1
    D3 -->|"Automation"| F1
    D4 -->|"Security"| B1
    D4 -->|"Security"| F1
    D5 -->|"Documentation"| B1
    D5 -->|"Documentation"| F1
    D6 -->|"BuildTools"| F1
    D7 -->|"Dependency"| F1
    D8 -->|"Dependency"| B1
    D9 -->|"Devtools"| F1

    %% Styling Nodes
    class B1,B2 backend
    class F1,F2,F3,F4,F5,F6,F7 frontend
    class F8,F9 db
    class API1,API2 config
    class D1,D2,D3,D4,D5,D6,D7,D8,D9 devops

    %% Class Definitions
    classDef backend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef frontend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef devops fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef config fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef db fill:#E6E6FA,stroke:#000,stroke-width:2px;

    %% Click Events for Component Mapping
    click B1 "https://github.com/isaacangyu/therapy-chatbot/tree/main/therapy_chatbot"
    click B2 "https://github.com/isaacangyu/therapy-chatbot/tree/main/core"
    click F1 "https://github.com/isaacangyu/therapy-chatbot/tree/main/lib"
    click F2 "https://github.com/isaacangyu/therapy-chatbot/tree/main/android"
    click F3 "https://github.com/isaacangyu/therapy-chatbot/tree/main/ios"
    click F4 "https://github.com/isaacangyu/therapy-chatbot/tree/main/web"
    click F5 "https://github.com/isaacangyu/therapy-chatbot/tree/main/linux"
    click F6 "https://github.com/isaacangyu/therapy-chatbot/tree/main/macos"
    click F7 "https://github.com/isaacangyu/therapy-chatbot/tree/main/windows"
    click API1 "https://github.com/isaacangyu/therapy-chatbot/tree/main/api"
    click API2 "https://github.com/isaacangyu/therapy-chatbot/tree/main/app_assets"
    click F8 "https://github.com/isaacangyu/therapy-chatbot/tree/main/drift_schemas"
    click F9 "https://github.com/isaacangyu/therapy-chatbot/tree/main/test/drift"
    click D1 "https://github.com/isaacangyu/therapy-chatbot/blob/main/.devcontainer"
    click D2 "https://github.com/isaacangyu/therapy-chatbot/blob/main/.github"
    click D3 "https://github.com/isaacangyu/therapy-chatbot/tree/main/scripts"
    click D4 "https://github.com/isaacangyu/therapy-chatbot/tree/main/cert"
    click D5 "https://github.com/isaacangyu/therapy-chatbot/tree/main/docs"
    click D6 "https://github.com/isaacangyu/therapy-chatbot/tree/main/tool"
    click D7 "https://github.com/isaacangyu/therapy-chatbot/blob/main/pubspec.yaml"
    click D8 "https://github.com/isaacangyu/therapy-chatbot/blob/main/requirements.txt"
    click D9 "https://github.com/isaacangyu/therapy-chatbot/blob/main/devtools_options.yaml"
```
