# libreosteo/libreosteo architecture

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

- Interactive diagram: https://gitdiagram.com/libreosteo/libreosteo
- Repository: https://github.com/libreosteo/libreosteo

## Overview

##### Project type and purpose
- LibreOsteo is a full-stack, Django-based web application for osteopaths to manage patients, documents, examinations, invoicing, etc.
- It ships with both development servers (Django’s runserver, CherryPy via server.py) and production‐ready setups (uWSGI, Nginx/Apache, Docker with PostgreSQL or SQLite).

##### File structure
- Top-level directories:
- Docker/ – Dockerfile variants (git branch builds, http-ready, sock-ready), compose files for dev & prod, scripts to install/uninstall under SQLite or PostgreSQL
- LibreOsteo/ – Django project settings (base.py + environment overrides: dev.py, standalone.py, container.py), WSGI entry, URL router
- libreosteoweb/ – Main Django app: models, views (API & HTML), serializers, management commands, migrations, templates, static assets, unit tests
- zipcode_lookup/ – Secondary app for postal code import & lookup, with its own models, views, migrations, tests
- application.py & server.py – entry points for CherryPy (dev) and uWSGI config
- manage.py – Django CLI
- package.json & yarn.lock – front-end build (JS/CSS) via Yarn/Node
- requirements/ – Python dependencies
- tests/ – Robot Framework acceptance tests
- .github/workflows/main.yml – CI pipeline

