Skip to content

feat: add MongoDB NoSQL database backend#904

Open
madhavilosetty-intel wants to merge 1 commit intomainfrom
mongodb
Open

feat: add MongoDB NoSQL database backend#904
madhavilosetty-intel wants to merge 1 commit intomainfrom
mongodb

Conversation

@madhavilosetty-intel
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@madhavilosetty-intel madhavilosetty-intel changed the title feat: add MongoDB NoSQL database backend feat: add MongoDB NoSQL database backend Apr 23, 2026
@madhavilosetty-intel madhavilosetty-intel force-pushed the mongodb branch 2 times, most recently from abde129 to a322ead Compare April 23, 2026 16:38
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 51.09827% with 423 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.52%. Comparing base (f5975ba) to head (79f9e16).

Files with missing lines Patch % Lines
internal/usecase/nosqldb/mongo/device.go 55.49% 52 Missing and 25 partials ⚠️
internal/usecase/nosqldb/mongo/wificonfig.go 50.79% 44 Missing and 18 partials ⚠️
internal/usecase/nosqldb/mongo/profile.go 61.70% 40 Missing and 14 partials ⚠️
internal/usecase/nosqldb/mongo/client.go 6.00% 47 Missing ⚠️
internal/usecase/nosqldb/mongo/ciraconfig.go 45.67% 32 Missing and 12 partials ⚠️
internal/usecase/nosqldb/mongo/domain.go 55.31% 23 Missing and 19 partials ⚠️
internal/usecase/nosqldb/mongo/ieee8021xconfig.go 52.38% 21 Missing and 19 partials ⚠️
internal/app/repos.go 38.63% 26 Missing and 1 partial ⚠️
...nternal/usecase/nosqldb/mongo/profilewificonfig.go 45.71% 10 Missing and 9 partials ⚠️
internal/app/app.go 33.33% 5 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #904      +/-   ##
==========================================
+ Coverage   39.81%   40.52%   +0.70%     
==========================================
  Files         124      134      +10     
  Lines       11395    12237     +842     
==========================================
+ Hits         4537     4959     +422     
- Misses       6461     6762     +301     
- Partials      397      516     +119     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a MongoDB-backed repository implementation and introduces an explicit “DB provider” selection so the app can run against Postgres, embedded SQLite, or MongoDB, while keeping the same usecase layer.

Changes:

  • Introduce usecase.Repos bundle and refactor usecase wiring to be backend-agnostic (NewSQLRepos, NewMongoRepos).
  • Add MongoDB repository implementations (devices/domains/profiles/wifi/802.1x/CIRA) + wire-level unit tests.
  • Add DB_PROVIDER configuration + docker/CI workflow support to run API tests against MongoDB.

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
internal/usecase/usecase_test.go Updates usecase construction to use repo bundle (NewSQLRepos).
internal/usecase/usecase.go Adds Repos bundle + SQL/Mongo repo constructors; refactors NewUseCases to accept repos.
internal/usecase/nosqldb/mongo/wificonfig_test.go Unit tests for Mongo wireless config repo.
internal/usecase/nosqldb/mongo/wificonfig.go Mongo wireless config repository implementation (incl. 802.1x “join” behavior).
internal/usecase/nosqldb/mongo/profilewificonfig_test.go Unit tests for Mongo profile-wifi-configs repo.
internal/usecase/nosqldb/mongo/profilewificonfig.go Mongo profile-wifi-configs repository implementation.
internal/usecase/nosqldb/mongo/profile_test.go Unit tests for Mongo profiles repo.
internal/usecase/nosqldb/mongo/profile.go Mongo profiles repository implementation (incl. 802.1x “join” behavior).
internal/usecase/nosqldb/mongo/mongo_test.go Shared test helpers using mongo-driver wire-level mock deployment.
internal/usecase/nosqldb/mongo/ieee8021xconfig_test.go Unit tests for Mongo IEEE8021x repo.
internal/usecase/nosqldb/mongo/ieee8021xconfig.go Mongo IEEE8021x repository implementation.
internal/usecase/nosqldb/mongo/errors_test.go Tests for duplicate-key detection wrapper.
internal/usecase/nosqldb/mongo/errors.go Mongo repo error wrappers + duplicate-key helper.
internal/usecase/nosqldb/mongo/domain_test.go Unit tests for Mongo domains repo.
internal/usecase/nosqldb/mongo/domain.go Mongo domains repository implementation (case-insensitive name lookups).
internal/usecase/nosqldb/mongo/device_test.go Unit tests for Mongo devices repo.
internal/usecase/nosqldb/mongo/device.go Mongo devices repository implementation (tags search, updates, status timestamps).
internal/usecase/nosqldb/mongo/client_test.go Tests Mongo Connect input validation.
internal/usecase/nosqldb/mongo/client.go Mongo Connect + index creation logic.
internal/usecase/nosqldb/mongo/ciraconfig_test.go Unit tests for Mongo CIRA configs repo.
internal/usecase/nosqldb/mongo/ciraconfig.go Mongo CIRA configs repository implementation.
internal/app/repos.go Adds provider-based repo construction (postgres/sqlite/mongo).
internal/app/app_test.go Updates test setup to explicitly select Postgres provider.
internal/app/app.go Refactors app startup/shutdown to use repo bundle + generic closer.
go.mod Adds mongo-driver v2 and related indirect deps.
go.sum Updates module sums for added/updated dependencies.
docker-compose.yml Adds optional Mongo service (profile-gated) + DB_PROVIDER/DB_URL env wiring.
config/config.yml Documents postgres.provider (backend selector) and defaults to sqlite.
config/config.go Adds DB.Provider to configuration (env/yaml).
.github/workflows/api-test.yml Adds a MongoDB-backed API test job and fixes artifact path.
.env.example Adds DB_PROVIDER example env var.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/usecase/nosqldb/mongo/domain.go Outdated
Comment thread internal/usecase/nosqldb/mongo/device.go Outdated
Comment thread internal/usecase/nosqldb/mongo/client.go Outdated
Comment thread internal/usecase/nosqldb/mongo/client.go Outdated
Comment thread internal/usecase/nosqldb/mongo/client.go
Comment thread internal/usecase/nosqldb/mongo/profile.go
Comment thread internal/usecase/nosqldb/mongo/wificonfig.go
@madhavilosetty-intel madhavilosetty-intel force-pushed the mongodb branch 15 times, most recently from a0e71a4 to 851bde8 Compare May 5, 2026 19:15
Adds a MongoDB backend implementing the same *.Repository interfaces as
the existing SQL backend (Postgres + embedded SQLite). Provider is
selected at startup via cfg.DB.Provider in {postgres, sqlite, mongo};
no existing backend is touched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants