# raghadmjbel/ai-smartpm architecture

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

- Interactive diagram: https://gitdiagram.com/raghadmjbel/ai-smartpm
- Repository: https://github.com/raghadmjbel/ai-smartpm

## Overview

1. **Repository shape**
   - This is a three-tier system: a **React frontend**, an **ASP.NET Core backend API**, and a separate **Python AI module**.
   - The root also contains **docker-compose** for orchestration plus docs for requirements and integration planning.

2. **Frontend subsystem (`smartpm-frontend`)**
   - Built with **React + Vite**.
   - It is the user interaction layer for login/register, project management, and artifact generation.
   - Key pages/components suggest flows for **project lists, project details, specification entry, AI-generated artifacts, WBS tree, and Gantt chart visualization**.

3. **Frontend data access boundary**
   - API calls are isolated under `src/api` with dedicated clients for **auth** and **project** operations.
   - `axios.js` centralizes HTTP transport, so the UI is not directly coupled to backend endpoints.
   - This makes the frontend mostly a consumer of backend-provided project, auth, and AI-related data.

4. **Backend API subsystem (`Backend/SmartPm.Api`)**
   - Built on **ASP.NET Core Web API**.
   - Controllers are split by domain: **AuthController** and **projectsController**.
   - DTOs are explicit and numerous, which indicates the backend is designed as a contract-first API layer rather than exposing entities directly.

5. **Backend domain and persistence**
   - The backend uses **Entity Framework Core** with migrations and an `AppDbContext`.
   - Core models include **User**, **Project**, **ProjectSpecification**, **ProjectArtifact**, and **ArtifactType**.
   - The migration history shows the system evolved to include **authentication**, **user-project relationships**, and **artifact versioning**.

6. **Backend service layer**
   - Business logic is separated from controllers into services such as:
     - `ArtifactGenerationService`
     - `ProjectContextBuilder`
     - `AIResponseValidator`
     - `JwtService`
     - `PasswordHasher`
   - This suggests the backend owns orchestration, validation, auth token creation, and preparation of context before any AI call is made.

7. **AI integration boundary**
   - The Python `AI_Module` is a separate service boundary, not just a library.
   - Its structure implies a pipeline for:
     - building prompts,
     - appending project context,
     - generating outputs,
     - normalizing AI responses.
   - The module’s tests include **generation behavior**, **real AI integration**, and **WBS-from-Gantt conversion**, which indicates it is responsible for structured project-planning outputs.

8. **Likely data flow for artifact generation**
   - A user submits a project/specification in the frontend.
   - The frontend sends the request to the backend API.
   - The backend loads project context from the database, validates/assembles it, and forwards the request to the AI module.
   - The AI module returns normalized structured output.
   - The backend validates and persists the generated artifact, including versioning.

9. **Authentication and authorization**
   - Auth is handled in the backend with **JWT** and password hashing.
   - The presence of `AuthController`, `User` model, and auth DTOs indicates the backend is the source of truth for identity.
   - The frontend likely stores and reuses tokens via its API layer, but token issuance and validation belong to the backend.

10. **Project and artifact domain**
   - The main business object appears to be a **project** with associated **specifications** and **artifacts**.
   - Artifacts appear to be generated outputs tied to project versions, which is reinforced by the version-related migrations.
   - The UI components for **WBS tree** and **Gantt chart** suggest artifact outputs are not just text, but structured project-planning data.

11. **Operational/container boundary**
   - `docker-compose.yml` is the top-level integration point for running the system together.
   - Each major subsystem also has its own packaging file:
     - `SmartPm.Api.csproj` for backend,
     - `package.json` for frontend,
     - `requirements.txt` and `DockerFile` for AI.
   - That means deployment is likely service-based rather than a single monolith.

12. **Documentation and design artifacts**
   - `docs/Requirements.md` and `docs/Integration_Plan.md` indicate the repo is still in an early integration phase.
   - The README also says the system is in the “Initial Structure” phase, so some runtime wiring is expected to be incomplete even though the architecture is already partitioned.

