# ma7moudalysalem/scholarpath architecture

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

- Interactive diagram: https://gitdiagram.com/ma7moudalysalem/scholarpath
- Repository: https://github.com/ma7moudalysalem/scholarpath

## Overview

1. **Overall shape**
ScholarPath is a monorepo with three main runtime areas: a React/Vite client, an ASP.NET Core 10 backend, and a separate analytics stack. The core business system follows Clean Architecture: the API host is thin, application logic is organized by feature module, domain entities stay pure, and infrastructure contains persistence and external integrations.

2. **Client boundary**
`client/` is a single-page app built with React 19, TypeScript, Vite, Tailwind v4, TanStack Query, Zustand, and SignalR clients. It is the only user-facing presentation layer; all business operations go through `client/src/services/api/*` or real-time hubs. Routing, role-based layouts, and auth guards live in `client/src/routes` and `client/src/components/layout`, which mirrors the platform’s gated access model.

3. **Backend entrypoint**
`server/src/ScholarPath.API` is the HTTP host. It contains controllers per feature area, middleware for exceptions, maintenance mode, and security headers, plus SignalR hubs and webhook endpoints. The API does not implement business rules directly; controllers dispatch into MediatR request handlers in the application layer.

4. **Application layer as the orchestration center**
`server/src/ScholarPath.Application` is the main use-case layer. It is split into modules matching product epics such as Auth, Profile, Scholarships, Applications, Bookings, Community, AI, Payments, Notifications, Admin, Audit, ProfitShare, Resources, and Analytics. Each module exposes commands, queries, DTOs, validators, and event handlers, which makes it the best place to place functional boundaries on a diagram.

5. **Domain layer**
`server/src/ScholarPath.Domain` holds the business model: entities, enums, domain events, exceptions, and small shared abstractions like `ICurrentUserService`. This layer models the platform’s core concepts such as users, scholarships, applications, bookings, payments, notifications, chat, community posts, documents, reviews, upgrade requests, and audit-related state. It is deliberately dependency-free and is the center of the architecture.

6. **Infrastructure layer**
`server/src/ScholarPath.Infrastructure` implements persistence and integration concerns. It contains the EF Core `ApplicationDbContext`, migrations, seed data, encryption-aware model configuration, background jobs, SignalR presence tracking, file storage, email delivery, Stripe, Azure OpenAI, Azure Communication Services, Power BI, audit services, and local/stub implementations for development. This layer is where external systems enter the platform.

7. **Primary data stores and external services**
The operational store is SQL Server 2022 via EF Core. Redis supports real-time scale-out and/or ephemeral coordination. MailHog is used for development email capture. External services include Stripe for payments and Connect payouts, Azure services for AI, key management, and meetings, plus Blob storage and Key Vault in production. These integrations materially shape the architecture because they are wrapped behind application interfaces.

8. **Authentication and access flow**
Auth is built around ASP.NET Core Identity plus RS256 JWTs and refresh-token rotation. The flow includes registration, login, email verification, password reset, SSO, role selection/switching, and onboarding gating. The client uses auth state and route guards; the server enforces access by role and current-user context.

9. **Realtime and event-driven paths**
The platform uses SignalR for chat, community updates, and notifications. In the backend, application event handlers translate domain/application events into notifications, audits, and hub pushes. Presence tracking and message delivery live in infrastructure, so the real-time boundary is: command/query handlers update state, then event handlers fan out updates to connected clients.

10. **Payments and financial workflow**
Payments are a first-class subsystem, not a library call. Stripe PaymentIntents, webhooks, refunds, Connect accounts, and payout jobs are all modeled explicitly. Booking payments, scholarship provider review payments, and profit-share configuration are separate but related flows, with business rules implemented in application services and state transitions enforced before infrastructure calls.

11. **AI and knowledge subsystem**
The AI module includes chatbot, eligibility checking, recommendation generation, recommendation-click logging, import of external scholarships, knowledge-base rebuild, and fine-tuning workflows. Infrastructure provides OpenAI/embedding services, knowledge retrieval/indexing, and dataset providers. The analytics and AI subsystems are connected through curated data, not direct client-side computation.

