# eorate/petsrus architecture

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

- Interactive diagram: https://gitdiagram.com/eorate/petsrus
- Repository: https://github.com/eorate/petsrus

## Overview

##### Main Components Identification

The project is a Flask web application with the following key components:

a) Web Layer:
- Flask application server
- Gunicorn (production server)
- Frontend templates (Bootstrap-based)

b) Data Layer:
- SQLAlchemy ORM
- PostgreSQL/SQLite database
- Alembic for database migrations

c) External Services:
- AWS S3/Backblaze for image storage
- Sentry for error tracking

##### Architecture Pattern

The application follows an MVC-like pattern:
- Models: petsrus/models/
- Views: petsrus/views/
- Templates: petsrus/templates/
- Forms: petsrus/forms/

- Web Browser
- Static Assets (CSS)

- Flask Application Server
- Views (Route Handlers)
- Forms (Input Validation)
- Templates (Jinja2)

- SQLAlchemy ORM
- Database (PostgreSQL/SQLite)

- AWS S3/Backblaze
- Sentry

##### Component Relationships

- HTTP requests from client to server
- Template rendering flow
- Database queries through ORM
- File uploads to S3/Backblaze
- Error reporting to Sentry

##### Important Details

Authentication Flow:
- User registration/login paths
- Session management

Data Flow:
- Pet management operations
- Schedule management
- Image upload pipeline

##### Specific Implementation Notes

- Configuration management (config.py)
- Database migration handling (alembic)
- Test infrastructure
- Development vs Production environments

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        StaticAssets["Static Assets"]:::frontend
    end

    subgraph "Application Layer"
        Flask["Flask App Server"]:::app
        click Flask "https://github.com/Eorate/petsrus/blob/master/petsrus/petsrus.py"
        
        subgraph "Web Components"
            Templates["Jinja2 Templates"]:::frontend
            click Templates "https://github.com/Eorate/petsrus/tree/master/petsrus/templates/"
            Forms["Form Validation"]:::app
            click Forms "https://github.com/Eorate/petsrus/blob/master/petsrus/forms/forms.py"
            Views["Route Handlers"]:::app
            click Views "https://github.com/Eorate/petsrus/blob/master/petsrus/views/main.py"
        end
        
        subgraph "Core Features"
            PetMgmt["Pet Management"]:::feature
            click PetMgmt "https://github.com/Eorate/petsrus/blob/master/petsrus/templates/pets.html"
            Schedule["Schedule Management"]:::feature
            click Schedule "https://github.com/Eorate/petsrus/blob/master/petsrus/templates/pet_schedule.html"
            Auth["Authentication"]:::feature
            click Auth "https://github.com/Eorate/petsrus/blob/master/petsrus/templates/register.html"
        end
    end

    subgraph "Data Layer"
        ORM["SQLAlchemy ORM"]:::data
        Models["Data Models"]:::data
        click Models "https://github.com/Eorate/petsrus/blob/master/petsrus/models/models.py"
        DB[(PostgreSQL/SQLite)]:::database
        Migrations["Alembic Migrations"]:::data
        click Migrations "https://github.com/Eorate/petsrus/tree/master/alembic/"
    end

    subgraph "External Services"
        S3["AWS S3/Backblaze"]:::external
        Sentry["Sentry Error Tracking"]:::external
    end

    subgraph "Development Infrastructure"
        Tests["Test Suite"]:::infra
        click Tests "https://github.com/Eorate/petsrus/tree/master/petsrus/tests/"
        Config["Configuration"]:::infra
        click Config "https://github.com/Eorate/petsrus/blob/master/config.py"
        CI["CI/CD Pipeline"]:::infra
        click CI "https://github.com/Eorate/petsrus/blob/master/.circleci/config.yml"
    end

    Browser --> Flask
    StaticAssets --> Browser
    click StaticAssets "https://github.com/Eorate/petsrus/tree/master/petsrus/static/"

    Flask --> Templates
    Flask --> Forms
    Flask --> Views

    Views --> PetMgmt
    Views --> Schedule
    Views --> Auth

    PetMgmt --> ORM
    Schedule --> ORM
    Auth --> ORM

    ORM --> Models
    Models --> DB
    Migrations --> DB

    PetMgmt --> S3
    Flask --> Sentry

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:#fff
    classDef app fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef feature fill:#e74c3c,stroke:#c0392b,color:#fff
    classDef data fill:#f1c40f,stroke:#f39c12,color:#fff
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:#fff
    classDef external fill:#9b59b6,stroke:#8e44ad,color:#fff
    classDef infra fill:#34495e,stroke:#2c3e50,color:#fff

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        AppComponent["Application Component"]:::app
        FeatureModule["Feature Module"]:::feature
        DataComponent["Data Component"]:::data
        DatabaseComponent["Database"]:::database
        ExternalService["External Service"]:::external
        Infrastructure["Infrastructure"]:::infra
    end
```
