docs: Remove redundant implementations and comments

This commit is contained in:
Mohammed Alquraini 2025-12-17 20:57:18 +04:00
parent ec1e0c742a
commit 9b7a6b1fa3
67 changed files with 2 additions and 87 deletions

View file

@ -75,7 +75,7 @@ graph TD
You will need:
* **Docker & Docker Compose** (Required for Database)
* **Go 1.23+** (Required for Backend)
* **Go 1.25+** (Required for Backend)
* **Node.js 20+ & pnpm** (Required for Frontend)
* **Make** (Required for running commands)

View file

@ -1,5 +1,5 @@
# Builder stage
FROM golang:1.23.7-alpine3.20 AS builder
FROM golang:1.25-alpine3.20 AS builder
WORKDIR /app

View file

@ -129,7 +129,6 @@ func (h *Handler) ListDocuments(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
// DeleteDocument deletes a document
// @Summary Delete document
// @Description Deletes a document and its associated file
// @Tags Documents

View file

@ -180,7 +180,6 @@ func (h *AccountHandler) UpdateAccount(c *gin.Context) {
response.Success(c, http.StatusOK, account)
}
// DeleteAccount deletes an account
func (h *AccountHandler) DeleteAccount(c *gin.Context) {
reqCtx := auth.GetRequestContext(c)
if reqCtx == nil {
@ -244,7 +243,6 @@ func (h *AccountHandler) UpdateAccountLastLogin(c *gin.Context) {
response.Success(c, http.StatusOK, account)
}
// CheckAccountPermission checks account permissions
func (h *AccountHandler) CheckAccountPermission(c *gin.Context) {
reqCtx := auth.GetRequestContext(c)
if reqCtx == nil {

View file

@ -218,7 +218,6 @@ func (h *MemberHandler) GetProfile(c *gin.Context) {
response.Success(c, http.StatusOK, profile)
}
// DeleteMember deletes an organization member.
// @Summary Delete organization member
// @Description Removes a member from the organization (deletes from both Stytch and internal database). Only admins can delete members.
// @Tags auth
@ -287,7 +286,6 @@ func (h *MemberHandler) DeleteMember(c *gin.Context) {
response.Success(c, http.StatusNoContent, nil)
}
// CheckEmail checks if an email exists in the system
// @Summary Check if email exists
// @Description Checks if an email exists in any organization. Returns 200 OK (empty response) if exists, 404 Not Found if doesn't exist. This is a public endpoint used during login flow.
// @Tags auth

View file

@ -12,7 +12,6 @@ type Provider struct {
container *dig.Container
}
// NewProvider creates a new organization API provider
func NewProvider(container *dig.Container) *Provider {
return &Provider{
container: container,

View file

@ -24,7 +24,6 @@ type moduleRoutes struct {
CognitiveRoutes *cognitiveAPI.Routes
}
// Init initializes the API by setting up dependencies and registering routes
// 1. Sets up all module dependencies
// 2. Registers API routes and handlers
// 3. Registers tools routes and handlers

View file

@ -15,7 +15,6 @@ type Handler struct {
service auth.RBACService
}
// NewHandler creates a new RBAC handler
func NewHandler(service auth.RBACService) *Handler {
return &Handler{
service: service,

View file

@ -12,7 +12,6 @@ type Provider struct {
container *dig.Container
}
// NewProvider creates a new RBAC provider
func NewProvider(container *dig.Container) *Provider {
return &Provider{
container: container,

View file

@ -11,7 +11,6 @@ type Routes struct {
handler *Handler
}
// NewRoutes creates a new Routes instance
func NewRoutes(handler *Handler) *Routes {
return &Routes{
handler: handler,

View file

@ -14,7 +14,6 @@ import (
// Module handles dependency injection for billing services
type Module struct{}
// NewModule creates a new services module
func NewModule() *Module {
return &Module{}
}

View file

@ -77,7 +77,6 @@ type billingService struct {
logger logger.Logger
}
// NewBillingService creates a new billing service
func NewBillingService(
repo domain.SubscriptionRepository,
orgAdapter domain.OrganizationAdapter,

View file

@ -4,7 +4,6 @@ import (
"go.uber.org/dig"
)
// Init initializes the billing module.
//
// The billing module handles subscription lifecycle management with Polar.sh:
// - Webhook processing for subscription events

View file

@ -17,7 +17,6 @@ type StatusProviderAdapter struct {
service services.BillingService
}
// NewStatusProviderAdapter creates a new StatusProviderAdapter.
func NewStatusProviderAdapter(service services.BillingService) paywall.SubscriptionStatusProvider {
return &StatusProviderAdapter{service: service}
}

View file

@ -17,7 +17,6 @@ type polarAdapter struct {
client *polarpkg.Client
}
// NewPolarAdapter creates a new Polar API adapter
func NewPolarAdapter(client *polarpkg.Client) *polarAdapter {
return &polarAdapter{
client: client,

View file

@ -13,7 +13,6 @@ type organizationAdapter struct {
orgStore adapters.OrganizationStore
}
// NewOrganizationAdapter creates a new organization adapter
func NewOrganizationAdapter(orgStore adapters.OrganizationStore) domain.OrganizationAdapter {
return &organizationAdapter{
orgStore: orgStore,

View file

@ -17,7 +17,6 @@ type subscriptionRepository struct {
store adapters.SubscriptionStore
}
// NewSubscriptionRepository creates a new subscription repository
func NewSubscriptionRepository(store adapters.SubscriptionStore) domain.SubscriptionRepository {
return &subscriptionRepository{
store: store,

View file

@ -9,7 +9,6 @@ type documentListener struct {
embeddingService EmbeddingService
}
// NewDocumentListener creates a new document listener
func NewDocumentListener(
embeddingService EmbeddingService,
) DocumentListener {

View file

@ -21,7 +21,6 @@ type embeddingService struct {
textVectorizer domain.TextVectorizer
}
// NewEmbeddingService creates a new embedding service
func NewEmbeddingService(
embeddingRepo domain.EmbeddingRepository,
textVectorizer domain.TextVectorizer,

View file

@ -26,7 +26,6 @@ type ragService struct {
assistantProvider domain.AssistantProvider
}
// NewRAGService creates a new RAG service
func NewRAGService(
chatRepo domain.ChatRepository,
embeddingRepo domain.EmbeddingRepository,

View file

@ -12,7 +12,6 @@ import (
"github.com/moasq/go-b2b-starter/pkg/eventbus"
)
// Init initializes the cognitive module
func Init(container *dig.Container) error {
module := cognitive.NewModule(container)
if err := module.RegisterDependencies(); err != nil {

View file

@ -42,7 +42,6 @@ type ChatSession struct {
UpdatedAt time.Time `json:"updated_at"`
}
// GetID returns the chat session's database ID
func (s *ChatSession) GetID() int32 {
return s.ID
}
@ -69,7 +68,6 @@ type ChatMessage struct {
CreatedAt time.Time `json:"created_at"`
}
// GetID returns the chat message's database ID
func (m *ChatMessage) GetID() int32 {
return m.ID
}
@ -88,12 +86,10 @@ func (m *ChatMessage) Validate() error {
return nil
}
// IsUserMessage checks if the message is from the user
func (m *ChatMessage) IsUserMessage() bool {
return m.Role == ChatRoleUser
}
// IsAssistantMessage checks if the message is from the assistant
func (m *ChatMessage) IsAssistantMessage() bool {
return m.Role == ChatRoleAssistant
}

View file

@ -13,7 +13,6 @@ type openAITextVectorizer struct {
llmClient llmdomain.LLMClient
}
// NewTextVectorizer creates a new TextVectorizer implementation
func NewTextVectorizer(llmClient llmdomain.LLMClient) domain.TextVectorizer {
return &openAITextVectorizer{llmClient: llmClient}
}

View file

@ -13,7 +13,6 @@ type chatRepository struct {
store adapters.ChatStore
}
// NewChatRepository creates a new chat repository
func NewChatRepository(store adapters.ChatStore) domain.ChatRepository {
return &chatRepository{store: store}
}

View file

@ -14,7 +14,6 @@ type embeddingRepository struct {
store adapters.EmbeddingStore
}
// NewEmbeddingRepository creates a new embedding repository
func NewEmbeddingRepository(store adapters.EmbeddingStore) domain.EmbeddingRepository {
return &embeddingRepository{store: store}
}

View file

@ -16,7 +16,6 @@ type Module struct {
container *dig.Container
}
// NewModule creates a new cognitive module
func NewModule(container *dig.Container) *Module {
return &Module{
container: container,

View file

@ -25,7 +25,6 @@ type documentService struct {
logger logger.Logger
}
// NewDocumentService creates a new document service
func NewDocumentService(
docRepo domain.DocumentRepository,
fileService filedomain.FileService,

View file

@ -6,7 +6,6 @@ import (
"github.com/moasq/go-b2b-starter/app/example_documents"
)
// Init initializes the documents module
func Init(container *dig.Container) error {
module := documents.NewModule(container)
return module.RegisterDependencies()

View file

@ -30,7 +30,6 @@ type Document struct {
UpdatedAt time.Time `json:"updated_at"`
}
// GetID returns the document's database ID
func (d *Document) GetID() int32 {
return d.ID
}
@ -52,17 +51,14 @@ func (d *Document) Validate() error {
return nil
}
// IsProcessed checks if the document has been processed
func (d *Document) IsProcessed() bool {
return d.Status == DocumentStatusProcessed
}
// IsPending checks if the document is pending processing
func (d *Document) IsPending() bool {
return d.Status == DocumentStatusPending
}
// HasText checks if the document has extracted text
func (d *Document) HasText() bool {
return d.ExtractedText != ""
}

View file

@ -23,7 +23,6 @@ type DocumentUploaded struct {
ExtractedText string `json:"extracted_text"`
}
// NewDocumentUploaded creates a new DocumentUploaded event
func NewDocumentUploaded(documentID, organizationID, fileAssetID int32, title, extractedText string) *DocumentUploaded {
return &DocumentUploaded{
BaseEvent: eventbus.BaseEvent{
@ -48,7 +47,6 @@ type DocumentProcessed struct {
EmbeddingID int32 `json:"embedding_id"`
}
// NewDocumentProcessed creates a new DocumentProcessed event
func NewDocumentProcessed(documentID, organizationID, embeddingID int32) *DocumentProcessed {
return &DocumentProcessed{
BaseEvent: eventbus.BaseEvent{
@ -71,7 +69,6 @@ type DocumentFailed struct {
Error string `json:"error"`
}
// NewDocumentFailed creates a new DocumentFailed event
func NewDocumentFailed(documentID, organizationID int32, err string) *DocumentFailed {
return &DocumentFailed{
BaseEvent: eventbus.BaseEvent{

View file

@ -14,7 +14,6 @@ type documentRepository struct {
store adapters.DocumentStore
}
// NewDocumentRepository creates a new document repository
func NewDocumentRepository(store adapters.DocumentStore) domain.DocumentRepository {
return &documentRepository{store: store}
}

View file

@ -18,7 +18,6 @@ type Module struct {
container *dig.Container
}
// NewModule creates a new documents module
func NewModule(container *dig.Container) *Module {
return &Module{
container: container,

View file

@ -44,7 +44,6 @@ type memberService struct {
logger loggerDomain.Logger
}
// NewMemberService creates a new instance of the member service.
func NewMemberService(
authOrgRepo domain.AuthOrganizationRepository,
authMemberRepo domain.AuthMemberRepository,
@ -531,7 +530,6 @@ func (s *memberService) DeleteOrganizationMember(
return nil
}
// CheckEmailExists checks if an email exists in the system
// Returns true if email is found in any organization, false otherwise
func (s *memberService) CheckEmailExists(ctx context.Context, email string) (bool, error) {
// Validate email format

View file

@ -12,7 +12,6 @@ type organizationService struct {
accountRepo domain.AccountRepository
}
// NewOrganizationService creates a new organization service
func NewOrganizationService(orgRepo domain.OrganizationRepository, accountRepo domain.AccountRepository) OrganizationService {
return &organizationService{
orgRepo: orgRepo,

View file

@ -6,7 +6,6 @@ import (
"github.com/moasq/go-b2b-starter/app/organizations"
)
// Init initializes the organizations module
func Init(container *dig.Container) error {
module := organizations.NewModule(container)
return module.RegisterDependencies()

View file

@ -39,7 +39,6 @@ type OrganizationContext struct {
AccountRole string `json:"account_role"`
}
// GetID returns the organization's database ID.
// Implements auth.OrganizationEntity interface.
func (o *Organization) GetID() int32 {
return o.ID
@ -59,7 +58,6 @@ func (o *Organization) Validate() error {
return nil
}
// GetID returns the account's database ID.
// Implements auth.AccountEntity interface.
func (a *Account) GetID() int32 {
return a.ID

View file

@ -81,7 +81,6 @@ func (e *OrganizationError) Unwrap() error {
return e.Cause
}
// NewOrganizationError creates a new organization error
func NewOrganizationError(errorType, message string, orgID *int32, cause error) *OrganizationError {
return &OrganizationError{
Type: errorType,
@ -108,7 +107,6 @@ func (e *AccountError) Unwrap() error {
return e.Cause
}
// NewAccountError creates a new account error
func NewAccountError(errorType, message string, accountID, orgID *int32, cause error) *AccountError {
return &AccountError{
Type: errorType,

View file

@ -17,7 +17,6 @@ type accountRepository struct {
orgStore adapters.OrganizationStore
}
// NewAccountRepository creates a new account repository
func NewAccountRepository(accountStore adapters.AccountStore, orgStore adapters.OrganizationStore) domain.AccountRepository {
return &accountRepository{
accountStore: accountStore,

View file

@ -16,7 +16,6 @@ type organizationRepository struct {
orgStore adapters.OrganizationStore
}
// NewOrganizationRepository creates a new organization repository
func NewOrganizationRepository(orgStore adapters.OrganizationStore) domain.OrganizationRepository {
return &organizationRepository{
orgStore: orgStore,

View file

@ -16,7 +16,6 @@ type Module struct {
container *dig.Container
}
// NewModule creates a new organization module
func NewModule(container *dig.Container) *Module {
return &Module{
container: container,

View file

@ -10,7 +10,6 @@ import (
)
func Execute() {
// Load environment variables from app.env file
if err := godotenv.Load("app.env"); err != nil {
log.Printf("Warning: Error loading app.env file: %v", err)
}

View file

@ -60,8 +60,6 @@ type StytchAuthAdapter struct {
// Ensure StytchAuthAdapter implements auth.AuthProvider.
var _ auth.AuthProvider = (*StytchAuthAdapter)(nil)
// NewStytchAuthAdapter creates a new Stytch authentication adapter.
//
// It initializes the Stytch client, JWKS cache, and RBAC policy service.
// Returns an error if configuration or client initialization fails.
func NewStytchAuthAdapter(

View file

@ -144,7 +144,6 @@ func (c *Config) Validate() error {
return nil
}
// NewConfigFromExisting creates a new Config from the existing stytch.Config type.
// This allows gradual migration from the old config type.
func NewConfigFromExisting(projectID, secret, env, baseURL, jwksURL string, sessionDurationMinutes int32, disableVerification bool, apiTimeout time.Duration) *Config {
return &Config{

View file

@ -53,7 +53,6 @@ type serializedPublicKey struct {
E string `json:"e"` // Exponent (base64url encoded)
}
// NewJWKSCache creates a new JWKS cache manager.
func NewJWKSCache(jwksURL string, redisClient redis.Client, logger logger.Logger) *JWKSCache {
return &JWKSCache{
jwksURL: jwksURL,

View file

@ -14,7 +14,6 @@ import (
// before signature verification.
type JWTParser struct{}
// NewJWTParser creates a new JWT parser.
func NewJWTParser() *JWTParser {
return &JWTParser{}
}

View file

@ -21,7 +21,6 @@ type MockAuthAdapter struct {
// Ensure MockAuthAdapter implements auth.AuthProvider.
var _ auth.AuthProvider = (*MockAuthAdapter)(nil)
// NewMockAuthAdapter creates a new mock auth adapter for development.
func NewMockAuthAdapter(log logger.Logger) *MockAuthAdapter {
return &MockAuthAdapter{
logger: log,

View file

@ -31,7 +31,6 @@ type RBACPolicyService struct {
logger logger.Logger
}
// NewRBACPolicyService creates a new RBAC policy service.
func NewRBACPolicyService(client *b2bstytchapi.API, redisClient redis.Client, logger logger.Logger) *RBACPolicyService {
return &RBACPolicyService{
client: client,

View file

@ -29,7 +29,6 @@ type TokenVerifier struct {
logger logger.Logger
}
// NewTokenVerifier creates a new token verifier with two-tier verification.
func NewTokenVerifier(
client *b2bstytchapi.API,
jwksCache *JWKSCache,

View file

@ -12,7 +12,6 @@ import (
"go.uber.org/dig"
)
// Init initializes the auth module and registers core dependencies.
//
// This sets up:
// - stytch.Config

View file

@ -63,8 +63,6 @@ type Middleware struct {
config *MiddlewareConfig
}
// NewMiddleware creates a new auth middleware instance.
//
// Parameters:
// - provider: The auth provider for token verification (e.g., Stytch adapter)
// - orgResolver: Resolves org by provider ID (optional, required for RequireOrganization)

View file

@ -393,7 +393,6 @@ type RBACService interface {
// defaultRBACService implements the RBACService interface
type defaultRBACService struct{}
// NewRBACService creates a new RBAC service
func NewRBACService() RBACService {
return &defaultRBACService{}
}

View file

@ -12,7 +12,6 @@ type embeddingStore struct {
store sqlc.Store
}
// NewEmbeddingStore creates a new embedding store
func NewEmbeddingStore(store sqlc.Store) adapters.EmbeddingStore {
return &embeddingStore{store: store}
}
@ -46,7 +45,6 @@ type chatStore struct {
store sqlc.Store
}
// NewChatStore creates a new chat store
func NewChatStore(store sqlc.Store) adapters.ChatStore {
return &chatStore{store: store}
}

View file

@ -12,7 +12,6 @@ type documentStore struct {
store sqlc.Store
}
// NewDocumentStore creates a new document store
func NewDocumentStore(store sqlc.Store) adapters.DocumentStore {
return &documentStore{store: store}
}

View file

@ -13,7 +13,6 @@ type fileAssetStore struct {
store sqlc.Store
}
// NewFileAssetStore creates a new file asset store wrapper
func NewFileAssetStore(store sqlc.Store) adapters.FileAssetStore {
return &fileAssetStore{
store: store,

View file

@ -13,7 +13,6 @@ type organizationStore struct {
store sqlc.Store
}
// NewOrganizationStore creates a new organization store
func NewOrganizationStore(store sqlc.Store) adapters.OrganizationStore {
return &organizationStore{store: store}
}
@ -63,7 +62,6 @@ type accountStore struct {
store sqlc.Store
}
// NewAccountStore creates a new account store
func NewAccountStore(store sqlc.Store) adapters.AccountStore {
return &accountStore{store: store}
}

View file

@ -12,7 +12,6 @@ type subscriptionStore struct {
store sqlc.Store
}
// NewSubscriptionStore creates a new subscription store
func NewSubscriptionStore(store sqlc.Store) adapters.SubscriptionStore {
return &subscriptionStore{store: store}
}

View file

@ -23,7 +23,6 @@ type PostgresManager struct {
connPool *pgxpool.Pool
}
// NewPostgresManager creates a new PostgresManager
func NewPostgresManager(config Config, connPool *pgxpool.Pool) *PostgresManager {
return &PostgresManager{
config: config,

View file

@ -19,7 +19,6 @@ type SQLStore struct {
*Queries
}
// NewStore creates a new store
func NewStore(connPool *pgxpool.Pool) Store {
return &SQLStore{
connPool: connPool,

View file

@ -27,7 +27,6 @@ type InMemoryEventBus struct {
closed bool
}
// NewInMemoryEventBus creates a new in-memory event bus
func NewInMemoryEventBus(middleware ...EventMiddleware) EventBus {
return &InMemoryEventBus{
subscribers: make(map[string][]EventHandler[Event]),

View file

@ -2,7 +2,6 @@ package cmd
import "go.uber.org/dig"
// Init initializes the event bus dependencies
func Init(container *dig.Container) error {
if err := ProvideEventBus(container); err != nil {
return err

View file

@ -22,7 +22,6 @@ type r2Repository struct {
bucketName string
}
// NewR2Repository creates a new Cloudflare R2 repository using AWS SDK v2
func NewR2Repository(cfg *fileconfig.Config) (domain.R2Repository, error) {
// Create custom AWS config for R2
r2Cfg, err := config.LoadDefaultConfig(context.Background(),
@ -74,7 +73,6 @@ func (r *r2Repository) ensureBucket(ctx context.Context) error {
return nil
}
// UploadObject uploads a file to R2
func (r *r2Repository) UploadObject(ctx context.Context, objectKey string, content io.Reader, size int64, contentType string) error {
_, err := r.client.PutObject(ctx, &s3.PutObjectInput{
Bucket: aws.String(r.bucketName),
@ -105,7 +103,6 @@ func (r *r2Repository) DownloadObject(ctx context.Context, objectKey string) (io
return result.Body, nil
}
// DeleteObject deletes a file from R2
func (r *r2Repository) DeleteObject(ctx context.Context, objectKey string) error {
_, err := r.client.DeleteObject(ctx, &s3.DeleteObjectInput{
Bucket: aws.String(r.bucketName),

View file

@ -52,7 +52,6 @@ type CircuitBreaker struct {
resetTimeout time.Duration
}
// NewCircuitBreaker creates a new circuit breaker
func NewCircuitBreaker(maxFailures int, resetTimeout time.Duration) *CircuitBreaker {
return &CircuitBreaker{
maxFailures: maxFailures,

View file

@ -45,8 +45,6 @@ type Middleware struct {
config *MiddlewareConfig
}
// NewMiddleware creates a new subscription middleware instance.
//
// Parameters:
// - provider: The subscription status provider (implements SubscriptionStatusProvider)
// - config: Middleware configuration (optional, uses defaults if nil)

View file

@ -19,7 +19,6 @@ type Client struct {
debug bool
}
// NewClient creates a new Polar HTTP client
func NewClient(config *Config) (*Client, error) {
if err := config.Validate(); err != nil {
return nil, fmt.Errorf("invalid configuration: %w", err)

View file

@ -7,7 +7,6 @@ import (
"go.uber.org/dig"
)
// Init initializes the Polar package and registers dependencies
func Init(container *dig.Container) error {
// Provide Polar configuration using viper
if err := container.Provide(func() (*polar.Config, error) {

View file

@ -24,7 +24,6 @@ type HTTPServer struct {
ipProtection *middleware.IPProtection
}
// NewHTTPServer creates a new HTTP server instance
func NewHTTPServer(
config *config.Config,
router *gin.Engine,

View file

@ -26,7 +26,6 @@ type RBACPolicyService struct {
logger logger.Logger
}
// NewRBACPolicyService creates a new RBAC policy service
func NewRBACPolicyService(
client *Client,
redisClient redis.Client,