# nahidhasan141400/rcc_backend architecture

> Architecture diagram of the GitHub repository nahidhasan141400/rcc_backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nahidhasan141400/rcc_backend
- Repository: https://github.com/nahidhasan141400/rcc_backend

## Overview

##### Main System Components

a) Frontend Layer:
- Public-facing web interface (/src/public)
- Static assets handling
- Various front-end pages (Home, About, Ministry, Get Involved)

b) Backend API Layer:
- Main Express.js server (src/server.ts)
- Router layer (/src/routers)
- Controller layer (/src/controllers)
- Service layer (/src/service)

c) Database Layer:
- Database connection (/src/database)
- Models (Event, Sermons, Video, Admin, etc.)

d) External Services:
- Payment processing systems (PayPal, SSLCommerz)
- SMS service
- Email service
- Nginx server

##### Component Relationships

a) Client-Server Flow:
**Client → Nginx → Express Server → Controllers → Services → Database**

b) Authentication Flow:
**Client → Auth Middleware → Protected Routes**

c) Payment Processing Flow:
**Client → Payment Controllers → PayPal/SSLCommerz → Database**

##### Specific Implementation Details

a) MVC Pattern:
- Models (/src/database/model)
- Controllers (/src/controllers)
- Views (/src/public)

b) Service Layer:
- Separation between controllers and services
- Business logic isolation

c) Middleware Layer:
- Authentication
- Error handling
- File upload handling (Multer)

##### Additional Components

Supporting features:
- Utility services (src/utility)
- Date handling
- Encryption
- OTP system
- Logging system
- IP handling

##### Technical Stack Callouts

Key technologies:
- Node.js/Express
- TypeScript
- MongoDB (assumed from model structure)
- Nginx
- PayPal/SSLCommerz integration
- Email/SMS services

Remember to show the clear separation of concerns between different layers and how the various modules interact while maintaining security through the authentication middleware.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CL[Browser/Client]
    end

    subgraph "Frontend Layer"
        PI["Public Interface"]:::frontend
        SA["Static Assets"]:::frontend
    end

    subgraph "Server Layer"
        NG[Nginx Server]:::server
        MS["Main Server"]:::server
        AC["App Configuration"]:::server
        EC["Environment Config"]:::server
    end

    subgraph "API Layer"
        RT["Routers"]:::api
        CT["Controllers"]:::api
        SV["Services"]:::api
    end

    subgraph "Authentication"
        AA["Admin Auth"]:::auth
        UA["User Auth"]:::auth
    end

    subgraph "Database Layer"
        DB["Database Connection"]:::database
        subgraph "Models"
            EM["Event Model"]:::model
            SM["Sermon Model"]:::model
            VM["Video Model"]:::model
            AM["Admin Model"]:::model
        end
    end

    subgraph "Payment Systems"
        PP["PayPal Integration"]:::payment
        SSL["SSLCommerz Integration"]:::payment
    end

    subgraph "Utility Services"
        SMS["SMS Service"]:::utility
        EML["Email Service"]:::utility
        ENC["Encryption"]:::utility
        LOG["Logger"]:::utility
        OTP["OTP System"]:::utility
        IP["IP Handler"]:::utility
        DU["Date Utilities"]:::utility
    end

    subgraph "File Handling"
        MU["Multer Config"]:::file
        PC["Photo Processing"]:::file
    end

    subgraph "Error Handling"
        EH["Error Handler"]:::error
    end

    subgraph "Content Management"
        EMC["Event Controller"]:::content
        SC["Sermon Controller"]:::content
        VC["Video Controller"]:::content
        PC2["Page Content"]:::content
    end

    %% Relationships
    CL --> NG
    NG --> MS
    MS --> RT
    RT --> CT
    CT --> SV
    SV --> DB
    CT --> PP
    CT --> SSL
    CT --> SMS
    CT --> EML
    AA --> RT
    UA --> RT

    %% Click Events
    click PI "https://github.com/nahidhasan141400/rcc_backend/tree/main/src/public"
    click SA "https://github.com/nahidhasan141400/rcc_backend/tree/main/src/public/assets"
    click MS "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/server.ts"
    click AC "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/app/index.ts"
    click EC "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/config/env.ts"
    click RT "https://github.com/nahidhasan141400/rcc_backend/tree/main/src/routers"
    click CT "https://github.com/nahidhasan141400/rcc_backend/tree/main/src/controllers"
    click SV "https://github.com/nahidhasan141400/rcc_backend/tree/main/src/service"
    click DB "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/database/index.ts"
    click AA "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/middleware/auth/isAdmin.ts"
    click UA "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/middleware/auth/isUserApp.ts"
    click PP "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/paypal/index.ts"
    click SSL "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/sslcommerz/index.ts"
    click SMS "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/utility/SMS/SMS.ts"
    click EML "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/utility/email/Connection.ts"
    click ENC "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/utility/encryption.ts"
    click LOG "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/utility/logger.ts"
    click OTP "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/utility/otp.ts"
    click IP "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/utility/ip.ts"
    click DU "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/utility/Date/DateFn.ts"
    click MU "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/middleware/multer/multer.ts"
    click PC "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/middleware/multer/photoComposure.ts"
    click EH "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/middleware/errorHandler/index.ts"
    click EMC "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/controllers/Event/Event.controller.ts"
    click SC "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/controllers/sermons/Sermons.controller.ts"
    click VC "https://github.com/nahidhasan141400/rcc_backend/blob/main/src/controllers/video/Video.controller.ts"
    click PC2 "https://github.com/nahidhasan141400/rcc_backend/tree/main/src/controllers/front-end"

    %% Styles
    classDef frontend fill:#3498db
    classDef server fill:#2ecc71
    classDef api fill:#e74c3c
    classDef auth fill:#f1c40f
    classDef database fill:#9b59b6
    classDef model fill:#8e44ad
    classDef payment fill:#e67e22
    classDef utility fill:#1abc9c
    classDef file fill:#34495e
    classDef error fill:#c0392b
    classDef content fill:#16a085
```
