How ruslanlesko/brightonum works
Main components
• API Gateway/Entry Point: Representing the REST API endpoints exposed on port 2525. (This is where requests such as user creation, invite sending, token issuance, etc., hit the server.)
• Authentication & Authorization Service: The core logic that processes JWT tokens—both issuance (access and refresh tokens) and verification. Include components from “src/auth.go.”
• Service Layer: A central business logic component, likely represented by “src/service.go,” that orchestrates operations between multiple internal services.
• Data Access Layer (DAO): The “src/dao” module, with its specific implementations (e.g., mongodb.go) and mocks. This connects directly to MongoDB.
• Cryptographic Module: Components in “src/crypto” handling RSA key operations and signing of JWT tokens.
• Email Service: Represented by “src/email” (i.e., mailer.go), which is responsible for sending invitation emails, password recovery, and verification emails.
• Shared Data Structures: The “src/structs” directory contains definitions for error handling, user responses, etc.
• External Dependencies: MongoDB (note: the README emphasizes that MongoDB is required), an email server for sending emails (currently geared towards Gmail), and RSA keys (provided via command-line parameters).
Relationships and Data Flow
• User requests from clients (e.g., user invite, registration, authentication, password recovery) are received at the API Gateway.
• The API Gateway forwards requests to the Service Layer. For example, when issuing a token, the service might first validate credentials with the Auth component.
• The Authentication Service calls the Cryptographic Module for token signing and verification.
• Wherever persistence is required (e.g., storing user data, invite codes), the Service Layer delegates to the DAO, which connects to the MongoDB database.
• Email-related flows are handled by the Email Service, which communicates with external SMTP servers.
• Testing mocks illustrate that the DAO and Email modules have abstraction layers for easier integration testing.
Architectural Patterns & Design Principles
• Separation of Concerns: The code design separates API handling, business logic, persistence (DAO), security (crypto), and notifications (email).
• Dependency Injection/Mocking: Presence of “*_mock.go” files for both DAO and mailer indicates that the system is designed to allow for unit testing and a high degree of testability.
• Modularization: Each function (authentication, emailing, database operations) is encapsulated in dedicated packages, promoting maintainability and extensibility.
Relevant Technologies and Frameworks
• Go (as the primary programming language) with dependency management via go.mod and go.sum.
• MongoDB as the data storage system.
• OpenSSL (for generating RSA keys) as described in the README.
• Docker and GitHub Actions (noted by the Dockerfile and GitHub workflow files), indicating that containerization and CI/CD pipelines are part of the project's ecosystem.