# angular-university/nestjs-course architecture

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

- Interactive diagram: https://gitdiagram.com/angular-university/nestjs-course
- Repository: https://github.com/angular-university/nestjs-course

## Overview

##### Project Type & Purpose
- This is a full-stack sample application used in a NestJs course.
- Frontend: Angular SPA (served on port 4200).
- Backend: NestJs REST API (launched via `rest-api/npm run server`).
- Data layer: MongoDB (populated via scripts).

##### File Structure
- Top level:
– angular.json, package.json, proxy.json, src/ (Angular app), rest-api/ (NestJs server), shared/ (common DTOs).
- Frontend (src/):
– app/auth (login, interceptor, service), app/courses (modules, components, HTTP service).
– environments, assets, styles, test configs.
- Backend (rest-api/src/):
– auth (controller, module, user schema), courses (controllers, repositories, schemas), filters, guards, middleware, pipes.
– main.ts bootstraps NestJs.
– populate-db.ts & db-data.ts seed MongoDB.
- Config files: proxy.json (for dev‐proxy from Angular → NestJs), karma.conf.js, protractor.conf.js.

##### Pull Insights from README
- Describes how to run both servers, Node 16 requirement.
- Emphasizes separate package.json in rest-api.

a. Main Components
- Angular Frontend (Browser)
- NestJs Backend (REST API server)
- MongoDB Database
- Shared DTO Layer (Type definitions shared between client & server)
- External tools (Node, Angular CLI, Proxy)
b. Relationships & Data Flows
- Browser ↔ Angular app components ↔ HTTP calls → NestJs controllers
- NestJs controllers → service/repository layer → MongoDB driver (Mongoose)
- Auth flow: LoginComponent → AuthService → AuthController → JWT → Guards
- Seed scripts → MongoDB (populate initial data)
c. Architectural Patterns & Principles
- Separation of concerns:
– Angular modules (feature modules for auth, courses)
– NestJs modules (AuthModule, CoursesModule)
- Layered architecture (controllers → services/repositories → schemas)
- Dependency injection (built-into NestJs, Angular)
- Filters & pipes (error handling, validation)
- Guards & middleware (authentication, authorization, request‐scoped logic)
d. Core Technologies & Frameworks
- Frontend: Angular, RxJS, Angular CLI, HTTP client, interceptors
- Backend: NestJs, TypeScript, Mongoose (MongoDB), Jest (e2e), class-validator
- Dev tooling: Node.js, npm, proxy.json, tsconfig, tslint/prettier

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Side (Angular SPA)"
        direction TB
        Browser["Browser"]:::external
        AngularApp["Angular App (port 4200)"]:::frontend
        AuthModule["AuthModule"]:::frontend
        LoginComponent["LoginComponent"]:::frontend
        AuthService["AuthService"]:::frontend
        AuthInterceptor["AuthInterceptor"]:::frontend
        CoursesModule["CoursesModule"]:::frontend
        CoursesHTTPService["CoursesHTTPService"]:::frontend
        CourseComponent["CourseComponent"]:::frontend
        CoursesCardListComponent["CoursesCardListComponent"]:::frontend
        EditCourseDialogComponent["EditCourseDialogComponent"]:::frontend
        HomeComponent["HomeComponent"]:::frontend
        SharedDTO["Shared DTOs"]:::shared
    end

    %% Server Layer
    subgraph "Server Side (NestJs API)"
        direction TB
        Main["main.ts"]:::backend
        AuthModuleS["AuthModule"]:::backend
        AuthController["AuthController"]:::backend
        UserSchema["UserSchema"]:::backend
        CoursesModuleS["CoursesModule"]:::backend
        CoursesController["CoursesController"]:::backend
        LessonsController["LessonsController"]:::backend
        CoursesRepo["CoursesRepository"]:::backend
        LessonsRepo["LessonsRepository"]:::backend
        CourseSchema["CourseSchema"]:::backend
        LessonSchema["LessonSchema"]:::backend
        Filters["Global Filters"]:::backend
        Guards["Guards"]:::backend
        Pipes["Pipes"]:::backend
        Middleware["Middleware"]:::backend
    end

    %% Infrastructure & Tools
    DB["MongoDB"]:::db
    Proxy["Dev Proxy (proxy.json)"]:::config
    SeedScripts["Seed Scripts"]:::scripts
    E2E_BE["Backend E2E Tests"]:::scripts
    E2E_FE["Frontend E2E Tests"]:::scripts

    %% Relationships
    Browser --> AngularApp
    AngularApp --> AuthModule
    AngularApp --> CoursesModule
    AngularApp --> SharedDTO
    AuthModule --> LoginComponent
    AuthModule --> AuthService
    AuthModule --> AuthInterceptor
    CoursesModule --> CoursesHTTPService
    CoursesModule --> CourseComponent
    CoursesModule --> CoursesCardListComponent
    CoursesModule --> EditCourseDialogComponent
    CoursesModule --> HomeComponent
    AuthService -->|HTTP Requests| Proxy
    CoursesHTTPService -->|HTTP Requests| Proxy

    Proxy -->|forwards to| Main
    Main --> Filters
    Main --> Guards
    Main --> Pipes
    Main --> Middleware
    Main --> AuthModuleS
    Main --> CoursesModuleS

    AuthModuleS --> AuthController
    AuthController --> UserSchema
    AuthController --> Guards

    CoursesModuleS --> CoursesController
    CoursesModuleS --> LessonsController
    CoursesController --> CoursesRepo
    LessonsController --> LessonsRepo
    CoursesRepo --> CourseSchema
    LessonsRepo --> LessonSchema
    CoursesRepo --> DB
    LessonsRepo --> DB

    SeedScripts --> DB
    E2E_BE --> Main
    E2E_FE --> AngularApp

    SharedDTO --> AuthController
    SharedDTO --> LoginComponent
    SharedDTO --> CoursesController
    SharedDTO --> CourseComponent

    %% Click Events
    click AngularApp "https://github.com/angular-university/nestjs-course/blob/master/angular.json"
    click AuthModule "https://github.com/angular-university/nestjs-course/blob/master/src/app/auth/auth.module.ts"
    click AuthService "https://github.com/angular-university/nestjs-course/blob/master/src/app/auth/auth.service.ts"
    click AuthInterceptor "https://github.com/angular-university/nestjs-course/blob/master/src/app/auth/auth.interceptor.ts"
    click LoginComponent "https://github.com/angular-university/nestjs-course/blob/master/src/app/auth/login/login.component.ts"
    click CoursesModule "https://github.com/angular-university/nestjs-course/blob/master/src/app/courses/courses.module.ts"
    click CoursesHTTPService "https://github.com/angular-university/nestjs-course/blob/master/src/app/courses/services/courses-http.service.ts"
    click CourseComponent "https://github.com/angular-university/nestjs-course/blob/master/src/app/courses/course/course.component.ts"
    click CoursesCardListComponent "https://github.com/angular-university/nestjs-course/blob/master/src/app/courses/courses-card-list/courses-card-list.component.ts"
    click EditCourseDialogComponent "https://github.com/angular-university/nestjs-course/blob/master/src/app/courses/edit-course-dialog/edit-course-dialog.component.ts"
    click HomeComponent "https://github.com/angular-university/nestjs-course/blob/master/src/app/courses/home/home.component.ts"
    click SharedDTO "https://github.com/angular-university/nestjs-course/blob/master/shared/course.ts"
    click SharedDTO "https://github.com/angular-university/nestjs-course/blob/master/shared/lesson.ts"
    click Main "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/main.ts"
    click AuthModuleS "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/auth/auth.module.ts"
    click AuthController "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/auth/auth.controller.ts"
    click UserSchema "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/auth/users.schema.ts"
    click CoursesModuleS "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/courses/courses.module.ts"
    click CoursesController "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/courses/controllers/courses.controller.ts"
    click LessonsController "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/courses/controllers/lessons.controller.ts"
    click CoursesRepo "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/courses/repositories/courses.repository.ts"
    click LessonsRepo "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/courses/repositories/lessons.repository.ts"
    click CourseSchema "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/courses/schemas/courses.schema.ts"
    click LessonSchema "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/courses/schemas/lessons.schema.ts"
    click Filters "https://github.com/angular-university/nestjs-course/tree/master/rest-api/src/filters"
    click Guards "https://github.com/angular-university/nestjs-course/tree/master/rest-api/src/guards"
    click Pipes "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/pipes/to-integer.pipe.ts"
    click Middleware "https://github.com/angular-university/nestjs-course/blob/master/rest-api/src/middleware/get-user.middleware.ts"
    click SeedScripts "https://github.com/angular-university/nestjs-course/blob/master/rest-api/populate-db.ts"
    click SeedScripts "https://github.com/angular-university/nestjs-course/blob/master/rest-api/db-data.ts"
    click E2E_BE "https://github.com/angular-university/nestjs-course/blob/master/rest-api/test/app.e2e-spec.ts"
    click E2E_BE "https://github.com/angular-university/nestjs-course/blob/master/rest-api/test/jest-e2e.json"
    click E2E_FE "https://github.com/angular-university/nestjs-course/blob/master/e2e/app.po.ts"
    click E2E_FE "https://github.com/angular-university/nestjs-course/blob/master/e2e/tsconfig.e2e.json"
    click Proxy "https://github.com/angular-university/nestjs-course/blob/master/proxy.json"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef db fill:#FFA500,stroke:#000,stroke-width:1px
    classDef shared fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef scripts fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef config fill:#FFE4B5,stroke:#000,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#000,stroke-width:1px
```
