# ashutoshadate/sctbackend architecture

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

- Interactive diagram: https://gitdiagram.com/ashutoshadate/sctbackend
- Repository: https://github.com/ashutoshadate/sctbackend

## Overview

##### Project type and purpose
- This is a server-side RESTful Web API backend (ASP.NET Core 8.0) for the Sri Chintamani Trusts website.
- Its responsibilities are to authenticate users, manage “Devotee” records, and process “Contact Us” submissions.

##### File structure
- Controllers: AuthController, DevoteeController, ContactUsController handle HTTP endpoints.
- Data/AppDbContext.cs: EF Core DbContext connecting to the underlying relational database.
- Models:
- Domain entities (Devotee, DevoteeContact)
- DTOs for request/response payloads (UserRequestDto, UserResponseDto).
- Repositories: AuthRepository, DevoteeRepository, ContactUsRepository implement the corresponding I*Repository interfaces; encapsulate business logic & data-access.
- Helper/authHelper.cs: contains authentication routines (e.g., password hashing, JWT generation).
- Migrations: EF Core code-first migrations for creating/updating database schema.
- Program.cs: configures services (DbContext, DI for repositories and helper), Swagger/OpenAPI, middleware, and starts the web host.
- Configuration files: appsettings.json / appsettings.Development.json hold connection strings and settings.

##### README
- Confirms this is the server-side code for the Sri Chintamani Trusts website.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client (Web Browser)"]:::external

    %% API Layer
    subgraph "API Layer"
        direction TB
        AuthController["AuthController"]:::api
        DevoteeController["DevoteeController"]:::api
        ContactUsController["ContactUsController"]:::api
        ProgramNode["Program.cs"]:::config
    end

    %% Business & Data-Access Layer
    subgraph "Business & Data-Access Layer"
        direction TB
        authHelper["authHelper"]:::helper
        IAuthRepo["IAuthRepository"]:::interface
        AuthRepo["AuthRepository"]:::repo
        IDevoteeRepo["IDevoteeRepository"]:::interface
        DevoteeRepo["DevoteeRepository"]:::repo
        IContactRepo["IContactUsRepository"]:::interface
        ContactRepo["ContactUsRepository"]:::repo
    end

    %% Models
    subgraph "Models"
        direction TB
        DevoteeEntity["Devotee"]:::model
        DevoteeContact["DevoteeContact"]:::model
        UserRequestDto["UserRequestDto"]:::dto
        UserResponseDto["UserResponseDto"]:::dto
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        AppDbContext["AppDbContext"]:::dbcontext
        Migrations["Migrations"]:::migrations
        Config["appsettings.json\nappsettings.Development.json"]:::config
    end

    %% Database and External
    DB[(Database)]:::database
    SMTP((SMTP Service)):::external

    %% Connections
    Client -->|"HTTP Request"| AuthController
    Client -->|"HTTP Request"| DevoteeController
    Client -->|"HTTP Request"| ContactUsController

    AuthController -->|"calls"| IAuthRepo
    DevoteeController -->|"calls"| IDevoteeRepo
    ContactUsController -->|"calls"| IContactRepo
    ContactUsController -->|"sends email via"| SMTP

    AuthController -->|"uses"| authHelper

    IAuthRepo --> AuthRepo
    IDevoteeRepo --> DevoteeRepo
    IContactRepo --> ContactRepo

    AuthRepo -->|"queries"| AppDbContext
    DevoteeRepo -->|"queries"| AppDbContext
    ContactRepo -->|"queries"| AppDbContext

    AppDbContext -->|"reads/writes"| DB
    Migrations -->|"updates schema"| DB
    AppDbContext -->|"configured by"| Config
    ProgramNode -->|"configures services and middleware using"| Config

    %% Model relationships
    AuthRepo -->|"maps to"| DevoteeEntity
    DevoteeRepo -->|"maps to"| DevoteeEntity
    DevoteeRepo -->|"maps to"| DevoteeContact
    AuthController -->|"exchanges DTOs"| UserRequestDto
    AuthController -->|"returns DTOs"| UserResponseDto

    %% Click Events
    click AuthController "https://github.com/ashutoshadate/sctbackend/blob/main/Controllers/AuthController.cs"
    click DevoteeController "https://github.com/ashutoshadate/sctbackend/blob/main/Controllers/DevoteeController.cs"
    click ContactUsController "https://github.com/ashutoshadate/sctbackend/blob/main/Controllers/ContactUsController.cs"
    click ProgramNode "https://github.com/ashutoshadate/sctbackend/blob/main/Program.cs"
    click authHelper "https://github.com/ashutoshadate/sctbackend/blob/main/Helper/authHelper.cs"
    click IAuthRepo "https://github.com/ashutoshadate/sctbackend/blob/main/Interfaces/IAuthRepository.cs"
    click IDevoteeRepo "https://github.com/ashutoshadate/sctbackend/blob/main/Interfaces/IDevoteeRepository.cs"
    click IContactRepo "https://github.com/ashutoshadate/sctbackend/blob/main/Interfaces/IContactUsRepository.cs"
    click AuthRepo "https://github.com/ashutoshadate/sctbackend/blob/main/Repositories/AuthRepository.cs"
    click DevoteeRepo "https://github.com/ashutoshadate/sctbackend/blob/main/Repositories/DevoteeRepository.cs"
    click ContactRepo "https://github.com/ashutoshadate/sctbackend/blob/main/Repositories/ContactUsRepository.cs"
    click DevoteeEntity "https://github.com/ashutoshadate/sctbackend/blob/main/Models/Devotee.cs"
    click DevoteeContact "https://github.com/ashutoshadate/sctbackend/blob/main/Models/DevoteeContact.cs"
    click UserRequestDto "https://github.com/ashutoshadate/sctbackend/blob/main/Models/DTO/UserRequestDto.cs"
    click UserResponseDto "https://github.com/ashutoshadate/sctbackend/blob/main/Models/DTO/UserResponseDto.cs"
    click AppDbContext "https://github.com/ashutoshadate/sctbackend/blob/main/Data/AppDbContext.cs"
    click Migrations "https://github.com/ashutoshadate/sctbackend/tree/main/Migrations/"
    click Config "https://github.com/ashutoshadate/sctbackend/blob/main/appsettings.json"

    %% Styles
    classDef api fill:#cce5ff,stroke:#0366d6,color:#0366d6;
    classDef repo fill:#e6ffed,stroke:#28a745,color:#28a745;
    classDef helper fill:#e6ffed,stroke:#28a745,color:#28a745;
    classDef interface fill:#e6f7ff,stroke:#00529b,color:#00529b,stroke-dasharray:5 5;
    classDef dbcontext fill:#fff5cc,stroke:#ffdd57,color:#b58900;
    classDef migrations fill:#fff5cc,stroke:#ffdd57,color:#b58900,stroke-dasharray:5 5;
    classDef database fill:#f0f0f0,stroke:#555,color:#555,stroke-width:2px;
    classDef external fill:#f9f9f9,stroke:#999,color:#999,stroke-dasharray:5 5;
    classDef config fill:#ffecec,stroke:#ff0000,color:#b58900;
    classDef model fill:#f5f5f5,stroke:#333,color:#333;
    classDef dto fill:#f5f5f5,stroke:#333,color:#333;
```