12. **Analytics stack**
`analytics/` is a separate data platform that extracts CDC data into bronze storage through Azure Data Factory, transforms it with dbt into silver/gold models, and publishes Power BI/streaming outputs. It is fed from operational SQL data and supports admin, consultant, and student reporting. This is a distinct read-optimized boundary from the OLTP backend.

13. **Background processing and automation**
Scheduled and asynchronous work is centralized in infrastructure jobs: booking reminders, completion handling, data export/delete, no-show sweeps, scholarship auto-close, review timeouts/refunds, session expiry, payout processing, and redaction sampling. These jobs are the backbone for SLA-driven behavior that should be drawn separately from request/response paths.

14. **Security, audit, and compliance**
Security-sensitive behavior is cross-cutting: field encryption, file scanning, audit logging, rate limiting, and webhook idempotency are built into the backend. Audit and privacy workflows include data export/delete requests, redaction review, and compliance logs. These concerns appear throughout the layers rather than as a single module.

15. **Testing and delivery**
The repo is heavily test-driven at both layers: xUnit integration/unit tests on the backend and Vitest/Playwright on the frontend. GitHub Actions runs build, test, lint/typecheck, docs, and security scans. Containerized local dev (`docker-compose.yml`, Dockerfiles) supports the backend, client, SQL Server, Redis, and mail services.

16. **How to diagram it**
A good architecture diagram should show a thin SPA client calling a .NET API host, the API delegating into MediatR-based application modules, those modules depending on pure domain abstractions, and infrastructure binding the app to SQL Server and external systems like Stripe, Azure OpenAI, email, file storage, SignalR, and analytics pipelines. The strongest boundaries are: presentation vs API, application vs domain, domain vs infrastructure, and operational OLTP vs analytics warehouse.

Main entry points: [`server/src/ScholarPath.API`](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.API) (API Host), [`server/src/ScholarPath.Application`](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application) (Application), [`client/src`](https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src) (SPA), [`server/src/ScholarPath.Infrastructure`](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure) (Infrastructure)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_app["SPA<br/>React/Vite UI"]
  node_client_routes["Routes<br/>auth/layout routing"]
  node_client_api["API SDK<br/>HTTP clients"]
  node_client_realtime["Realtime<br/>SignalR clients"]
end

subgraph group_server["Server"]
  node_api_host["API Host<br/>ASP.NET host<br/>[ScholarPath.API]"]
  node_api_surface["Controllers<br/>HTTP endpoints<br/>[Controllers]"]
  node_api_mid["Middleware<br/>pipeline policies<br/>[Middleware]"]
  node_app_core["Application<br/>use-case modules"]
  node_app_auth["Auth & Profile<br/>identity flows<br/>[Auth]"]
  node_app_ops["Business Ops<br/>core workflows<br/>[Scholarships]"]
  node_app_realtime["Events<br/>event handlers<br/>[Streaming]"]
  node_domain_model[("Domain<br/>entities & events<br/>[ScholarPath.Domain]")]
  node_infra_core["Infrastructure<br/>persistence & integrations"]
  node_infra_db[("Persistence<br/>EF Core/SQL Server<br/>[Persistence]")]
  node_infra_ext["Integrations<br/>external services<br/>[Services]"]
  node_infra_jobs["Jobs<br/>background automation<br/>[Jobs]"]
end

subgraph group_analytics["Analytics"]
  node_analytics_pipe["Analytics<br/>warehouse pipeline"]
  node_analytics_adf["ADF<br/>CDC ingestion"]
  node_analytics_dbt["dbt<br/>transform models"]
  node_analytics_pbi["Power BI<br/>reporting layer"]
end

subgraph group_ops["Ops"]
  node_repo_tests["Tests<br/>unit/integration/e2e"]
  node_repo_deploy["Deploy<br/>docker/infra"]
end

