# antsmo/dev-wales architecture

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

- Interactive diagram: https://gitdiagram.com/antsmo/dev-wales
- Repository: https://github.com/antsmo/dev-wales

## Overview

##### Main System Components

a) Web Application Layer
- Express.js server (entry point: server.js)
- Route handlers (/routes directory)
- View templates (/views directory using Handlebars)
- API interfaces (/lib/api directory)

b) Data Layer
- Airtable Database (external)
- Local Cache System (lib/cache.js)

c) Frontend Layer
- Static assets (/public directory)
- Tailwind CSS styling
- Handlebars templates

##### Client Request Flow
- Browser → Express Server → Route Handlers
##### Data Flow
- Route Handlers → API Layer → Cache/Airtable
##### Response Flow
- Data → Handlebars Templates → Rendered HTML → Client

##### Detailed Component Breakdown

a) Route Layer (group these functionally):
- Community Features (groups, events, speakers)
- Business Features (companies, jobs)
- User Features (users, newsletter)

b) API Services (/lib/api):
- Individual API modules connecting to Airtable
- Cache interaction

c) View Layer:
- Main layout (views/layouts/main.handlebars)
- Individual view templates
- Partial components

##### Important Relationships to Highlight

Use connecting lines to show:
- Cache refresh cycle (30-minute interval)
- Template helper integration (lib/templateHelpers.js)
- Meta tags middleware flow (lib/metaTagsMiddleware.js)

##### Deployment Flow (Optional Section)

A small section showing:
- GitHub → Heroku deployment pipeline
- Automatic deployment from master branch

##### Additional Notes

- Cache refresh mechanism
- Template rendering flow
- API data flow
- Static asset serving

Remember to maintain a balance between showing the essential architecture while not overwhelming with implementation details. The focus should be on how the components interact to serve the community-driven features of Dev Wales.

## Diagram (Mermaid)

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

    subgraph Server
        Express["Express.js Server"]:::server
        click Express "https://github.com/antsmo/dev-wales/blob/master/server.js"

        subgraph "Route Layer"
            Routes["Route Handlers"]:::routes
            click Routes "https://github.com/antsmo/dev-wales/tree/master/routes/"

            subgraph "Community Routes"
                GroupsR["Groups"]:::routes
                EventsR["Events"]:::routes
                SpeakersR["Speakers"]:::routes
                click GroupsR "https://github.com/antsmo/dev-wales/blob/master/routes/groups.js"
                click EventsR "https://github.com/antsmo/dev-wales/blob/master/routes/events.js"
                click SpeakersR "https://github.com/antsmo/dev-wales/blob/master/routes/speakers.js"
            end

            subgraph "Business Routes"
                CompaniesR["Companies"]:::routes
                JobsR["Jobs"]:::routes
                click CompaniesR "https://github.com/antsmo/dev-wales/blob/master/routes/companies.js"
                click JobsR "https://github.com/antsmo/dev-wales/blob/master/routes/jobs.js"
            end

            subgraph "User Routes"
                UsersR["Users"]:::routes
                NewsletterR["Newsletter"]:::routes
                click UsersR "https://github.com/antsmo/dev-wales/blob/master/routes/users.js"
                click NewsletterR "https://github.com/antsmo/dev-wales/blob/master/routes/newsletter.js"
            end
        end

        subgraph "API Layer"
            API["API Interfaces"]:::api
            click API "https://github.com/antsmo/dev-wales/tree/master/lib/api/"

            subgraph "Community APIs"
                GroupsAPI["Groups API"]:::api
                EventsAPI["Events API"]:::api
                SpeakersAPI["Speakers API"]:::api
                click GroupsAPI "https://github.com/antsmo/dev-wales/blob/master/lib/api/groups.js"
                click EventsAPI "https://github.com/antsmo/dev-wales/blob/master/lib/api/events.js"
                click SpeakersAPI "https://github.com/antsmo/dev-wales/blob/master/lib/api/speakers.js"
            end

            subgraph "Business APIs"
                CompaniesAPI["Companies API"]:::api
                JobsAPI["Jobs API"]:::api
                click CompaniesAPI "https://github.com/antsmo/dev-wales/blob/master/lib/api/companies.js"
                click JobsAPI "https://github.com/antsmo/dev-wales/blob/master/lib/api/jobs.js"
            end

            subgraph "User APIs"
                UsersAPI["Users API"]:::api
                NewsletterAPI["Newsletter API"]:::api
                click UsersAPI "https://github.com/antsmo/dev-wales/blob/master/lib/api/users.js"
                click NewsletterAPI "https://github.com/antsmo/dev-wales/blob/master/lib/api/newsletter.js"
            end
        end

        Cache[(Cache)]:::storage
        click Cache "https://github.com/antsmo/dev-wales/blob/master/lib/cache.js"

        DBInterface["Database Interface"]:::db
        click DBInterface "https://github.com/antsmo/dev-wales/blob/master/lib/db.js"

        MetaTags["Meta Tags Middleware"]:::middleware
        click MetaTags "https://github.com/antsmo/dev-wales/blob/master/lib/metaTagsMiddleware.js"

        TemplateHelpers["Template Helpers"]:::helpers
        click TemplateHelpers "https://github.com/antsmo/dev-wales/blob/master/lib/templateHelpers.js"
    end

    subgraph "View Layer"
        Views["View Templates"]:::views
        click Views "https://github.com/antsmo/dev-wales/tree/master/views/"
        
        MainLayout["Main Layout"]:::views
        click MainLayout "https://github.com/antsmo/dev-wales/blob/master/views/layouts/main.handlebars"
        
        Partials["Partial Components"]:::views
        click Partials "https://github.com/antsmo/dev-wales/tree/master/views/partials/"
        
        StaticAssets["Static Assets"]:::static
        click StaticAssets "https://github.com/antsmo/dev-wales/tree/master/public/"
    end

    subgraph "External Services"
        Airtable[(Airtable DB)]:::external
        GitHub["GitHub"]:::external
        Heroku["Heroku"]:::external
    end

    %% Connections
    Browser <--> Express
    Express --> Routes
    Routes --> API
    API --> Cache
    API --> DBInterface
    DBInterface <--> Airtable
    Express --> MetaTags
    Express --> TemplateHelpers
    Express --> Views
    Views --> MainLayout
    Views --> Partials
    Views --> StaticAssets
    GitHub --> Heroku

    %% Styles
    classDef server fill:#3498db,stroke:#2980b9,color:white
    classDef routes fill:#e74c3c,stroke:#c0392b,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef db fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef views fill:#e67e22,stroke:#d35400,color:white
    classDef static fill:#1abc9c,stroke:#16a085,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef middleware fill:#34495e,stroke:#2c3e50,color:white
    classDef helpers fill:#95a5a6,stroke:#7f8c8d,color:white
```
