Documentation Index
Fetch the complete documentation index at: https://mintlify.com/stevenrq/sgivu/llms.txt
Use this file to discover all available pages before exploring further.
Frontend Setup
This guide covers setting up the SGIVU frontend for local development, building for production, and troubleshooting common issues.Prerequisites
Before starting, ensure you have the following installed:Required Software
- Node.js - Compatible with Angular 21 (Node.js 18.19+ or 20.11+ recommended)
- npm 8+ - Package manager (comes with Node.js)
- Git - Version control
Backend Services
The frontend requires these backend services to be running:sgivu-config- Configuration serversgivu-discovery- Service discovery (Eureka)sgivu-gateway- API gateway and BFFsgivu-auth- Authentication server
You can start all backend services using Docker Compose:
Installation
1. Clone the Repository
2. Install Dependencies
package.json including:
- Angular framework and CLI
- Bootstrap and UI libraries
- Chart.js for visualizations
- Development tools (ESLint, Prettier, Karma)
3. Configure Environment
The default development configuration is insrc/environments/environment.development.ts:
4. Update Hosts File (Optional)
For better Docker integration, add to your/etc/hosts (Linux/Mac) or C:\Windows\System32\drivers\etc\hosts (Windows):
Development Server
Start Development Server
- URL: http://localhost:4200
- Hot Reload: Enabled by default
- Source Maps: Enabled for debugging
Development Features
- Live Reload - Automatic browser refresh on file changes
- Source Maps - Debug TypeScript in browser DevTools
- Error Overlay - Build errors displayed in browser
- Hot Module Replacement - Fast incremental builds
Building for Production
Standard Build
dist/sgivu-frontend/ directory.
Optimized Production Build
- Code minification and uglification
- Tree shaking (removes unused code)
- Ahead-of-Time (AOT) compilation
- Bundle optimization and splitting
- CSS optimization
- Source map generation (optional)
Watch Mode (Development)
Testing
Unit Tests
Run unit tests with Karma and Jasmine:- Framework: Jasmine
- Runner: Karma
- Browser: Chrome (via Puppeteer)
- Coverage: Enabled with
karma-coverage
Linting
Check code quality with ESLint:Code Formatting
Format code with Prettier:Consider adding Prettier as an npm script in
package.json for easier access.Development Workflow
Recommended Workflow
-
Start Backend Services
-
Start Frontend Dev Server
-
Open Browser
- Navigate to http://localhost:4200
- Login credentials depend on your
sgivu-authconfiguration
-
Make Changes
- Edit files in
src/app/ - Browser automatically reloads
- Check console for errors
- Edit files in
-
Run Tests
-
Lint Before Committing
IDE Recommendations
Visual Studio Code with extensions:- Angular Language Service
- ESLint
- Prettier - Code formatter
- Angular Snippets
- Auto Rename Tag
- Path Intellisense
- Built-in Angular support
- Built-in TypeScript support
- ESLint integration
- Prettier integration
Troubleshooting
401/403 Errors on API Calls
Problem: XHR requests return 401 Unauthorized or 403 Forbidden. Solutions:- Verify
apiUrlinenvironment.development.tspoints tosgivu-gateway - Check that
sgivu-gatewayis running:docker ps | grep sgivu-gateway - Verify session is established: Open DevTools Network tab and check
/auth/sessionresponse - Clear browser cookies and localStorage
- Try logging out and logging back in
Issuer/Redirect Mismatch
Problem: OAuth2 redirect fails with issuer mismatch error. Solutions:- Verify
issuermatchesISSUER_URLinsgivu-authconfiguration - Check
application.ymlinsgivu-authfor correct issuer URL - Ensure Nginx configuration matches issuer URL
- Verify no trailing slashes in issuer URLs
Routes Not Found After Deployment
Problem: Direct navigation to routes returns 404 on static hosting. Solutions:- Configure server to serve
index.htmlfor all routes - Verify
base hrefindist/sgivu-frontend/index.html - For Nginx, add rewrite rule:
- For S3, configure error document to
index.html
Module Not Found Errors
Problem: Import errors or module not found during build. Solutions:- Delete
node_modulesand reinstall: - Clear Angular cache:
- Verify TypeScript paths in
tsconfig.json
Port Already in Use
Problem: Port 4200 is already occupied. Solutions:- Use different port:
- Kill process using port 4200:
CORS Errors
Problem: CORS policy blocks API requests. Solutions:- Verify
sgivu-gatewayCORS configuration allowshttp://localhost:4200 - Check gateway
application.ymlfor CORS allowed origins - Ensure cookies are included in requests (handled by interceptor)
- Verify
withCredentials: truein HTTP requests
Cannot Resolve Hostname
Problem: Browser cannot resolvesgivu-auth or other service hostnames.
Solutions:
- Add hostname to
/etc/hosts(see Configuration section) - Change issuer to use
localhostin development - Verify Docker network configuration if using Docker
Environment Configuration
Development Environment
Editsrc/environments/environment.development.ts:
Production Environment
Editsrc/environments/environment.ts:
Next Steps
Architecture
Learn about the frontend architecture and patterns
Features
Explore feature modules and components