# ahmadmdabit/sinavolusturma architecture

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

- Interactive diagram: https://gitdiagram.com/ahmadmdabit/sinavolusturma
- Repository: https://github.com/ahmadmdabit/sinavolusturma

## Overview

##### Project Type and Purpose
- This is a full-stack, N-Tier web application for creating and taking exams.
- Technologies:
– UI: ASP.NET Core MVC (Razor pages, controllers, views, static assets)
– API: ASP.NET Core Web API (REST controllers, JWT authentication)
– BLL: Business logic library (services, policies)
– DAL: Data access library (repositories, entities)
– Common: Shared helpers, extensions, result wrappers
– Database: SQLite (file-based, stored under API/App_Data)

##### File Structure
Top-level modules:
- UI/             – MVC web front-end with controllers, Razor views, static assets, JWT middleware
- API/            – REST API with controllers (Answer, Exam, Question, User, etc.), JWT auth helpers, SQLite DB file
- BLL/            – Business layer classes handling use cases, validation, mapping
- DAL/            – Repository layer interacting with SQLite via entities & repositories
- Common/         – Shared DTOs, extension methods, ApiResult wrappers
Configuration & cross-cut concerns:
- appsettings.json (connection strings, JWT settings)
- Startup.cs in both UI and API (DI container, middleware pipelines)
- JwtMiddleware, AllowAnonymous/Authorize attributes

##### Extract Additional Insights from README
- Confirms N-Tier architecture
- SQLite DB stored in API/App_Data
- Two startup projects: UI and API
- Authentication flows: Admin vs. normal user

a. Main Components
1. Client Browser
2. UI Web App (ASP.NET Core MVC)
3. API Service (ASP.NET Core Web API)
4. Business Logic Layer (BLL)
5. Data Access Layer (DAL)
6. SQLite Database
7. Shared Common Library (used by API, BLL, DAL)

b. Relationships & Data Flows
– Browser ↔ UI: HTTPS requests for pages & static assets; form submissions
– UI → API: HTTP calls for data (exams, questions, authentication) carrying JWT tokens
– API → BLL: Direct method calls via DI to perform business operations
– BLL → DAL: Repository calls to CRUD entities
– DAL → SQLite: SQL commands to read/write the DB file
– Authentication:
- User login request → API/AuthController → BLL.Authenticate → DAL.UserRepository → returns user
- API issues JWT → UI stores token (cookie or session) → passed on subsequent API calls

c. Key Architectural Patterns
- Layered (N-Tier) Architecture
- Repository Pattern (DAL/Repositories/Base)
- Dependency Injection (Startup.cs registers all layers)
- JWT-Based Authentication & Authorization
- Separation of Concerns (UI vs API vs BLL vs DAL)

d. Technologies & Frameworks
- ASP.NET Core 3.1 (MVC + Web API)
- Entity Framework Core (or lightweight SQLite access)
- SQLite (file-based DB)
- JWT (custom JwtMiddleware, attributes)
- Razor Views, Bootstrap, jQuery (UI)

