How samiteon-india/expert-meme-frontend works
Purpose and Entry Points
Angular 17 single-page frontend for listing and creating users through a Java backend API. Browser bootstrap begins at src/main.ts, initializes application providers in src/app/app.config.ts, and renders the root shell in src/app/app.component.ts.
Application Shell and Routing
The root component provides the application layout and navigation; routed content is displayed through its template. Route definitions in src/app/app.routes.ts select the user-management feature. Client-side routing must remain compatible with nginx’s SPA fallback.
• src/app/app.component.ts
• src/app/app.component.html
• src/app/app.routes.ts
User Management Feature
UsersComponent is the primary feature UI: it presents the user table and add-user form, orchestrates loading/submission, and delegates backend access to UserService. Its templates/styles define the concrete management interface.
• src/app/users/users.component.ts
• src/app/users/users.component.html
• src/app/users/user.service.ts
API Boundary
UserService owns HTTP calls to the Java backend, including GET /api/users and POST /api/users. Angular’s HTTP client is registered application-wide, separating UI components from transport concerns.
• src/app/users/user.service.ts
• src/app/app.config.ts
Environment-Specific API Addressing
Development targets the backend directly at localhost, while production intentionally uses relative /api/... URLs. This makes the frontend portable behind the production reverse proxy rather than embedding a deployment-specific backend hostname in the Angular bundle.
• src/environments/environment.ts
• src/environments/environment.prod.ts
• src/app/users/user.service.ts
Container Build and Runtime Proxy
The Docker image is multi-stage: Node 18 builds the production Angular artifacts, then nginx serves them on port 80. At container startup, entrypoint.sh injects Railway’s API_URL into the nginx configuration. nginx proxies /api/* to the private Java backend and falls back to index.html for SPA routes.
• Dockerfile
• entrypoint.sh
• nginx.conf
Infrastructure and External Dependencies
Local development requires Node.js 18+, Angular CLI, and a Java API on localhost:8080. Railway is the production platform: its Docker deployment runs nginx publicly while API_URL identifies the Java backend over Railway’s private internal network. The browser never needs the backend’s internal hostname.
Main entry points: nginx.conf nginx SPA server · user.service.ts User API service · app.component.ts Root shell · main.ts Angular bootstrap
Components 14
Angular SPA
- Angular bootstrap
src/main.ts - Application providers · Registers application-wide providers including HTTP.
src/app/app.config.ts - Root shell · Provides layout, navigation, and routed-content outlet.
src/app/app.component.ts - App routes
src/app/app.routes.ts - User management UI · Lists users and submits the add-user form.
src/app/users/users.component.ts - User API service · Issues GET and POST requests under /api/users.
src/app/users/user.service.ts - Development API address · Targets the local Java API.
src/environments/environment.ts - Production API address · Uses relative /api URLs for reverse-proxy deployment.
src/environments/environment.prod.ts
Container Runtime
- Multi-stage image build · Node 18 builds Angular artifacts for nginx.
Dockerfile - Runtime API injection · Injects Railway API_URL into nginx configuration.
entrypoint.sh - nginx SPA server · Serves Angular assets, proxies /api, and falls back to index.html.
nginx.conf
Railway Production
- Railway deployment · Runs the public frontend container and supplies API_URL.
- Java backend API · Private backend serving the users API.
Other components
- Browser
Connections 15
- Browser → nginx SPA server: loads SPA / calls /api
- Angular bootstrap → Application providers: initializes providers
- Angular bootstrap → Root shell: bootstraps
- Root shell → App routes: renders routed content
- App routes → User management UI: selects feature
- User management UI → User API service: loads and creates users
- Application providers → User API service: provides HTTP client
- Development API address → User API service: localhost API base
- Production API address → User API service: relative /api base
- Multi-stage image build → nginx SPA server: packages built assets
- Runtime API injection → nginx SPA server: configures proxy target
- Railway deployment → Runtime API injection: supplies API_URL
- Railway deployment → nginx SPA server: runs public container
- nginx SPA server → Root shell: serves assets / SPA fallback
- nginx SPA server → Java backend API: proxies /api/*