# geeksforsocialchange/placecal architecture

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

## Overview

##### Main System Components

a) Client Layer:
- Public Web Interface (Rails Views)
- Admin Interface
- GraphQL API Endpoints

b) Application Layer:
- Controllers (Public & Admin)
- View Components
- Policies (Authorization)
- GraphQL Schema

c) Service Layer:
- Calendar Importer Jobs
- Event Processing
- Mailers
- Image Processing

d) Data Layer:
- PostgreSQL Database
- File Storage (for images)
- External Calendar Sources

##### Key Relationships to Highlight

a) Data Flow:
- External Calendar Sources → Calendar Importer → Events
- User Requests → Controllers → Views/Components
- API Requests → GraphQL → Models
- Admin Actions → Policies → Data Access

b) Authentication Flow:
- User Authentication (Devise)
- Admin Authorization (Pundit)
- Site-specific Access (Constraints)

##### Specific Implementation Details

a) Core Models (Rectangle):
- Sites
- Partners
- Events
- Calendars
- Users
- Neighbourhoods
- Tags

b) Services (Hexagon):
- Calendar Importers
- Image Processors
- Email Services

c) External Systems (Cloud):
- iCal Sources
- API Endpoints
- Email Providers

##### Technical Stack Elements

Technologies:

- Ruby on Rails (Application Framework)
- PostgreSQL (Database)
- ViewComponent & Mountain View (UI Components)
- GraphQL (API Layer)
- Delayed Job (Background Processing)
- Docker (Development/Deployment)

##### Important Architectural Patterns

Emphasize:

a) MVC Architecture:
- Models (app/models)
- Views (app/views)
- Controllers (app/controllers)

b) Component-Based UI:
- ViewComponents
- Mountain View Components

c) Service Objects:
- Calendar Importers
- Event Processors

##### Deployment Architecture

Include:

- Docker Containers
- Nginx Configuration
- Asset Pipeline
- Database Connections

##### Bottom Level: Data Storage and External Services

- Blue: User-facing components
- Green: Processing services
- Yellow: Data storage
- Red: External services/APIs
- Purple: Authentication/Authorization

Remember to highlight the multi-tenant nature of the system, showing how different sites can operate independently within the same infrastructure.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WI["Public Web Interface"]
        AI["Admin Interface"]
        API["GraphQL API"]
    end

    subgraph Application
        PC["Public Controllers"]
        AC["Admin Controllers"]
        VC["View Components"]
        POL["Policies"]
        GS["GraphQL Schema"]
    end

    subgraph Services
        CIJ["Calendar Importer Jobs"]
        EP["Event Processing"]
        M["Mailers"]
        IP["Image Processing"]
    end

    subgraph Data
        DB[(PostgreSQL)]
        FS["File Storage"]
        ECS["External Calendar Sources"]
    end

    subgraph Core_Models
        S["Sites"]
        P["Partners"]
        E["Events"]
        C["Calendars"]
        U["Users"]
        N["Neighbourhoods"]
        T["Tags"]
    end

    %% Client Layer Connections
    WI --> PC
    AI --> AC
    API --> GS

    %% Application Layer Connections
    PC --> VC
    AC --> VC
    PC --> POL
    AC --> POL
    GS --> Core_Models

    %% Service Layer Connections
    CIJ --> EP
    EP --> E
    ECS --> CIJ

    %% Data Layer Connections
    Core_Models --> DB
    IP --> FS

    %% Authentication Flow
    U --> POL
    S --> POL

    %% Click Events
    click WI "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/views/"
    click AI "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/views/admin/"
    click API "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/graphql/"
    click PC "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/controllers/"
    click AC "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/controllers/admin/"
    click VC "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/components/"
    click POL "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/policies/"
    click GS "https://github.com/geeksforsocialchange/PlaceCal/blob/main/app/graphql/place_cal_schema.rb"
    click CIJ "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/jobs/calendar_importer/"
    click EP "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/jobs/calendar_importer/events/"
    click M "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/mailers/"
    click ECS "https://github.com/geeksforsocialchange/PlaceCal/tree/main/app/jobs/calendar_importer/parsers/"
    click S "https://github.com/geeksforsocialchange/PlaceCal/blob/main/app/models/site.rb"
    click P "https://github.com/geeksforsocialchange/PlaceCal/blob/main/app/models/partner.rb"
    click E "https://github.com/geeksforsocialchange/PlaceCal/blob/main/app/models/event.rb"
    click C "https://github.com/geeksforsocialchange/PlaceCal/blob/main/app/models/calendar.rb"
    click U "https://github.com/geeksforsocialchange/PlaceCal/blob/main/app/models/user.rb"
    click N "https://github.com/geeksforsocialchange/PlaceCal/blob/main/app/models/neighbourhood.rb"
    click T "https://github.com/geeksforsocialchange/PlaceCal/blob/main/app/models/tag.rb"

    classDef client fill:#3498db
    classDef application fill:#2ecc71
    classDef service fill:#f1c40f
    classDef data fill:#e74c3c
    classDef model fill:#9b59b6

    class WI,AI,API client
    class PC,AC,VC,POL,GS application
    class CIJ,EP,M,IP service
    class DB,FS,ECS data
    class S,P,E,C,U,N,T model
```