##### README
- Lists tech stack: Python 3.8+, Django, Yarn/Node, Docker, PostgreSQL/SQLite, CherryPy, uWSGI, Nginx/Apache.
- Documents install & run flows (virtualenv & manage.py, Docker build/run, make targets).
- Describes environment overrides and volume mappings for data, backups, and database.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers: Client, Infra, App Server, Django, Data
    subgraph "Client Layer"
        direction TB
        Browser["Browser"]:::user
    end

    subgraph "Infrastructure Layer"
        direction TB
        subgraph "HTTP/Reverse-Proxy"
            direction TB
            DevProxy["Dev Proxy\n(docker-compose.yml)"]:::infra
            click DevProxy "https://github.com/libreosteo/libreosteo/blob/master/Docker/build/git/develop/docker-compose.yml"
            ProdProxyHTTP["Prod Proxy\n(HTTP-ready Dockerfile)"]:::infra
            click ProdProxyHTTP "https://github.com/libreosteo/libreosteo/tree/master/Docker/build/http-ready/Dockerfile"
            ProdProxySock["Prod Proxy\n(socket-ready Dockerfile)"]:::infra
            click ProdProxySock "https://github.com/libreosteo/libreosteo/tree/master/Docker/build/sock-ready/Dockerfile"
        end
        subgraph "CI/CD Pipeline"
            direction TB
            GitHubActions["GitHub Actions\n(.github/workflows/main.yml)"]:::infra
            click GitHubActions "https://github.com/libreosteo/libreosteo/blob/master/.github/workflows/main.yml"
            DockerRegistry["Docker Registry"]:::infra
            Deployment["Production Deployment"]:::infra
            click Deployment "https://github.com/libreosteo/libreosteo/blob/master/Docker/deploy/pg/docker-compose.yml"
        end
    end

    subgraph "Front-End Build"
        direction TB
        NodeYarn["Node.js & Yarn\n(package.json)"]:::infra
        click NodeYarn "https://github.com/libreosteo/libreosteo/blob/master/package.json"
        StaticAssets["Static Assets\n(JS/CSS)"]:::user
    end

    subgraph "Application Server Layer"
        direction TB
        CherryPy["CherryPy WSGI\n(application.py)"]:::app
        click CherryPy "https://github.com/libreosteo/libreosteo/blob/master/application.py"
        uWSGI["uWSGI Socket\n(server.py)"]:::app
        click uWSGI "https://github.com/libreosteo/libreosteo/blob/master/server.py"
    end

    subgraph "Django Layer"
        direction TB
        DjangoProj["Django Project"]:::app
        subgraph "Settings"
            direction TB
            BaseSettings["base.py"]:::app
            click BaseSettings "https://github.com/libreosteo/libreosteo/blob/master/Libreosteo/settings/base.py"
            DevSettings["dev.py"]:::app
            click DevSettings "https://github.com/libreosteo/libreosteo/blob/master/Libreosteo/settings/dev.py"
            StandaloneSettings["standalone.py"]:::app
            click StandaloneSettings "https://github.com/libreosteo/libreosteo/blob/master/Libreosteo/settings/standalone.py"
            ContainerSettings["container.py"]:::app
            click ContainerSettings "https://github.com/libreosteo/libreosteo/blob/master/Libreosteo/settings/container.py"
        end
        WSGIEntry["wsgi.py"]:::app
        click WSGIEntry "https://github.com/libreosteo/libreosteo/blob/master/Libreosteo/wsgi.py"
        URLDispatcher["urls.py"]:::app
        click URLDispatcher "https://github.com/libreosteo/libreosteo/blob/master/Libreosteo/urls.py"

        subgraph "Apps"
            direction TB
            subgraph "libreosteoweb"
                direction TB
                LOModels["models.py"]:::app
                click LOModels "https://github.com/libreosteo/libreosteo/blob/master/libreosteoweb/models.py"
                LOViews["views.py & api/views.py"]:::app
                click LOViews "https://github.com/libreosteo/libreosteo/blob/master/libreosteoweb/api/views.py"
                LOViewsHtml["libreosteoweb/views.py"]:::app
                click LOViewsHtml "https://github.com/libreosteo/libreosteo/blob/master/libreosteoweb/views.py"
                LOSerializers["serializers.py"]:::app
                click LOSerializers "https://github.com/libreosteo/libreosteo/blob/master/libreosteoweb/api/serializers.py"
                LOTemplates["templates/"]:::app
                click LOTemplates "https://github.com/libreosteo/libreosteo/tree/master/libreosteoweb/templates/"
                LOStatic["static/"]:::app
                click LOStatic "https://github.com/libreosteo/libreosteo/tree/master/libreosteoweb/static/"
                LOCommands["backup_db.py"]:::app
                click LOCommands "https://github.com/libreosteo/libreosteo/blob/master/libreosteoweb/management/commands/backup_db.py"
            end
            subgraph "zipcode_lookup"
                direction TB
                ZLModels["models.py"]:::app
                click ZLModels "https://github.com/libreosteo/libreosteo/blob/master/zipcode_lookup/models.py"
                ZLViews["views.py"]:::app
                click ZLViews "https://github.com/libreosteo/libreosteo/blob/master/zipcode_lookup/views.py"
                ZLCommands["import_zipcodes.py"]:::app
                click ZLCommands "https://github.com/libreosteo/libreosteo/blob/master/zipcode_lookup/management/commands/import_zipcodes.py"
                ZLURLs["urls.py"]:::app
                click ZLURLs "https://github.com/libreosteo/libreosteo/blob/master/zipcode_lookup/urls.py"
            end
        end

        ManageCLI["manage.py"]:::app
        click ManageCLI "https://github.com/libreosteo/libreosteo/blob/master/manage.py"
    end

    subgraph "Data Layer"
        direction TB
        subgraph "Databases"
            direction TB
            SQLiteDB["SQLite (file)"]:::data
            PostgresDB["PostgreSQL (container)"]:::data
        end
        FileVolume["File Volume\n(uploads/backups)"]:::data
    end

    %% Flows
    Browser -->|HTTP/S| DevProxy
    Browser -->|HTTP/S| ProdProxyHTTP
    Browser -->|HTTP/S| ProdProxySock
    DevProxy -->|FastCGI/Socket| CherryPy
    DevProxy -->|FastCGI/Socket| uWSGI
    ProdProxyHTTP -->|Socket| uWSGI
    ProdProxySock -->|Socket| uWSGI

    CherryPy --> DjangoProj
    uWSGI --> DjangoProj

    DjangoProj --> BaseSettings
    DjangoProj --> DevSettings
    DjangoProj --> StandaloneSettings
    DjangoProj --> ContainerSettings
    DjangoProj --> WSGIEntry
    DjangoProj --> URLDispatcher
    DjangoProj --> ManageCLI

    DjangoProj --> LOModels
    DjangoProj --> LOViews
    DjangoProj --> LOViewsHtml
    DjangoProj --> LOSerializers
    DjangoProj --> LOTemplates
    DjangoProj --> LOStatic
    DjangoProj --> LOCommands

    DjangoProj --> ZLModels
    DjangoProj --> ZLViews
    DjangoProj --> ZLCommands
    DjangoProj --> ZLURLs

    LOModels --> SQLiteDB
    LOModels --> PostgresDB
    ZLModels --> SQLiteDB
    ZLModels --> PostgresDB
    LOCommands --> FileVolume
    ZLCommands --> SQLiteDB

    NodeYarn --> StaticAssets
    StaticAssets --> DevProxy
    StaticAssets --> ProdProxyHTTP

    GitHubActions --> DockerRegistry
    DockerRegistry --> Deployment
    Deployment --> ProdProxyHTTP
    Deployment --> uWSGI
    Deployment --> PostgresDB

    %% Styles
    classDef user fill:#b2f2bb,stroke:#2f6627,color:#000
    classDef infra fill:#e3e3e3,stroke:#999,color:#000
    classDef app fill:#add8e6,stroke:#31708f,color:#000
    classDef data fill:#ffd8b1,stroke:#e68a00,color:#000
```
