15 KiB
Story 0: Foundation - Walking Skeleton
Story Overview
As a development team
I want to establish the technical foundation and development patterns
So that all future features can be built consistently and efficiently
Story Type: Technical Foundation
Priority: Highest
Estimated Effort: 2-3 weeks
Dependencies: None (first story)
Business Value
This story establishes:
- Complete tech stack setup (Spring Boot + Angular + PostgreSQL)
- Authentication and authorization framework
- One complete CRUD example (Environment entity) as a template
- CI/CD pipeline foundation
- Testing infrastructure
- Development patterns for all future stories
Scope
In Scope
✅ Spring Boot project setup with security
✅ PostgreSQL database with Liquibase
✅ JWT authentication implementation
✅ Angular project setup
✅ Authentication UI (login page)
✅ Environment entity (complete CRUD) as pattern example
✅ API documentation (Swagger)
✅ Docker setup for local development
✅ Basic CI/CD configuration
Out of Scope
❌ All business entities except Environment
❌ Complex authorization rules (just basic role check)
❌ OAuth integration (local auth only)
❌ Advanced UI features
Technical Implementation
Backend Tasks
1. Project Setup
- Create Spring Boot project via Spring Initializr
- Spring Boot 3.2.x
- Dependencies: Web, Security, JPA, PostgreSQL, Liquibase, Validation
- Configure
pom.xmlwith additional dependencies- JJWT for JWT handling
- Lombok
- SpringDoc OpenAPI
- Testcontainers
- Setup project structure (packages: config, domain, repository, service, dto, controller, security, exception)
2. Database Setup
- Create Liquibase changelog master file
- Migration 001: Create
usertable with columns:id(UUID, PK)username(VARCHAR, unique, not null)password(VARCHAR, hashed, not null)email(VARCHAR, unique, not null)role(VARCHAR, not null) - Simple role: ADMIN, USERcreated_at,updated_at(TIMESTAMP)
- Migration 002: Create
environmenttable with columns:id(UUID, PK)name(VARCHAR, unique, not null)description(TEXT, nullable)is_production(BOOLEAN, default false)criticality_level(INTEGER, nullable)created_at,updated_at(TIMESTAMP)
- Add indexes on
is_productionandname
3. JPA Entities
- Create
BaseEntityabstract class with:idfield with UUID generatorcreatedAt,updatedAtwith JPA auditing
- Create
Userentity extendingBaseEntity - Create
Environmententity extendingBaseEntity - Configure JPA auditing in configuration class
4. Security Implementation
- Create
JwtTokenProviderclassgenerateToken(Authentication): Create JWT tokengetUsernameFromToken(String): Extract usernamevalidateToken(String): Validate token
- Create
JwtAuthenticationFilterextendsOncePerRequestFilter- Extract JWT from Authorization header
- Validate token
- Set authentication in SecurityContext
- Create
UserDetailsServiceImplimplementsUserDetailsService- Load user from database
- Map to Spring Security UserDetails
- Create
SecurityConfig- Configure HTTP security
- Disable CSRF (stateless API)
- Configure CORS
- Set session management to STATELESS
- Define public endpoints:
/api/auth/** - Require authentication for all other endpoints
- Add JWT filter before UsernamePasswordAuthenticationFilter
- Create
AuthControllerwith endpoints:POST /api/auth/register: Register new userPOST /api/auth/login: Authenticate and return JWTGET /api/auth/me: Get current user info
5. Environment CRUD (Pattern Example)
- Create
EnvironmentRepositoryextendsJpaRepository<Environment, UUID> - Create DTOs:
CreateEnvironmentRequest(name, description, isProduction, criticalityLevel)UpdateEnvironmentRequest(same as create, all optional)EnvironmentResponse(all fields + createdAt, updatedAt)
- Create
EnvironmentServicewith methods:create(CreateEnvironmentRequest): Create new environmentupdate(UUID, UpdateEnvironmentRequest): Update environmentfindById(UUID): Get by IDfindAll(Pageable): List all with paginationdelete(UUID): Delete environment
- Create
EnvironmentControllerwith endpoints:GET /api/environments: List all (with pagination, sorting)GET /api/environments/{id}: Get by IDPOST /api/environments: Create newPUT /api/environments/{id}: UpdateDELETE /api/environments/{id}: Delete
- Add validation annotations on DTOs
- Add Swagger annotations on controller methods
6. Exception Handling
- Create custom exceptions:
ResourceNotFoundExceptionBadRequestExceptionUnauthorizedException
- Create
GlobalExceptionHandlerwith@ControllerAdvice- Handle all custom exceptions
- Return standardized error response (status, message, timestamp)
7. Configuration
- Configure
application.ymlfor database, JPA, Liquibase - Configure
application-dev.ymlfor development - Configure
application-prod.ymlfor production - Create
OpenApiConfigfor Swagger documentation - Create
CorsConfigfor frontend integration
8. Testing
- Unit tests for
EnvironmentService(with Mockito) - Integration tests for
EnvironmentController(with Testcontainers) - Security tests for JWT authentication flow
- Test coverage > 80%
Frontend Tasks
1. Project Setup
- Create Angular 18 project:
ng new ldpv2-frontend - Add Angular Material or PrimeNG
- Configure TypeScript strict mode
- Setup proxy configuration for API calls
- Configure environments (dev, prod)
2. Project Structure
- Create folder structure:
core/(auth, guards, interceptors, services)shared/(models, components, pipes)features/(feature modules)
- Setup routing module
3. Authentication Module
- Create models:
Userinterface (id, username, email, role)LoginRequestinterface (username, password)LoginResponseinterface (token, user)
- Create
AuthService:login(credentials): Call login API, store JWT in localStoragelogout(): Clear JWT from localStorageisAuthenticated(): Check if JWT exists and is validgetCurrentUser(): Get current user from token
- Create
JwtInterceptor(implementsHttpInterceptor):- Add Authorization header with JWT to all requests
- Create
ErrorInterceptor(implementsHttpInterceptor):- Handle 401 (redirect to login)
- Handle other errors (show notification)
- Create
AuthGuard(implementsCanActivate):- Protect routes requiring authentication
- Redirect to login if not authenticated
- Create
LoginComponent:- Reactive form with username and password
- Call AuthService.login()
- Redirect to dashboard on success
- Show error message on failure
4. Environment Management (Pattern Example)
- Create
Environmentmodel (TypeScript interface) - Create
EnvironmentService:getEnvironments(page, size, sort): GET /api/environmentsgetEnvironment(id): GET /api/environments/{id}createEnvironment(data): POST /api/environmentsupdateEnvironment(id, data): PUT /api/environments/{id}deleteEnvironment(id): DELETE /api/environments/{id}
- Create
EnvironmentListComponent:- Display environments in table/list
- Pagination controls
- Sort by name, criticality, etc.
- Actions: View, Edit, Delete
- Button: Create New
- Create
EnvironmentDetailComponent:- Display full environment details
- Edit and Delete buttons
- Create
EnvironmentFormComponent:- Reactive form for create/edit
- Validation (required fields, unique name)
- Submit to API
- Success/error notifications
- Add routing:
/environments: EnvironmentListComponent/environments/new: EnvironmentFormComponent (create mode)/environments/:id: EnvironmentDetailComponent/environments/:id/edit: EnvironmentFormComponent (edit mode)
5. Shared Components
- Create
HeaderComponent(navigation, user menu, logout) - Create
LoadingSpinnerComponent - Create
ConfirmDialogComponent(for delete confirmations) - Create
NotificationService(toast notifications)
6. Styling
- Setup global styles
- Create responsive layout
- Style login page
- Style environment management pages
7. Testing
- Unit tests for
AuthService - Unit tests for
EnvironmentService - Component tests for
LoginComponent - Component tests for
EnvironmentListComponent - E2E test: Login flow
- E2E test: Create environment flow
- Test coverage > 70%
DevOps Tasks
1. Docker Setup
- Create
Dockerfilefor backend - Create
Dockerfilefor frontend - Create
docker-compose.ymlwith services:- PostgreSQL
- Backend
- Frontend (optional for dev)
- Document how to run with Docker
2. CI/CD Pipeline
- Create
.gitlab-ci.ymlorJenkinsfileor GitHub Actions workflow - Pipeline stages:
- Build (backend and frontend)
- Test (run all tests)
- Code quality check (SonarQube optional)
- Build Docker images
- Push to registry (optional)
- Configure environment variables
3. Documentation
- README.md with:
- Project description
- Prerequisites
- How to run locally
- How to run with Docker
- How to run tests
- API documentation accessible via Swagger UI
- Contribution guidelines (optional)
Acceptance Criteria
Authentication
- User can register a new account
- User can login with username and password
- Upon successful login, JWT token is returned
- JWT token is stored in browser (localStorage)
- JWT token is automatically included in API requests
- User is redirected to login page when token is invalid/expired
- User can logout (token is cleared)
Environment CRUD
- User can view a list of all environments
- List is paginated (20 items per page)
- User can sort environments by name or criticality
- User can view details of a specific environment
- User can create a new environment with:
- Name (required, unique)
- Description (optional)
- Production flag (default: false)
- Criticality level (optional, 1-5)
- Form validation works correctly (required fields, unique name)
- User can edit an existing environment
- User can delete an environment (with confirmation dialog)
- Success and error notifications are displayed appropriately
API Documentation
- Swagger UI is accessible at
/swagger-ui/index.html - All endpoints are documented with request/response schemas
- Authentication endpoints are documented
- Environment endpoints are documented
Testing
- Backend unit tests pass (>80% coverage)
- Backend integration tests pass
- Frontend unit tests pass (>70% coverage)
- E2E tests pass for critical flows
DevOps
- Application runs successfully with
docker-compose up - CI/CD pipeline builds and tests successfully
- README documentation is complete and accurate
Testing Scenarios
Scenario 1: User Registration and Login
- Navigate to registration page
- Fill in username, email, password
- Submit registration form
- Verify success message
- Navigate to login page
- Enter username and password
- Submit login form
- Verify redirect to dashboard
- Verify JWT token in localStorage
- Verify Authorization header in subsequent requests
Scenario 2: Create Environment
- Login as authenticated user
- Navigate to environments list
- Click "Create New Environment"
- Fill in form:
- Name: "PROD-EU"
- Description: "Production environment for Europe"
- Production: true
- Criticality: 5
- Submit form
- Verify success notification
- Verify redirect to environment list
- Verify new environment appears in list
Scenario 3: Edit Environment
- Navigate to environment list
- Click "Edit" on an environment
- Modify description
- Submit form
- Verify success notification
- Verify changes are reflected
Scenario 4: Delete Environment
- Navigate to environment list
- Click "Delete" on an environment
- Confirm deletion in dialog
- Verify success notification
- Verify environment is removed from list
Scenario 5: Unauthorized Access
- Logout or clear JWT token
- Attempt to access protected route (e.g.,
/environments) - Verify redirect to login page
- Login again
- Verify redirect to originally requested page
Definition of Done
- All backend tasks completed
- All frontend tasks completed
- All DevOps tasks completed
- All acceptance criteria met
- All tests passing (unit, integration, E2E)
- Code reviewed and approved
- API documented in Swagger
- User documentation updated
- Demo conducted successfully
- Code merged to main branch
Technical Debt & Future Improvements
Known Limitations
- Simple role-based authorization (ADMIN, USER) - will need environment-specific roles in future
- Local authentication only - OAuth integration planned for later
- Basic error handling - can be enhanced with more specific error codes
- No password reset functionality - to be added later
Future Enhancements
- Implement refresh token mechanism
- Add password strength validation
- Implement account activation via email
- Add "Remember me" functionality
- Implement rate limiting on auth endpoints
- Add audit logging for security events
Dependencies & Blockers
Dependencies
None - this is the first story
Potential Blockers
- PostgreSQL setup issues → Use Docker Compose
- CORS configuration issues → Properly configure allowed origins
- JWT secret management → Use environment variables
- Network connectivity between services → Use Docker network
Resources & References
Spring Boot Documentation
Angular Documentation
JWT
Story Status: Ready for Development
Story Created: February 2026
Estimated Completion: 2-3 weeks from start