# ecotrust/tekdb architecture

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

- Interactive diagram: https://gitdiagram.com/ecotrust/tekdb
- Repository: https://github.com/ecotrust/tekdb

## Overview

##### Main Components

a. Frontend Layer:
- Explore Module (public-facing interface)
- Admin Interface (Django Admin)
- Login/Authentication System
- Static Assets (CSS, JS, images)
- GIS Interface Components

b. Backend Layer:
- Django Application Server
- Core Apps:
- TEKDB (main application)
- Accounts
- Lookup
- Relationships
- Configuration
- Explore
- Authentication/Authorization

c. Database Layer:
- PostgreSQL Database (with PostGIS extension)
- Data Models:
- Citations
- Places
- Media
- Resources
- Events
- Relationships

d. Infrastructure Components:
- Nginx Web Server (proxy)
- uWSGI Application Server
- Docker Containers
- Static/Media File Storage

##### Relationships and Data Flow

- HTTP requests from clients to Nginx
- Nginx proxy passes to uWSGI
- uWSGI communication with Django
- Django's interaction with PostgreSQL
- Static/Media file serving paths
- Authentication flow
- GIS data flow

##### Specific Implementation Details

**[Client Browsers] → [Nginx Proxy] → [uWSGI] → [Django Apps] → [PostgreSQL]**
- ↓
- [Static/Media Files]

b. Specialized components:
- GIS functionality (OpenLayers, PostGIS)
- Media handling system
- Authentication flow
- Configuration management

##### Additional Elements

- Notes about Docker containerization
- Development vs production environments
- Backup/restore paths
- Security boundaries

##### Key Integration Points

- Integration with external services
- API endpoints if any
- Where configuration affects the system
- Where custom middleware operates

##### GIS component interaction

Remember to include:
- Version information
- Environment variables
- Configuration paths
- Deployment considerations
- Backup/restore paths
- Security boundaries
- Scaling points

This will provide a comprehensive view of the system while maintaining clarity and usefulness for the development team.

## Diagram (Mermaid)

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

    subgraph "Frontend Layer"
        ExploreUI["Explore Module"]:::frontend
        AdminUI["Admin Interface"]:::frontend
        LoginUI["Login System"]:::frontend
        StaticAssets["Static Assets"]:::frontend
        GISInterface["GIS Interface"]:::frontend
    end

    subgraph "Web Server"
        Nginx["Nginx Proxy"]:::infra
        uWSGI["uWSGI Server"]:::infra
    end

    subgraph "Backend Layer"
        DjangoApp["Django Application Server"]:::backend
        
        subgraph "Core Applications"
            MainApp["TEKDB Core"]:::backend
            AccountsApp["Accounts"]:::backend
            LookupApp["Lookup"]:::backend
            RelationshipsApp["Relationships"]:::backend
            ConfigApp["Configuration"]:::backend
            ExploreApp["Explore"]:::backend
        end

        subgraph "Authentication"
            AuthSystem["Auth System"]:::security
            AccountManagement["Account Management"]:::security
        end
    end

    subgraph "Database Layer"
        PostgreSQL[(PostgreSQL + PostGIS)]:::database
        subgraph "Data Models"
            Citations["Citations Model"]:::database
            Places["Places Model"]:::database
            Media["Media Model"]:::database
            Resources["Resources Model"]:::database
            Events["Events Model"]:::database
            RelationshipModels["Relationship Models"]:::database
        end
    end

    subgraph "Infrastructure"
        Docker["Docker Containers"]:::infra
        StaticStorage["Static Storage"]:::infra
        MediaStorage["Media Storage"]:::infra
    end

    %% Relationships
    Browser --> Nginx
    Nginx --> uWSGI
    uWSGI --> DjangoApp
    DjangoApp --> PostgreSQL
    DjangoApp --> StaticStorage
    DjangoApp --> MediaStorage

    %% Frontend connections
    Browser --> ExploreUI
    Browser --> AdminUI
    Browser --> LoginUI
    Browser --> StaticAssets
    Browser --> GISInterface

    %% Core app relationships
    MainApp --> PostgreSQL
    AccountsApp --> PostgreSQL
    LookupApp --> PostgreSQL
    RelationshipsApp --> PostgreSQL
    ExploreApp --> PostgreSQL
    ConfigApp --> PostgreSQL

    %% Click events
    click ExploreUI "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/explore/"
    click AdminUI "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/TEKDB/templates/admin/"
    click LoginUI "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/login/"
    click StaticAssets "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/TEKDB/static/"
    click GISInterface "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/TEKDB/templates/gis/"
    click MainApp "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/TEKDB/"
    click AccountsApp "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/Accounts/"
    click LookupApp "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/Lookup/"
    click RelationshipsApp "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/Relationships/"
    click ConfigApp "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/configuration/"
    click ExploreApp "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/explore/"
    click Docker "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/docker/"
    click Citations "https://github.com/Ecotrust/TEKDB/blob/main/TEKDB/TEKDB/models.py"
    click RelationshipModels "https://github.com/Ecotrust/TEKDB/blob/main/TEKDB/Relationships/models.py"
    click AuthSystem "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/login/"
    click AccountManagement "https://github.com/Ecotrust/TEKDB/tree/main/TEKDB/Accounts/"

    %% Styling
    classDef frontend fill:#3498db
    classDef backend fill:#2ecc71
    classDef database fill:#f1c40f
    classDef infra fill:#e67e22
    classDef security fill:#9b59b6

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        Backend["Backend"]:::backend
        Database["Database"]:::database
        Infrastructure["Infrastructure"]:::infra
        Security["Security"]:::security
    end
```