node_client_app -->|"uses"| node_client_routes
node_client_app -->|"calls"| node_client_api
node_client_app -->|"subscribes"| node_client_realtime
node_client_api -->|"HTTP"| node_api_host
node_client_realtime -->|"SignalR"| node_api_host
node_api_host -->|"exposes"| node_api_surface
node_api_host -->|"wraps"| node_api_mid
node_api_surface -->|"dispatches"| node_app_core
node_app_core -->|"contains"| node_app_auth
node_app_core -->|"contains"| node_app_ops
node_app_core -->|"publishes"| node_app_realtime
node_app_core -->|"depends on"| node_domain_model
node_domain_model -.->|"implemented by"| node_infra_core
node_infra_core -->|"persists to"| node_infra_db
node_infra_core -->|"integrates with"| node_infra_ext
node_infra_core -->|"runs"| node_infra_jobs
node_app_realtime -->|"pushes via"| node_infra_ext
node_app_ops -->|"uses"| node_infra_ext
node_analytics_pipe -->|"ingests"| node_analytics_adf
node_analytics_pipe -->|"transforms"| node_analytics_dbt
node_analytics_pipe -->|"publishes"| node_analytics_pbi
node_repo_tests -.->|"verifies"| node_api_host
node_repo_tests -.->|"verifies"| node_client_app
node_repo_deploy -.->|"deploys"| node_api_host
node_repo_deploy -.->|"deploys"| node_client_app
node_repo_deploy -.->|"provisions"| node_analytics_pipe