##### Detailed Element Checklist
- Actors: Admin, Student
- Client: Web Browser
- UI Application: Controllers, Views, JWT middleware
- API Service: Controllers, BLL calls, JWT generation/validation
- BLL: Business services (AnswerBusiness, ExamBusiness, etc.)
- DAL: Repositories (AnswerRepository, ExamRepository, etc.)
- Database: SQLite file (DB.db)
- Shared Common library: ApiResult, AppSettings, Extensions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors and Client
    Admin["Admin User"]:::actor
    Student["Student User"]:::actor
    Browser["Web Browser"]:::browser

    Admin --> Browser
    Student --> Browser

    %% UI Layer
    subgraph "UI (SinavOlusturma.UI)"
        UIApp["UI App"]:::frontend
        UIProj["UI.csproj"]:::frontend
        UIStartup["Startup.cs"]:::frontend
        UIProgram["Program.cs"]:::frontend
        AuthController["AuthController.cs"]:::frontend
        HomeController["HomeController.cs"]:::frontend
        Views["Views/"]:::frontend
        JwtMW_UI["JwtMiddleware.cs"]:::frontend
        WWWRoot["wwwroot/"]:::frontend
    end

    Browser -->|"HTTPS, Razor Pages"| UIApp

    %% API Layer
    subgraph "API (SinavOlusturma.API)"
        APIApp["API Service"]:::api
        APIProj["API.csproj"]:::api
        APIStartup["Startup.cs"]:::api
        APIProgram["Program.cs"]:::api
        AppSettingsAPI["appsettings.json"]:::api
        ControllersAPI["Controllers/"]:::api
        JwtMW_API["JwtMiddleware.cs"]:::api
        AllowAnon["AllowAnonymousAttribute.cs"]:::api
        AuthorizeAttr["AuthorizeAttribute.cs"]:::api
        DBFile["DB.db"]:::db
    end

    UIApp -->|"HTTPS/REST, JWT"| APIApp

    %% BLL Layer
    subgraph "Business Logic Layer (BLL)"
        BLLApp["Business Logic"]:::bll
        BLLProj["BLL.csproj"]:::bll
        Businesses["Businesses/"]:::bll
        Models["Models/"]:::bll
    end

    APIApp -->|"DI Calls"| BLLApp

    %% DAL Layer
    subgraph "Data Access Layer (DAL)"
        DALApp["Data Access"]:::dal
        DALProj["DAL.csproj"]:::dal
        Entities["Entities/"]:::dal
        Repositories["Repositories/"]:::dal
    end

    BLLApp -->|"Repository Calls"| DALApp
    DALApp -->|"SQL Commands"| DBFile

    %% Common Library
    CommonLib["Common Library"]:::common
    CommonProj["Common.csproj"]:::common
    Extensions["Extensions/"]:::common
    Helpers["Helpers/"]:::common

    CommonLib --> APIApp
    CommonLib --> BLLApp
    CommonLib --> DALApp

    %% Click Events
    click UIProj "https://github.com/ahmadmdabit/sinavolusturma/blob/master/UI/UI.csproj"
    click UIStartup "https://github.com/ahmadmdabit/sinavolusturma/blob/master/UI/Startup.cs"
    click UIProgram "https://github.com/ahmadmdabit/sinavolusturma/blob/master/UI/Program.cs"
    click AuthController "https://github.com/ahmadmdabit/sinavolusturma/blob/master/UI/Controllers/AuthController.cs"
    click HomeController "https://github.com/ahmadmdabit/sinavolusturma/blob/master/UI/Controllers/HomeController.cs"
    click Views "https://github.com/ahmadmdabit/sinavolusturma/tree/master/UI/Views/"
    click JwtMW_UI "https://github.com/ahmadmdabit/sinavolusturma/blob/master/UI/Helpers/JwtMiddleware.cs"
    click WWWRoot "https://github.com/ahmadmdabit/sinavolusturma/tree/master/UI/wwwroot/"

    click APIProj "https://github.com/ahmadmdabit/sinavolusturma/blob/master/API/API.csproj"
    click APIStartup "https://github.com/ahmadmdabit/sinavolusturma/blob/master/API/Startup.cs"
    click APIProgram "https://github.com/ahmadmdabit/sinavolusturma/blob/master/API/Program.cs"
    click AppSettingsAPI "https://github.com/ahmadmdabit/sinavolusturma/blob/master/API/appsettings.json"
    click ControllersAPI "https://github.com/ahmadmdabit/sinavolusturma/tree/master/API/Controllers/"
    click JwtMW_API "https://github.com/ahmadmdabit/sinavolusturma/blob/master/API/Helpers/JwtMiddleware.cs"
    click AllowAnon "https://github.com/ahmadmdabit/sinavolusturma/blob/master/API/Helpers/AllowAnonymousAttribute.cs"
    click AuthorizeAttr "https://github.com/ahmadmdabit/sinavolusturma/blob/master/API/Helpers/AuthorizeAttribute.cs"
    click DBFile "https://github.com/ahmadmdabit/sinavolusturma/blob/master/API/App_Data/DB.db"

    click BLLProj "https://github.com/ahmadmdabit/sinavolusturma/blob/master/BLL/BLL.csproj"
    click Businesses "https://github.com/ahmadmdabit/sinavolusturma/tree/master/BLL/Businesses/"
    click Models "https://github.com/ahmadmdabit/sinavolusturma/tree/master/BLL/Models/"

    click DALProj "https://github.com/ahmadmdabit/sinavolusturma/blob/master/DAL/DAL.csproj"
    click Entities "https://github.com/ahmadmdabit/sinavolusturma/tree/master/DAL/Entities/"
    click Repositories "https://github.com/ahmadmdabit/sinavolusturma/tree/master/DAL/Repositories/"

    click CommonProj "https://github.com/ahmadmdabit/sinavolusturma/blob/master/Common/Common.csproj"
    click Extensions "https://github.com/ahmadmdabit/sinavolusturma/tree/master/Common/Extensions/"
    click Helpers "https://github.com/ahmadmdabit/sinavolusturma/tree/master/Common/Helpers/"

    %% Styles
    classDef actor fill:#fff2cc,stroke:#333,shape:circle
    classDef browser fill:#f0f0f0,stroke:#333,shape:rect
    classDef frontend fill:#a2fca6,stroke:#333
    classDef api fill:#a6c8fc,stroke:#333
    classDef bll fill:#fca66a,stroke:#333
    classDef dal fill:#dddddd,stroke:#333
    classDef common fill:#e0a6fc,stroke:#333
    classDef db fill:#c69c6d,stroke:#333,shape:cylinder
```
