How lucasnobsob/cursoangular works
Purpose and topology
This is a full-stack supplier/product management application: an Angular SPA consumes a versioned ASP.NET Core API. The backend is split into API, business/domain, and EF Core data projects; the frontend currently centers on account registration/login and shared navigation.
Backend host and API boundary
ASP.NET Core 3.1 starts through back-end/src/DevIO.Api/Program.cs and composes HTTP pipeline, configuration, DI, identity, Swagger, and middleware in back-end/src/DevIO.Api/Startup.cs. REST endpoints are versioned under V1, with authentication plus supplier and product controllers:
• back-end/src/DevIO.Api/V1/Controllers/AuthController.cs
• back-end/src/DevIO.Api/V1/Controllers/FornecedoresController.cs
• back-end/src/DevIO.Api/V1/Controllers/ProdutosController.cs
Controllers translate API view models to domain entities and delegate work; they should not own persistence or domain rules.
Cross-cutting API services
Configuration modules isolate host concerns: dependency registration, AutoMapper, ASP.NET Identity/JWT-style auth setup, and Swagger are under back-end/src/DevIO.Api/Configuration/. API-specific identity storage is represented by back-end/src/DevIO.Api/Data/ApplicationDbContext.cs. Global exception handling and authorization/user access abstractions form the request boundary:
• back-end/src/DevIO.Api/Extensions/ExceptionMiddleware.cs
• back-end/src/DevIO.Api/Extensions/CustomAuthorize.cs
• back-end/src/DevIO.Api/Extensions/AspNetUser.cs
Domain and application services
DevIO.Business is the persistence-independent core. It models suppliers (Fornecedor), products (Produto), and addresses, validates their business constraints, and exposes repository/service contracts:
• back-end/src/DevIO.Business/Models/Fornecedor.cs
• back-end/src/DevIO.Business/Services/FornecedorService.cs
• back-end/src/DevIO.Business/Services/ProdutoService.cs
Services use notification-based error propagation rather than forcing all business failures into exceptions. Notificador and INotificador carry validation/domain failures back through controllers, while FluentValidation-style model validators protect mutations.
Persistence and database
DevIO.Data implements repository contracts with Entity Framework Core. MeuDbContext maps domain entities through dedicated mappings, and repositories provide CRUD/query access for services:
• back-end/src/DevIO.Data/Context/MeuDbContext.cs
• back-end/src/DevIO.Data/Repository/FornecedorRepository.cs
• back-end/src/DevIO.Data/Mappings/ProdutoMapping.cs
Two EF migration sets exist: business data migrations in back-end/src/DevIO.Data/Migrations/ and Identity migrations in back-end/src/DevIO.Api/Migrations/. Database creation SQL is also present at back-end/sql/criarbanco.sql; connection/environment settings reside in API appsettings*.json.
Frontend application and flows
Angular boots at front-end/src/main.ts, with root module/routing at:
• front-end/src/app/app.module.ts
• front-end/src/app/app-routing.module.ts
The feature structure currently emphasizes account flow: registration and login components call ContaService; ContaGuard gates protected routes; local storage retains client-side session/token state:
• front-end/src/app/conta/services/conta.service.ts
• front-end/src/app/conta/services/conta.guard.ts
• front-end/src/app/utils/localstorage.ts
BaseService is the shared HTTP integration seam, expected to centralize API URL, headers/token handling, and failures. Navigation components render public/authenticated menus and route outlet content.
Runtime and deployment
The backend ships a Docker build definition at back-end/Dockerfile and solution file back-end/MinhaAPICompleta.sln. Material runtimes are .NET Core 3.1 / ASP.NET Core, EF Core with a relational database, ASP.NET Identity, and Angular with Node-based build tooling. The principal external boundary is browser-to-API HTTP; the API then accesses Identity and application data stores through separate EF contexts.
Main entry points: Startup.cs API host & pipeline · FornecedorService.cs Supplier & product services · app.module.ts App module & routes · AuthController.cs V1 REST controllers
Components 17
Angular SPA
- Angular bootstrap
front-end/src/main.ts - App module & routes · Composes routed application features.
front-end/src/app/app.module.ts - Account flow · Registration and login UI.
front-end/src/app/conta/services/conta.service.ts - Account guard · Gates protected routes.
front-end/src/app/conta/services/conta.guard.ts - Local session store · Retains client token/session state.
front-end/src/app/utils/localstorage.ts - Base HTTP service · Centralizes API URL, headers, tokens, and failures.
ASP.NET Core API
- API host & pipeline · Configures DI, middleware, identity, Swagger, and HTTP pipeline.
back-end/src/DevIO.Api/Startup.cs - V1 REST controllers · Auth, supplier, and product endpoints translate view models and delegate.
back-end/src/DevIO.Api/V1/Controllers/AuthController.cs - Authorization & exceptions · Provides user access, authorization, and global error handling.
back-end/src/DevIO.Api/Extensions/ExceptionMiddleware.cs - Identity EF context · API-specific identity storage.
back-end/src/DevIO.Api/Data/ApplicationDbContext.cs
Business & Data
- Supplier & product services · Applies mutation and business workflows.
back-end/src/DevIO.Business/Services/FornecedorService.cs - Supplier & product domain · Persistence-independent entities and business constraints.
back-end/src/DevIO.Business/Models/Fornecedor.cs - Domain notifications · Carries validation and domain failures to the API.
- EF repositories · Implements domain repository contracts for CRUD and queries.
back-end/src/DevIO.Data/Repository/FornecedorRepository.cs - Business EF context · Maps application domain entities.
back-end/src/DevIO.Data/Context/MeuDbContext.cs
Other components
- Relational database · Stores application and identity data through separate contexts.
back-end/sql/criarbanco.sql - Docker backend build
back-end/Dockerfile
Connections 19
- Angular bootstrap → App module & routes: boots
- App module & routes → Account flow: routes to
- App module & routes → Account guard: protects routes with
- Account guard → Local session store: checks
- Account flow → Base HTTP service: uses
- Base HTTP service → Local session store: reads/writes token
- Base HTTP service → API host & pipeline: HTTPS API calls
- API host & pipeline → Authorization & exceptions: applies
- API host & pipeline → V1 REST controllers: routes requests
- V1 REST controllers → Supplier & product services: delegates to
- Supplier & product services → Supplier & product domain: enforces rules on
- Supplier & product services → Domain notifications: reports failures through
- V1 REST controllers → Domain notifications: returns failures from
- Supplier & product services → EF repositories: uses contracts implemented by
- EF repositories → Business EF context: persists via
- Business EF context → Relational database: application data
- API host & pipeline → Identity EF context: configures identity
- Identity EF context → Relational database: identity data
- Docker backend build → API host & pipeline: packages