# alecxcode/edm architecture

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

- Interactive diagram: https://gitdiagram.com/alecxcode/edm
- Repository: https://github.com/alecxcode/edm

## Overview

##### Project Type and Purpose
- Full-stack web application for electronic document, task, and project management.
- Single Go monolithic backend (cmd/edm → internal/ & pkg/) with a static front-end (HTML/CSS/JS/templates).
- Supports multiple RDBMS backends plus optional Redis for sessions/shared data.
- Exposes HTTP (and WebSocket) API endpoints, sends e-mails via an SMTP service.

##### File Structure and Key Components
- cmd/edm – entry point: HTTP server, CLI flags, Dockerfile, docker-compose.yml
- internal/ – core business modules:
– config: environment/config file parsing
– core: common helpers, SQL generation, theming, uploads
– docs, projs, tasks, team: domain sub-systems exposing handlers/views
– mail: mail template generation + DB logging
– filldata: seed data routines
- pkg/ – reusable libraries (datetime, currency, in-memory or Redis/SQL DB wrappers)
- static/, templates/ – frontend assets (CSS themes, JS modules, HTML templates)
- i18nserver/ & static/i18n/ – translation JSON files for backend and client
- sqlscripts/ – schema definitions for each supported RDBMS
- docker-related files – Dockerfile + compose orchestration

##### Extract Architectural Patterns
- Monolithic MVC-style backend:
– Model: internal/* + pkg/db
– View: HTML templates + static frontend
– Controller: HTTP handlers in internal/* packages
- Layered architecture: config → core → domain services → persistence
- Optional message channel: WebSocket handlers (internal/projs/wshandler.go & tasks/wsmsg.go)
- External integrations: SMTP server for notifications, Redis (optional)

##### Main Components
1. Client (Browser UI)
– Requests HTML templates + JS/CSS from static server
– Invokes REST/Fetch API calls + WebSocket connections
2. Web Server (Go Application)
– HTTP routing → handlers in internal/
– MVC pipeline: config loader → controllers → core logic → persistence
3. Persistence Layer
– Primary: RDBMS (SQLite, MySQL, PostgreSQL, Oracle, SQL Server)
– Secondary (optional): Redis as session store / counter store
4. External Services
– SMTP Mail Server for notifications
– (Optional) Docker network links among service containers
5. Supporting Utilities
– i18n server (JSON files)
– Static asset hosting
– Build scripts (build-release.sh, Dockerfile)

##### Relationships & Data Flows
- Browser → HTTP (GET / POST) → Go Server
- Browser ↔ WebSocket → Go Server (real-time task/project updates)
- Go Server → SQL driver → RDBMS
- Go Server → Redis client → Redis
- Go Server → SMTP port 25/587 → Mail Server
- Config file (.edm dir) read at startup

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Client["Browser UI"]:::frontend
    Client -->|HTTP GET/POST| EDMServer
    Client -->|WebSocket| EDMServer
    Client -->|Fetch assets| StaticAssets

    %% Go Server
    subgraph "EDM Go Server"
        direction TB
        EntryPoint["Entry Point\n(cmd/edm)"]:::backend
        ConfigLoader["Configuration Loader"]:::backend
        CoreServices["Core Services"]:::backend
        DocsSubsystem["Document Management"]:::backend
        ProjsSubsystem["Project Management"]:::backend
        TasksSubsystem["Task Management"]:::backend
        TeamSubsystem["Team/User Management"]:::backend
        MailService["Mail Service"]:::backend
        FillData["Seed Data (filldata)"]:::backend
    end

    Client -->|HTTP/WS| EntryPoint
    EntryPoint -->|load| ConfigLoader
    ConfigLoader --> CoreServices
    CoreServices --> DocsSubsystem
    CoreServices --> ProjsSubsystem
    CoreServices --> TasksSubsystem
    CoreServices --> TeamSubsystem
    CoreServices --> MailService
    CoreServices --> FillData

    %% Persistence Layer
    subgraph "Persistence"
        direction TB
        SQLDB["RDBMS\n(SQLite/MySQL/Postgres/... )"]:::db
        RedisDB["Redis Session Store"]:::redis
    end

    EDMServer -->|SQL queries| SQLDB
    EDMServer -->|Redis calls| RedisDB

    %% External Services
    SMTP["SMTP Mail Server"]:::external
    EDMServer -->|SMTP send| SMTP

    %% Static and i18n
    StaticAssets["Static Assets\n(static/)"]:::frontend
    Templates["HTML Templates\n(templates/)"]:::frontend
    I18nBackend["i18n JSON (backend)"]:::frontend
    I18nFrontend["i18n JSON (frontend)"]:::frontend

    StaticAssets --> Templates
    StaticAssets --> I18nFrontend
    EntryPoint --> Templates
    EntryPoint --> I18nBackend

    %% Connections to diagram root
    EDMServer["EDM Go Server"]:::backend

    %% Click Events
    click EntryPoint "https://github.com/alecxcode/edm/tree/main/cmd/edm"
    click ConfigLoader "https://github.com/alecxcode/edm/tree/main/internal/config"
    click CoreServices "https://github.com/alecxcode/edm/tree/main/internal/core"
    click DocsSubsystem "https://github.com/alecxcode/edm/tree/main/internal/docs"
    click ProjsSubsystem "https://github.com/alecxcode/edm/tree/main/internal/projs"
    click TasksSubsystem "https://github.com/alecxcode/edm/tree/main/internal/tasks"
    click TeamSubsystem "https://github.com/alecxcode/edm/tree/main/internal/team"
    click MailService "https://github.com/alecxcode/edm/tree/main/internal/mail"
    click FillData "https://github.com/alecxcode/edm/tree/main/internal/filldata"
    click StaticAssets "https://github.com/alecxcode/edm/tree/main/static"
    click Templates "https://github.com/alecxcode/edm/tree/main/templates"
    click I18nBackend "https://github.com/alecxcode/edm/tree/main/i18nserver"
    click I18nFrontend "https://github.com/alecxcode/edm/tree/main/static/i18n"
    click SQLDB "https://github.com/alecxcode/edm/tree/main/sqlscripts"
    click RedisDB "https://github.com/alecxcode/edm/tree/main/pkg/redisdb"

    %% Styles
    classDef frontend fill:#CCE5FF,stroke:#003366,color:#003366;
    classDef backend fill:#CCFFCC,stroke:#006600,color:#006600;
    classDef db fill:#FFFFCC,stroke:#999900,color:#999900,shape:cylinder;
    classDef redis fill:#FFCCCC,stroke:#CC0000,color:#CC0000,shape:cylinder;
    classDef external fill:#F2F2F2,stroke:#666666,color:#666666;
```
