{"id":15463418,"url":"https://github.com/cored/mailboxes","last_synced_at":"2026-06-20T03:31:50.700Z","repository":{"id":250744454,"uuid":"832874417","full_name":"cored/mailboxes","owner":"cored","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-30T12:46:16.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-11T15:51:05.852Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cored.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-23T22:46:43.000Z","updated_at":"2024-07-30T12:46:21.000Z","dependencies_parsed_at":"2024-11-08T17:43:41.439Z","dependency_job_id":"32e68b1d-2de3-482f-b45d-0a3cfe5fa99f","html_url":"https://github.com/cored/mailboxes","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"897cd43152869f3cbe4e055d433f38fd037b2da4"},"previous_names":["cored/mailboxes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cored/mailboxes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cored%2Fmailboxes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cored%2Fmailboxes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cored%2Fmailboxes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cored%2Fmailboxes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cored","download_url":"https://codeload.github.com/cored/mailboxes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cored%2Fmailboxes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34556494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T00:20:56.990Z","updated_at":"2026-06-20T03:31:50.679Z","avatar_url":"https://github.com/cored.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mailbox Processing System\n\n## Implementation Overview\n\n### 1. Database Connection and Configuration\n\n- **Configuration Management**:\n\t- The system initializes a database connection using configuration loaded from a `config.yaml` file. Configuration management is handled using the `github.com/spf13/viper` package.\n\t- It establishes a connection to an SQLite database using the database driver (`dbDriver`) and path (`dbPath`) specified in the configuration file.\n\n### 2. DBStore\n\n- **DBStore Struct**:\n\t- The `DBStore` struct implements the `db.Store` interface, providing methods to interact with the database.\n\t- Key methods include:\n\t\t- `AllMailboxes()`: Retrieves all mailboxes from the database and returns a channel (`\u003c-chan db.Mailbox`) that streams each mailbox as it's fetched.\n\t\t- `UsersForMailbox(mailboxID int)`: Retrieves users associated with a specific mailbox ID and returns a channel (`\u003c-chan db.User`) that streams each user record.\n\n### 3. Pipeline Function (`Pipeline`)\n\n- **Functionality**:\n\t- The `Pipeline` function coordinates the process of retrieving mailboxes and their associated users.\n\t- It starts by fetching mailboxes using `store.AllMailboxes()`, which returns a channel of `Mailbox` objects.\n\t- For each retrieved mailbox, it concurrently retrieves users using `store.UsersForMailbox(mb.ID)` and processes each user in a separate goroutine.\n\t- A `sync.WaitGroup` is used to ensure all user processing goroutines complete before the function finishes.\n\n## Setup and Usage\n\n### 1. Setting Up the Database Locally\n\n1. **Create Database Schema**:\n\t - Use the provided SQL script to set up the database schema and sample data. Save the following script as `schema.sql`:\n\n\t\t ```sql\n\t\t -- Create mailboxes table\n\t\t CREATE TABLE mailboxes (\n\t\t\t\t id INTEGER PRIMARY KEY,\n\t\t\t\t mpi_id VARCHAR(200),\n\t\t\t\t token VARCHAR(200),\n\t\t\t\t created_at TIMESTAMP\n\t\t );\n\n\t\t -- Create users table\n\t\t CREATE TABLE users (\n\t\t\t\t id INTEGER PRIMARY KEY,\n\t\t\t\t mailbox_id INTEGER,\n\t\t\t\t user_name VARCHAR(200),\n\t\t\t\t email_address VARCHAR(200),\n\t\t\t\t created_at TIMESTAMP,\n\t\t\t\t FOREIGN KEY (mailbox_id) REFERENCES mailboxes(id)\n\t\t );\n\n\t\t -- Insert sample data into mailboxes table\n\t\t INSERT INTO mailboxes (id, mpi_id, token, created_at)\n\t\t VALUES\n\t\t\t\t (1, 'mpi123', 'token123', '2024-07-23 12:00:00'),\n\t\t\t\t (2, 'mpi456', 'token456', '2024-07-23 13:00:00');\n\n\t\t -- Insert sample data into users table\n\t\t INSERT INTO users (id, mailbox_id, user_name, email_address, created_at)\n\t\t VALUES\n\t\t\t\t (101, 1, 'user1', 'user1@example.com', '2024-07-23 12:30:00'),\n\t\t\t\t (102, 1, 'user2', 'user2@example.com', '2024-07-23 12:45:00'),\n\t\t\t\t (201, 2, 'user3', 'user3@example.com', '2024-07-23 13:15:00');\n\t\t ```\n\n2. **Execute the Script**:\n\t - Run the script `bin/dbsetup` to setup the database and add test data:\n\t\t ```sh\n\t\t./bin/dbsetup\n\t\t ```\n\n### 2. Running the Program\n\n1. **Build the Application**:\n\t - Navigate to the project directory and execute `/bin/dev`\tto build and run\n\t the application:\n\t\t ```sh\n\t\t ./bin/dev\n\t\t ```\n\n### 3. Running the Tests\n\n1. **Run Unit Tests**:\n\t - Ensure you have Go installed and the `go test` command available.\n\t - Run the tests using:\n\t\t ```sh\n\t\t go test -v\n\t\t ```\n\n2. **Test Output**:\n\t - Review test results in the console output for verification of functionality and correctness.\n\n## Configuration\n\n- **Configuration File**:\n\t- Create a `config.yaml` file in the root directory with the following structure:\n\t\t```yaml\n\t\tdatabase:\n\t\t\tdriver: sqlite3\n\t\t\tpath: path_to_your_database.db\n\t\t```\n\n- **Adjust the `path`** according to your local database file location.\n\n## Additional Information\n\n- **Dependencies**:\n\t- The project depends on the `github.com/spf13/viper` package for configuration management. Ensure it is included in your `go.mod` file.\n\n- **Logging**:\n\t- The application uses standard logging to provide runtime information and debugging output.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcored%2Fmailboxes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcored%2Fmailboxes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcored%2Fmailboxes/lists"}