# tejoesperanto/pasportaservo architecture

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

- Interactive diagram: https://gitdiagram.com/tejoesperanto/pasportaservo
- Repository: https://github.com/tejoesperanto/pasportaservo

## Overview

##### Main Components

a. Frontend Layer:
- Static assets (CSS, JavaScript, images)
- Templates organized by apps (core, hosting, blog, etc.)
- User interface components
- Client-side validation and interactions

b. Backend Layer:
- Django applications:
- Core (authentication, base templates)
- Hosting (main hospitality service)
- Blog (news and updates)
- Maps (geographical features)
- Shop (reservations system)
- Pages (static content)
- Links (URL management)

c. Database Layer:
- PostgreSQL with PostGIS extension
- Models for:
- User profiles
- Places/Locations
- Family members
- Phones
- Preferences
- Countries/Regions

d. External Services:
- Email service (MailDump for development)
- Services (Mapbox GL)
- Analytics (Google Analytics)
- Sentry for error tracking

##### Component Relationships

- User requests → Nginx → Gunicorn → Django
- Django → PostgreSQL/PostGIS for data storage
- Django → External services
- Template rendering flow
- Authentication flow
- Geographic data processing flow

##### Key Architectural Patterns

- MVC/MTV pattern (Django's implementation)
- Service-oriented architecture for external integrations
- Modular app structure
- Middleware chain
- Template inheritance system

##### Infrastructure Components

Include:
- Nginx web server
- Gunicorn WSGI server
- Memcached for caching
- Static file serving
- Media file handling

##### Security Layer

Show:
- HTTPS implementation
- Authentication middleware
- Permission systems
- CSRF protection
- Session management

**[Client Layer]**
- ↓ ↑
**[Web Server (Nginx)]**
- ↓ ↑
**[Application Server (Gunicorn)]**
- ↓ ↑
**[Django Framework]**
- ↓ ↑
**[Database Layer]**

- Blue: Core components
- Green: External services
- Orange: Security features
- Purple: Caching layer
- Gray: Infrastructure components

Specific notes about:
- Internationalization support (focusing on Esperanto)
- Geographic data handling
- User role management
- Content management features
- Testing infrastructure

This system design should reflect both the Django-specific architecture and the custom implementations for the hospitality service features, making it clear how all components work together to deliver the application's functionality.

## Diagram (Mermaid)

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

    subgraph WebServer
        Nginx["Nginx Web Server"]:::infra
        click Nginx "https://github.com/tejoesperanto/pasportaservo/tree/master/etc/nginx/"
    end

    subgraph AppServer
        Gunicorn["Gunicorn WSGI"]:::infra
        click Gunicorn "https://github.com/tejoesperanto/pasportaservo/blob/master/etc/gunicorn_config.py.example"
    end

    subgraph DjangoFramework
        subgraph Apps
            Core["Core App"]:::core
            click Core "https://github.com/tejoesperanto/pasportaservo/tree/master/core/"
            Hosting["Hosting Service"]:::core
            click Hosting "https://github.com/tejoesperanto/pasportaservo/tree/master/hosting/"
            Blog["Blog System"]:::core
            click Blog "https://github.com/tejoesperanto/pasportaservo/tree/master/blog/"
            Maps["Maps Service"]:::core
            click Maps "https://github.com/tejoesperanto/pasportaservo/tree/master/maps/"
            Shop["Shop/Reservations"]:::core
            click Shop "https://github.com/tejoesperanto/pasportaservo/tree/master/shop/"
            Pages["Static Pages"]:::core
            click Pages "https://github.com/tejoesperanto/pasportaservo/tree/master/pages/"
            Links["URL Management"]:::core
            click Links "https://github.com/tejoesperanto/pasportaservo/tree/master/links/"
        end

        subgraph Frontend
            Static["Static Assets"]:::frontend
            click Static "https://github.com/tejoesperanto/pasportaservo/tree/master/core/static/"
            Templates["Templates"]:::frontend
            click Templates "https://github.com/tejoesperanto/pasportaservo/tree/master/core/templates/"
            UIComponents["UI Components"]:::frontend
            click UIComponents "https://github.com/tejoesperanto/pasportaservo/tree/master/core/templates/ui/"
        end

        subgraph Security
            Auth["Authentication"]:::security
            click Auth "https://github.com/tejoesperanto/pasportaservo/blob/master/core/auth.py"
            Middleware["Security Middleware"]:::security
            click Middleware "https://github.com/tejoesperanto/pasportaservo/blob/master/core/middleware.py"
            Permissions["Permissions System"]:::security
            click Permissions "https://github.com/tejoesperanto/pasportaservo/blob/master/hosting/views/mixins.py"
        end

        subgraph Config
            BaseSettings["Base Settings"]:::config
            click BaseSettings "https://github.com/tejoesperanto/pasportaservo/blob/master/pasportaservo/settings/base.py"
            ProdSettings["Production Settings"]:::config
            click ProdSettings "https://github.com/tejoesperanto/pasportaservo/blob/master/pasportaservo/settings/prod.py"
            DevSettings["Development Settings"]:::config
            click DevSettings "https://github.com/tejoesperanto/pasportaservo/blob/master/pasportaservo/settings/dev.py"
        end
    end

    subgraph ExternalServices
        Email["Email Service"]:::external
        click Email "https://github.com/tejoesperanto/pasportaservo/tree/master/core/templates/email/"
        MapService["Mapbox GL"]:::external
        click MapService "https://github.com/tejoesperanto/pasportaservo/tree/master/maps/static/maps/"
        Analytics["Google Analytics"]:::external
        click Analytics "https://github.com/tejoesperanto/pasportaservo/blob/master/core/templates/core/snippets/google_analytics.html"
        Sentry["Sentry Error Tracking"]:::external
        click Sentry "https://github.com/tejoesperanto/pasportaservo/blob/master/pasportaservo/settings/sentry.py"
    end

    subgraph Database
        PostgreSQL["PostgreSQL + PostGIS"]:::db
        click PostgreSQL "https://github.com/tejoesperanto/pasportaservo/tree/master/etc/docker/ps-db-image/"
        Models["Core Models"]:::db
        click Models "https://github.com/tejoesperanto/pasportaservo/blob/master/core/models.py"
        HostingModels["Hosting Models"]:::db
        click HostingModels "https://github.com/tejoesperanto/pasportaservo/blob/master/hosting/models.py"
        Migrations["Database Migrations"]:::db
        click Migrations "https://github.com/tejoesperanto/pasportaservo/tree/master/*/migrations/"
    end

    subgraph Cache
        Memcached["Memcached"]:::cache
        click Memcached "https://github.com/tejoesperanto/pasportaservo/blob/master/etc/systemd/system/memcached-ps.prod.service"
    end

    Browser --> Nginx
    Nginx --> Gunicorn
    Gunicorn --> Core
    Core --> PostgreSQL
    Core --> Memcached
    Core --> ExternalServices
    Hosting --> PostgreSQL
    Blog --> PostgreSQL
    Maps --> PostgreSQL
    Shop --> PostgreSQL
    Pages --> PostgreSQL
    Links --> PostgreSQL

    classDef core fill:#4a90e2
    classDef frontend fill:#42b983
    classDef security fill:#ff7043
    classDef external fill:#7cb342
    classDef db fill:#8e44ad
    classDef cache fill:#9c27b0
    classDef infra fill:#78909c
    classDef config fill:#ffa726
```