click node_client_app "https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src"
click node_client_routes "https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src/routes"
click node_client_api "https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src/services/api"
click node_client_realtime "https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src/services/signalR"
click node_api_host "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.API"
click node_api_surface "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.API/Controllers"
click node_api_mid "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.API/Middleware"
click node_app_core "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application"
click node_app_auth "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application/Auth"
click node_app_ops "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application/Scholarships"
click node_app_realtime "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application/Streaming"
click node_domain_model "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Domain"
click node_infra_core "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure"
click node_infra_db "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure/Persistence"
click node_infra_ext "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure/Services"
click node_infra_jobs "https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure/Jobs"
click node_analytics_pipe "https://github.com/ma7moudalysalem/scholarpath/tree/main/analytics"
click node_analytics_adf "https://github.com/ma7moudalysalem/scholarpath/tree/main/analytics/adf"
click node_analytics_dbt "https://github.com/ma7moudalysalem/scholarpath/tree/main/analytics/dbt"
click node_analytics_pbi "https://github.com/ma7moudalysalem/scholarpath/tree/main/analytics/powerbi"
click node_repo_tests "https://github.com/ma7moudalysalem/scholarpath/tree/main/server/tests"
click node_repo_deploy "https://github.com/ma7moudalysalem/scholarpath/tree/main/infra"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_app,node_client_routes,node_client_api,node_client_realtime toneBlue
class node_api_host,node_api_surface,node_api_mid,node_app_core,node_app_auth,node_app_ops,node_app_realtime,node_domain_model,node_infra_core,node_infra_db,node_infra_ext,node_infra_jobs toneAmber
class node_analytics_pipe,node_analytics_adf,node_analytics_dbt,node_analytics_pbi toneMint
class node_repo_tests,node_repo_deploy toneRose
```

## Components

### Client

React/Vite SPA presentation layer

- [SPA](https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src): React/Vite UI · Single-page app for students, consultants, companies, and admins · `client/src`
- [Routes](https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src/routes): auth/layout routing · Route guards, role-based layouts, and page composition · `client/src/routes`
- [API SDK](https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src/services/api): HTTP clients · Typed client wrappers for backend endpoints · `client/src/services/api`
- [Realtime](https://github.com/ma7moudalysalem/scholarpath/tree/main/client/src/services/signalR): SignalR clients · Chat, community, and notification hub connections · `client/src/services/signalR`

### Server

ASP.NET Core clean architecture backend

- [API Host](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.API): ASP.NET host · Thin HTTP entrypoint with controllers, hubs, and middleware · `server/src/ScholarPath.API`
- [Controllers](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.API/Controllers): HTTP endpoints · Feature controllers, webhooks, diagnostics, and status endpoints · `server/src/ScholarPath.API/Controllers`
- [Middleware](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.API/Middleware): pipeline policies · Exception handling, maintenance mode, and security headers · `server/src/ScholarPath.API/Middleware`
- [Application](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application): use-case modules · MediatR orchestration layer split by product epics · `server/src/ScholarPath.Application`
- [Auth & Profile](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application/Auth): identity flows · Registration, login, role switching, onboarding, profile, and privacy · `server/src/ScholarPath.Application/Auth`
- [Business Ops](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application/Scholarships): core workflows · Scholarships, applications, bookings, payments, reviews, resources, and admin · `server/src/ScholarPath.Application/Scholarships`
- [Events](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Application/Streaming): event handlers · Domain/application events fan out to notifications and hub pushes · `server/src/ScholarPath.Application/Streaming`
- [Domain](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Domain): entities & events · Pure business model and shared domain contracts · `server/src/ScholarPath.Domain`
- [Infrastructure](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure): persistence & integrations · EF Core context, repositories, external services, and adapters · `server/src/ScholarPath.Infrastructure`
- [Persistence](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure/Persistence): EF Core/SQL Server · DbContext, migrations, seeding, and model configuration · `server/src/ScholarPath.Infrastructure/Persistence`
- [Integrations](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure/Services): external services · Stripe, email, AI, file storage, key vault, Power BI, and auth support · `server/src/ScholarPath.Infrastructure/Services`
- [Jobs](https://github.com/ma7moudalysalem/scholarpath/blob/main/server/src/ScholarPath.Infrastructure/Jobs): background automation · Reminders, refunds, expiries, export/delete, payout, and audit sweeps · `server/src/ScholarPath.Infrastructure/Jobs`

### Analytics

Separate reporting and warehouse stack

- [Analytics](https://github.com/ma7moudalysalem/scholarpath/tree/main/analytics): warehouse pipeline · CDC ingestion, dbt modeling, and Power BI outputs · `analytics`
- [ADF](https://github.com/ma7moudalysalem/scholarpath/tree/main/analytics/adf): CDC ingestion · Copies operational SQL changes into bronze storage and reverse ETL · `analytics/adf`
- [dbt](https://github.com/ma7moudalysalem/scholarpath/tree/main/analytics/dbt): transform models · Silver and gold transformations for reporting marts · `analytics/dbt`
- [Power BI](https://github.com/ma7moudalysalem/scholarpath/tree/main/analytics/powerbi): reporting layer · Embedded reports, dataflows, and streaming datasets · `analytics/powerbi`

### Ops

Container, infra, docs, and tests

- [Tests](https://github.com/ma7moudalysalem/scholarpath/tree/main/server/tests): unit/integration/e2e · Backend xUnit and frontend Vitest/Playwright validation · `server/tests`
- [Deploy](https://github.com/ma7moudalysalem/scholarpath/tree/main/infra): docker/infra · Containers, bicep infrastructure, and CI/CD workflows · `infra`

## Connections

- SPA → Routes: uses · SPA renders through route guards and layout shells
- SPA → API SDK: calls · User actions go through typed HTTP clients
- SPA → Realtime: subscribes · Live updates flow through SignalR clients
- API SDK → API Host: HTTP · Front end talks to the .NET API host
- Realtime → API Host: SignalR · Client connects to backend hubs
- API Host → Controllers: exposes · Controllers and webhooks define the external API
- API Host → Middleware: wraps · Request pipeline is protected by middleware
- Controllers → Application: dispatches · Controllers forward requests into application handlers
- Application → Auth & Profile: contains · Identity and onboarding use cases
- Application → Business Ops: contains · Domain workflows and feature modules
- Application → Events: publishes · Event handlers project updates to notifications and hubs
- Application → Domain: depends on · Application logic depends on pure domain concepts
- Domain → Infrastructure: implemented by · Infrastructure supplies persistence and adapters behind domain-facing interfaces
- Infrastructure → Persistence: persists to · EF Core maps the domain to SQL Server
- Infrastructure → Integrations: integrates with · External services are wrapped behind application ports
- Infrastructure → Jobs: runs · Scheduled and asynchronous workflows live here
- Events → Integrations: pushes via · Notifications and real-time notifications are delivered through infrastructure adapters
- Business Ops → Integrations: uses · Payments, email, AI, file storage, and meetings are accessed through ports
- Analytics → ADF: ingests · CDC and reverse ETL land into bronze
- Analytics → dbt: transforms · Warehouse models are built from staged data
- Analytics → Power BI: publishes · Modeled data feeds embedded and operational reports
- Tests → API Host: verifies · Integration tests cover API behavior
- Tests → SPA: verifies · Frontend tests cover UI and flows
- Deploy → API Host: deploys · Container and cloud definitions package the backend
- Deploy → SPA: deploys · Client container and hosting assets package the SPA
- Deploy → Analytics: provisions · Infra and CI include the analytics stack
