# jllorencetti/pets architecture

> Architecture diagram of the GitHub repository jllorencetti/pets, 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/jllorencetti/pets
- Repository: https://github.com/jllorencetti/pets

## Overview

##### Main Components

a. Frontend Layer:
- Static content (CSS, JS, images) in /static
- Template system with layouts and partials in /templates
- Separate template directories for each app component

b. Backend Layer (Django Apps):
- Main apps:
- meupet (core pet functionality)
- users (user management)
- cities (location management)
- common (shared functionality)
- api (REST API interface)

c. External Services:
- Social Authentication (Facebook, Twitter)
- SendGrid (Email service)
- Database (PostgreSQL)
- Media Storage (for pet images)

##### Architecture Pattern Representation

System following Django's MVT (Model-View-Template) pattern:
**[Client Browser] ←→ [Django URLs/Views] ←→ [Models] ←→ [Database]**
- ↑
- → [Templates] ←→ [Static Files]

##### Component Relationships

- User authentication flow through social providers
- Image processing pipeline (upload → easy-thumbnails processing)
- Database interactions
- API endpoints communication
- Email notification system

##### Specific Elements

a. Core Features:
- Pet registration system
- User management
- Location services
- Image handling
- Search functionality
- Social media integration

b. Supporting Services:
- Email notifications
- Social authentication
- Image processing
- API endpoints

##### Detailed Component Breakdown

Subcomponents for each main app:
**meupet/**
- Models (Pet, Photo)
- Views (registration, search, status updates)
- Forms
- Services (Facebook sharing, image processing)

**users/**
- Models (OwnerProfile)
- Authentication
- Social Integration

**cities/**
- Models (City, State)
- Location Services

##### Data Flow Indicators

- User request flow
- Authentication processes
- Database operations
- External service communications
- Media handling

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]:::client
    end

    subgraph "Frontend Layer"
        Static["Static Content"]:::frontend
        Templates["Template System"]:::frontend
        click Static "https://github.com/jllorencetti/pets/tree/master/pets/static/"
        click Templates "https://github.com/jllorencetti/pets/blob/master/pets/templates/_layouts/base.html"
    end

    subgraph "Django Apps"
        direction TB
        subgraph "Core Pet Module"
            MeupetModels["Pet Models"]:::core
            MeupetViews["Pet Views"]:::core
            MeupetForms["Pet Forms"]:::core
            MeupetServices["Pet Services"]:::core
            click MeupetModels "https://github.com/jllorencetti/pets/blob/master/pets/meupet/models.py"
            click MeupetViews "https://github.com/jllorencetti/pets/blob/master/pets/meupet/views.py"
            click MeupetForms "https://github.com/jllorencetti/pets/blob/master/pets/meupet/forms.py"
            click MeupetServices "https://github.com/jllorencetti/pets/blob/master/pets/meupet/services.py"
        end

        subgraph "User Management"
            UserModels["User Models"]:::user
            UserViews["User Views"]:::user
            UserForms["User Forms"]:::user
            click UserModels "https://github.com/jllorencetti/pets/blob/master/pets/users/models.py"
            click UserViews "https://github.com/jllorencetti/pets/blob/master/pets/users/views.py"
            click UserForms "https://github.com/jllorencetti/pets/blob/master/pets/users/forms.py"
        end

        subgraph "Location Services"
            CityModels["City Models"]:::location
            CityViews["City Views"]:::location
            CityUtils["City Utils"]:::location
            click CityModels "https://github.com/jllorencetti/pets/blob/master/pets/cities/models.py"
            click CityViews "https://github.com/jllorencetti/pets/blob/master/pets/cities/views.py"
            click CityUtils "https://github.com/jllorencetti/pets/blob/master/pets/cities/utils.py"
        end

        subgraph "API Layer"
            APIViews["API Views"]:::api
            APISerializers["API Serializers"]:::api
            click APIViews "https://github.com/jllorencetti/pets/blob/master/pets/api/views.py"
            click APISerializers "https://github.com/jllorencetti/pets/blob/master/pets/api/serializers.py"
        end

        subgraph "Common Functions"
            CommonModels["Common Models"]:::common
            CommonViews["Common Views"]:::common
            CommonUtils["Common Utils"]:::common
            click CommonModels "https://github.com/jllorencetti/pets/blob/master/pets/common/models.py"
            click CommonViews "https://github.com/jllorencetti/pets/blob/master/pets/common/views.py"
            click CommonUtils "https://github.com/jllorencetti/pets/blob/master/pets/common/utils.py"
        end
    end

    subgraph "External Services"
        DB[(PostgreSQL)]:::database
        SocialAuth["Social Auth"]:::external
        SendGrid["SendGrid Email"]:::external
        MediaStorage["Media Storage"]:::external
    end

    subgraph "Configuration"
        Settings["Django Settings"]:::config
        click Settings "https://github.com/jllorencetti/pets/tree/master/pets/pets/settings/"
    end

    %% Relationships
    Browser --> Static
    Browser --> Templates
    Browser --> APIViews
    
    MeupetViews --> MeupetModels
    MeupetViews --> MeupetForms
    MeupetServices --> SocialAuth
    
    UserViews --> UserModels
    UserViews --> UserForms
    UserViews --> SocialAuth
    
    CityViews --> CityModels
    CityViews --> CityUtils
    
    APIViews --> APISerializers
    APIViews --> MeupetModels
    
    CommonViews --> CommonModels
    CommonViews --> CommonUtils
    
    MeupetModels --> DB
    UserModels --> DB
    CityModels --> DB
    CommonModels --> DB
    
    MeupetServices --> SendGrid
    MeupetServices --> MediaStorage

    %% Styles
    classDef client fill:#f9f,stroke:#333
    classDef frontend fill:#ff9,stroke:#333
    classDef core fill:#9cf,stroke:#333
    classDef user fill:#fcf,stroke:#333
    classDef location fill:#cfc,stroke:#333
    classDef api fill:#fc9,stroke:#333
    classDef common fill:#ccc,stroke:#333
    classDef database fill:#c9f,stroke:#333
    classDef external fill:#9fc,stroke:#333
    classDef config fill:#f99,stroke:#333
```