13. **Testing boundaries**
   - Backend and frontend are separated by their own APIs and UI components; the AI module has focused tests around generation logic.
   - The AI tests are especially important because they validate the structure of machine-generated outputs, which is a critical contract for the backend and UI.

14. **Best architecture-diagram summary**
   - Draw this as: **React UI → ASP.NET Core API → database + Python AI service**.
   - Put **auth, project persistence, and AI orchestration** in the backend boundary.
   - Put **prompting/generation/normalization** in the AI boundary.
   - Put **presentation and user interaction** in the frontend boundary.

Main entry points: [`Backend/SmartPm.Api/Services/ArtifactGenerationService.cs`](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Services/ArtifactGenerationService.cs) (Artifact Service), [`smartpm-frontend/src/App.jsx`](https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/App.jsx) (React UI), [`docker-compose.yml`](https://github.com/raghadmjbel/ai-smartpm/blob/main/docker-compose.yml) (Docker Compose), [`Backend/SmartPm.Api/Controllers/AuthController.cs`](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Controllers/AuthController.cs) (Auth API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_ui["React UI<br/>react app<br/>[App.jsx]"]
  node_home["Home<br/>page<br/>[Home.jsx]"]
  node_auth_pages["Auth Pages<br/>[Login.jsx]"]
  node_project_details["Project Details<br/>page<br/>[ProjectDetails.jsx]"]
  node_project_components["Project Views<br/>components<br/>[ProjectList.jsx]"]
  node_frontend_api["API Layer<br/>client boundary<br/>[axios.js]"]
end

subgraph group_backend["Backend API"]
  node_auth_controller["Auth API<br/>controller<br/>[AuthController.cs]"]
  node_project_controller["Projects API<br/>controller"]
  node_dto_layer["DTOs<br/>contracts<br/>[ProjectDto.cs]"]
  node_artifact_service["Artifact Service"]
  node_context_builder["Context Builder"]
  node_validation_auth["Validation & Auth<br/>services"]
  node_db_context[("App DbContext<br/>ef core<br/>[AppDbContext.cs]")]
  node_domain_models["Domain Models<br/>entities<br/>[project.cs]"]
end

subgraph group_ai["AI Module"]
  node_prompt_pipeline["Prompt Pipeline<br/>[prompt_builder.py]"]
  node_generation_core["Generation Core<br/>pipeline<br/>[generators.py]"]
  node_response_normalizer["Normalizer<br/>pipeline"]
  node_ai_entry["AI Service<br/>[main.py]"]
end

subgraph group_infra["Integration"]
  node_compose["Docker Compose<br/>orchestration<br/>[docker-compose.yml]"]
  node_docs["Docs<br/>[Requirements.md]"]
end

node_ui -->|"routes to"| node_home
node_ui -->|"shows"| node_auth_pages
node_ui -->|"shows"| node_project_details
node_ui -->|"composes"| node_project_components
node_project_components -->|"calls"| node_frontend_api
node_frontend_api -->|"auth requests"| node_auth_controller
node_frontend_api -->|"project requests"| node_project_controller
node_auth_controller -->|"uses"| node_dto_layer
node_project_controller -->|"uses"| node_dto_layer
node_auth_controller -->|"delegates"| node_validation_auth
node_project_controller -->|"delegates"| node_artifact_service
node_artifact_service -->|"prepares context"| node_context_builder
node_artifact_service -->|"validates output"| node_response_normalizer
node_artifact_service -->|"persists"| node_db_context
node_db_context -->|"maps"| node_domain_models
node_artifact_service -->|"calls"| node_ai_entry
node_ai_entry -->|"orchestrates"| node_prompt_pipeline
node_prompt_pipeline -->|"feeds"| node_generation_core
node_generation_core -->|"returns"| node_response_normalizer
node_compose -->|"runs"| node_ui
node_compose -->|"runs"| node_auth_controller
node_compose -->|"runs"| node_ai_entry
node_docs -->|"describes"| node_compose

click node_ui "https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/App.jsx"
click node_home "https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/pages/Home.jsx"
click node_auth_pages "https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/pages/Login.jsx"
click node_project_details "https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/pages/ProjectDetails.jsx"
click node_project_components "https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/components/ProjectList.jsx"
click node_frontend_api "https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/api/axios.js"
click node_auth_controller "https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Controllers/AuthController.cs"
click node_project_controller "https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Controllers/projectsController.cs"
click node_dto_layer "https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/DTOs/ProjectDto.cs"
click node_artifact_service "https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Services/ArtifactGenerationService.cs"
click node_context_builder "https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Services/ProjectContextBuilder.cs"
click node_validation_auth "https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Services/AIResponseValidator.cs"
click node_db_context "https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Data/AppDbContext.cs"
click node_domain_models "https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Models/project.cs"
click node_prompt_pipeline "https://github.com/raghadmjbel/ai-smartpm/blob/main/AI_Module/app/prompt_builder.py"
click node_generation_core "https://github.com/raghadmjbel/ai-smartpm/blob/main/AI_Module/app/generators.py"
click node_response_normalizer "https://github.com/raghadmjbel/ai-smartpm/blob/main/AI_Module/app/response_normalizer.py"
click node_ai_entry "https://github.com/raghadmjbel/ai-smartpm/blob/main/AI_Module/app/main.py"
click node_compose "https://github.com/raghadmjbel/ai-smartpm/blob/main/docker-compose.yml"
click node_docs "https://github.com/raghadmjbel/ai-smartpm/blob/main/docs/Requirements.md"

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_ui,node_home,node_auth_pages,node_project_details,node_project_components,node_frontend_api toneBlue
class node_auth_controller,node_project_controller,node_dto_layer,node_artifact_service,node_context_builder,node_validation_auth,node_db_context,node_domain_models toneAmber
class node_prompt_pipeline,node_generation_core,node_response_normalizer,node_ai_entry toneMint
class node_compose,node_docs toneRose
```

## Components

### Frontend

React + Vite user interface and API boundary

- [React UI](https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/App.jsx): react app · User-facing application shell and routing · `smartpm-frontend/src/App.jsx`
- [Home](https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/pages/Home.jsx): page · Entry and landing screen · `smartpm-frontend/src/pages/Home.jsx`
- [Auth Pages](https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/pages/Login.jsx): pages · Login and registration screens · `smartpm-frontend/src/pages/Login.jsx`
- [Project Details](https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/pages/ProjectDetails.jsx): page · Project view and artifact workflow · `smartpm-frontend/src/pages/ProjectDetails.jsx`
- [Project Views](https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/components/ProjectList.jsx): components · Project list, form, specification, artifact, and visualization components · `smartpm-frontend/src/components/ProjectList.jsx`
- [API Layer](https://github.com/raghadmjbel/ai-smartpm/blob/main/smartpm-frontend/src/api/axios.js): client boundary · Frontend HTTP access for auth and project operations · `smartpm-frontend/src/api/axios.js`

### Backend API

ASP.NET Core application, domain logic, and persistence

- [Auth API](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Controllers/AuthController.cs): controller · JWT login and registration endpoints · `Backend/SmartPm.Api/Controllers/AuthController.cs`
- [Projects API](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Controllers/projectsController.cs): controller · Project, specification, and artifact endpoints · `Backend/SmartPm.Api/Controllers/projectsController.cs`
- [DTOs](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/DTOs/ProjectDto.cs): contracts · Request and response shapes for API boundaries · `Backend/SmartPm.Api/DTOs/ProjectDto.cs`
- [Artifact Service](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Services/ArtifactGenerationService.cs): service · Coordinates generation and persistence of artifacts · `Backend/SmartPm.Api/Services/ArtifactGenerationService.cs`
- [Context Builder](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Services/ProjectContextBuilder.cs): service · Assembles project context before AI calls · `Backend/SmartPm.Api/Services/ProjectContextBuilder.cs`
- [Validation & Auth](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Services/AIResponseValidator.cs): services · AI response validation, JWT, and password hashing · `Backend/SmartPm.Api/Services/AIResponseValidator.cs`
- [App DbContext](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Data/AppDbContext.cs): ef core · Database access and entity mapping · `Backend/SmartPm.Api/Data/AppDbContext.cs`
- [Domain Models](https://github.com/raghadmjbel/ai-smartpm/blob/main/Backend/SmartPm.Api/Models/project.cs): entities · User, project, specification, and artifact entities · `Backend/SmartPm.Api/Models/project.cs`

### AI Module

Python service for prompt, generation, and normalization

- [Prompt Pipeline](https://github.com/raghadmjbel/ai-smartpm/blob/main/AI_Module/app/prompt_builder.py): pipeline · Builds prompts and appends project context · `AI_Module/app/prompt_builder.py`
- [Generation Core](https://github.com/raghadmjbel/ai-smartpm/blob/main/AI_Module/app/generators.py): pipeline · AI generation routines and output shaping · `AI_Module/app/generators.py`
- [Normalizer](https://github.com/raghadmjbel/ai-smartpm/blob/main/AI_Module/app/response_normalizer.py): pipeline · Normalizes AI responses into structured outputs · `AI_Module/app/response_normalizer.py`
- [AI Service](https://github.com/raghadmjbel/ai-smartpm/blob/main/AI_Module/app/main.py): service · Python service entrypoint for generation requests · `AI_Module/app/main.py`

### Integration

Top-level orchestration and documentation

- [Docker Compose](https://github.com/raghadmjbel/ai-smartpm/blob/main/docker-compose.yml): orchestration · Runs the frontend, backend, and AI service together · `docker-compose.yml`
- [Docs](https://github.com/raghadmjbel/ai-smartpm/blob/main/docs/Requirements.md): design docs · Requirements and integration plan · `docs/Requirements.md`

## Connections

- React UI → Home: routes to · App includes the landing experience
- React UI → Auth Pages: shows · Login and registration screens are part of the UI
- React UI → Project Details: shows · Project workflow is centered in the details page
- React UI → Project Views: composes · Reusable project, artifact, and chart components
- Project Views → API Layer: calls · UI components use the API client layer
- API Layer → Auth API: auth requests · Authentication traffic goes through the backend API
- API Layer → Projects API: project requests · Project and artifact operations go to the backend
- Auth API → DTOs: uses · Controller contracts are DTO-driven
- Projects API → DTOs: uses · Project endpoints exchange explicit DTOs
- Auth API → Validation & Auth: delegates · Token and password handling are service-backed
- Projects API → Artifact Service: delegates · Artifact generation is coordinated in services
- Artifact Service → Context Builder: prepares context · Project data is assembled before AI generation
- Artifact Service → Normalizer: validates output · AI output is checked before persistence
- Artifact Service → App DbContext: persists · Generated artifacts and project data are stored in the database
- App DbContext → Domain Models: maps · EF Core maps the core entities
- Artifact Service → AI Service: calls · Backend forwards generation work to the Python service
- AI Service → Prompt Pipeline: orchestrates · Service entry coordinates prompt construction
- Prompt Pipeline → Generation Core: feeds · Built prompts drive generation routines
- Generation Core → Normalizer: returns · Raw AI output is normalized into structured data
- Docker Compose → React UI: runs · Orchestration includes the frontend service
- Docker Compose → Auth API: runs · Orchestration includes the backend API
- Docker Compose → AI Service: runs · Orchestration includes the AI service
- Docs → Docker Compose: describes · Documentation captures the integration setup
