Skip to content

HNygard/offpost

Repository files navigation

Offpost

Offpost - Offentlig post - er en tjeneste for å sende e-post til offentlige myndigheter.

Tjenesten baserer seg på at man lager en forespørsel til en myndighet. Denne får en unik profil med tilfeldig navn og epost. Eposten brukes for å sende e-post og å motta svar. De tilfeldige navnene baserer seg på Motorvognregisteret, så det er ekte navn men kombinasjonen av fornavn og etternavn er sannsnyligvis unik siden navene ikke er vektet.

Offpost was internally known as "email-engine". From 06.12.2024, this project have been written by AI tools.

Architecture

(kept in sync with .clinerules in the root directory)

Offpost is mainly a PHP application running on a web server. It revolves around email threads sent to public entities.

One email thread is a conversation between the system and a public entity. Or mulitple in case of a complaint. Connected to the thread is a profile of first name, last name and email address. This is unique for each thread.

It uses IMAP to get emails from a mail server and store them in local storage. The emails are sorted into threads based on the to/from addresses that matches the profile of the thread.

Components

(kept in sync with .clinerules in the root directory)

Organizer

  • Main program that provides client, API and JSON storage for email threads
  • Creates threads and "identities" in Roundcube
  • Sorts email using IMAP folders directly on the server

Roundcube

  • Webmail client using the IMAP server directly
  • Email threads are stored as folders on the IMAP server
  • Uses MySQL for storage

Sendgrid (Production only)

  • Used to send emails
  • Handles copying to the IMAP server

IMAP Server

  • Used to store email threads
  • Email threads are organized as folders on the server

Auth Service (Development only)

  • Simple authentication service for development
  • Not intended for production use

GreenMail (Development only)

  • SMTP/IMAP server for development environment
  • Provides email testing capabilities without external dependencies
  • Configured with test accounts for local development

Development

Setup

  1. Start the development services:
docker-compose -f docker-compose.dev.yaml up -d
  1. Access Roundcube (mail client):
  1. For new database setup:

Production

See infrastructure/production/README.md for details.

For production deployment:

docker-compose -f docker-compose.prod.yaml up -d

Note: The auth service is only available in development. For production uses auth0.

Running Tests

To run the organizer tests:

cd organizer/src && ./vendor/bin/phpunit tests/

Available Services

Starting a New Email Thread

  1. Generate a profile:
php generate-profile.php
  1. Use the generated link (example):
http://localhost:25081/start-thread.php?my_email=asmund.visnes%40offpost.no&my_name=%C3%85smund+Visnes
  1. Create thread:

    • Set title and label
    • Connect to Entity
  2. Sync with Roundcube:

  3. Post-send steps:

Extracting information from emails

From an email there are multiple ways to extract text. The diagram below shows the different paths for text extraction from emails, including plain text conversion, HTML parsing, and handling of attachments like PDFs and images.

graph TD;
    A[Email] -->|EML to plain Text| B(Plain Text)
    A -->|EML to HTML| C(HTML)
    A --> D(Attachments)
    D --> E(PDF)
    D --> F(Images)
    E -->|pdftotext| G(PDF Text)
    E -->|pdfimages| H(PDF Images)
    H --> F
    B --> I(Text)
    C -->|HTML to text| I
    G --> I
    F -->|LLM describe| I
Loading

About

Service for sending emails to public entities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •