# jfilby/nexus architecture

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

## Overview

##### Main Components

a. Core Framework Components:
- Command Line Interface (nexus)
- Model Generation System
- Web Framework
- Database Layer
- Authentication System

b. Module Structure:
- Core Module
- Core Extras Module
- CRM Module
- Social Module

**┌─ Application Layer ─────────────────────────────────────┐**
- Web Apps / Console Apps                                 │
- (Generated from conf/*/web_apps/)                      │
- ┘
- ↑                    ↑                    ↑
**┌─ Framework Modules ──────────────────────────────────────┐**
- ┌─────────┐ ┌──────────┐ ┌─────┐ ┌──────────┐          │
- Core   │ │   Core   │ │ CRM │ │  Social  │          │
- Module  │ │  Extras  │ │     │ │  Module  │          │
- ┘ └──────────┘ └─────┘ └──────────┘          │
- ┘
- ↑                    ↑                    ↑
**┌─ Services Layer ───────────────────────────────────────┐**
- Authentication | Email | Scheduled Tasks | Data Access │
- ┘
- ↑                    ↑                    ↑
**┌─ Data Layer ──────────────────────────────────────────┐**
- ORM | Model Generation | Database Access              │
- ┘

##### Component Relationships

- Data flow between components
- Dependencies between modules
- Generation paths for code artifacts

##### Special Elements

a. Code Generation Pipeline:
- YAML Model Definitions → Generated Nim Types
- Route Definitions → Generated Controllers
- Database Schema Generation

b. Authentication Flow:
- User Sessions
- JWT Handling
- Role-based Access Control

##### Implementation Details

Implementation features:
- Cached vs. Uncached Data Access
- Model Type Generation
- View Generation
- Route Generation

- Multiple layers and grouping
- Clear text labels
- Export to common formats

Remember to include the database schema generation and ORM functionality as these are central to the framework's operation, but keep them at an appropriate level of abstraction.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef app fill:#a8d1ff,stroke:#000
    classDef framework fill:#90EE90,stroke:#000
    classDef service fill:#FFE5B4,stroke:#000
    classDef data fill:#FFB6C1,stroke:#000
    classDef config fill:#E6E6FA,stroke:#000

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        WebApps["Web Applications"]:::app
        ConsoleApps["Console Applications"]:::app
    end

    %% Framework Modules Layer
    subgraph FrameworkLayer["Framework Modules"]
        CoreMod["Core Module"]:::framework
        CoreExtras["Core Extras Module"]:::framework
        CRMModule["CRM Module"]:::framework
        SocialModule["Social Module"]:::framework
    end

    %% Services Layer
    subgraph ServicesLayer["Services Layer"]
        CLI["Command Line Interface"]:::service
        Auth["Authentication System"]:::service
        Email["Email Service"]:::service
        Tasks["Scheduled Tasks"]:::service
        WebFramework["Web Framework Components"]:::service
        RouteGen["Route Generation"]:::service
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        ModelGen["Model Generation"]:::data
        DBAccess["Database Access"]:::data
        DBMigration["Database Migration"]:::data
    end

    %% Configuration
    subgraph ConfigLayer["Configuration"]
        CoreConfig["Core Configuration"]:::config
        ModuleConfig["Module Configurations"]:::config
    end

    %% Relationships
    CoreConfig --> ModelGen
    ModuleConfig --> ModelGen
    ModelGen --> DBAccess
    DBAccess --> DBMigration
    
    CLI --> ModelGen
    CLI --> RouteGen
    CLI --> DBMigration
    
    CoreMod --> WebFramework
    CoreMod --> Auth
    CoreMod --> Email
    CoreMod --> Tasks
    
    WebFramework --> WebApps
    CLI --> ConsoleApps
    
    CoreExtras --> CoreMod
    CRMModule --> CoreMod
    SocialModule --> CoreMod

    %% Click Events
    click CLI "https://github.com/jfilby/nexus/blob/main/src/nexus/cmd/programs/nexus.nim"
    click ModelGen "https://github.com/jfilby/nexus/tree/main/src/nexus/cmd/service/generate/models/"
    click DBAccess "https://github.com/jfilby/nexus/tree/main/src/nexus/core/data_access/"
    click Auth "https://github.com/jfilby/nexus/tree/main/src/nexus/core/service/account/"
    click WebFramework "https://github.com/jfilby/nexus/tree/main/src/nexus/core/view/"
    click CoreMod "https://github.com/jfilby/nexus/tree/main/src/nexus/core/"
    click CoreExtras "https://github.com/jfilby/nexus/tree/main/src/nexus/core_extras/"
    click CRMModule "https://github.com/jfilby/nexus/tree/main/src/nexus/crm/"
    click SocialModule "https://github.com/jfilby/nexus/tree/main/src/nexus/social/"
    click Email "https://github.com/jfilby/nexus/tree/main/src/nexus/core/service/email/"
    click Tasks "https://github.com/jfilby/nexus/tree/main/src/nexus/core/service/scheduled/"
    click RouteGen "https://github.com/jfilby/nexus/tree/main/src/nexus/cmd/service/generate/routes/"
    click DBMigration "https://github.com/jfilby/nexus/tree/main/src/nexus/cmd/service/migrations/"
    click CoreConfig "https://github.com/jfilby/nexus/tree/main/conf/core/"
    click ModuleConfig "https://github.com/jfilby/nexus/blob/main/conf/*/models/models.yaml"

    %% Legend
    subgraph Legend
        AppComp["Application Component"]:::app
        FrameworkComp["Framework Component"]:::framework
        ServiceComp["Service Component"]:::service
        DataComp["Data Component"]:::data
        ConfigComp["Configuration Component"]:::config
    end
```
