How leeyreserrano/keyly works
1. Repository shape
- This repo is a full stack password-manager system with three main runtime areas: a Spring Boot backend, a Vite/React web frontend, and a second React-based client under keyly that looks like an extension-style or lightweight companion UI because it includes popup.tsx.
- Supporting pieces include MySQL initialization scripts, Nginx TLS config, and Docker/Docker Compose deployment artifacts.
2. Backend as the system core
- backend/api is the central application. It exposes REST endpoints through controllers such as AuthController, ItemController, CarpetaController, BagulController, CompartitController, UsuariController, and several admin/config controllers.
- The backend is organized in a classic layered Spring architecture: controller → service → repository → MySQL.
3. Domain boundaries and main business concepts
- The domain is built around credential storage and organization: Bagul (vault/container), Carpeta (folder), Item (credential entry), and Compartit (shared access).
- Supporting organizational/security entities include Usuari, Rol, Config, Domini, Sucursal, and Departament.
- Enums such as Permisos, RolIntern, and TipusEntitat suggest permission-driven access control and typed domain relationships.
4. Backend data flow
- Client requests hit controllers, which delegate to services for business rules.
- Services persist and query through repository interfaces such as ItemRepo, UsuariRepo, BagulRepo, and others, which connect to MySQL.
- The backend returns dedicated response DTOs rather than raw entities, indicating a clean API boundary.
5. DTOs and mapping layer
- The request, response, and response/basics packages show that the API is designed around explicit data contracts.
- Mapper classes (ItemMapper, UsuariMapper, etc.) transform between persistence models and API payloads, keeping entity structure separated from external API shape.
6. Authentication and security
- Authentication is handled by AuthController and AuthService, with JWT support in security/JwtUtils, JwtAuthenticationFilter, and SecurityConfig.
- This implies the frontends authenticate once, then send JWT-bearing requests for protected endpoints.
- JwtAuthenticationEntryPoint indicates a centralized unauthorized-response path.
7. Error handling
- The backend has custom exceptions for domain failures such as invalid domain, missing entity, image problems, password-generation issues, and user/corruption-related errors.
- GestorGlobalExcepcions and ErrorResponse form the global exception boundary, translating backend failures into consistent API errors.
8. Frontend web app
- frontend-react is a Vite + React + TypeScript app with pages for login, home, item lists, add/edit item flows, and folder creation.
- Its structure is component-driven (Sidebar, LoginCard, CredentialCard, modals) with API modules in src/api for login, folders, and items.
- The theme/customization folders suggest a styled UI layer, likely built on a component library with centralized theming.
9. Second client in keyly
- The keyly app is another React/TypeScript frontend with home, login, popup, and API service modules.
- Because it contains popup.tsx, it likely serves as a browser-extension or embedded client rather than the main web SPA.
- It shares the same conceptual domain as the main frontend: auth plus folder/item operations.
10. Database bootstrap and deployment
- db/mysql-init contains scripts for user setup, table creation, triggers, and seed inserts, so MySQL is initialized from code rather than manually.
- nginx/conf.d includes a default site config plus certificate/key files, indicating HTTPS termination and likely reverse-proxy deployment.
- docker-compose.yml at the root suggests the intended runtime is containerized, with MySQL, backend, and frontend/proxy wired together.
11. Testing and maintainability
- Backend service tests exist for the main business services, which means the core domain logic is unit-tested separately from controllers and persistence.
- The architecture is therefore centered on business logic in services, with thin controllers and explicit DTO boundaries, making it diagram-friendly and easier to evolve.
Main entry points: controller Controllers · docker-compose.yml Compose stack · service Services · main.tsx Web app
Components 19
Spring backend
Core API, domain services, persistence, and security.
- API app · Backend application bootstrap.
backend/api/src/main/java/com/keyly/KeylyApplication.java - Controllers · HTTP endpoints for auth, items, folders, vaults, sharing, users, and admin data.
backend/api/src/main/java/com/keyly/controller - Services · Domain rules and use-case orchestration.
backend/api/src/main/java/com/keyly/service - Repositories · Spring Data repositories for domain persistence.
backend/api/src/main/java/com/keyly/repo - Domain model · Vault, folder, item, user, role, config, request, and response contracts.
backend/api/src/main/java/com/keyly/model - Mappers · Transforms between entities and API payloads.
backend/api/src/main/java/com/keyly/mapper - JWT security · JWT issuance, request filtering, unauthorized handling, and security config.
backend/api/src/main/java/com/keyly/security - Errors · Global exception handling and API error responses.
backend/api/src/main/java/com/keyly/exception
Web clients
Main React SPA and companion React client.
- Web app · Main browser UI for login and credential management.
frontend-react/src/main.tsx - Web APIs · Frontend API wrappers for login, folders, and items.
frontend-react/src/api - Pages · Login, home, items, item editing, and folder creation screens.
frontend-react/src/pages - UI components · Shared cards, sidebar, modals, and content assembly.
frontend-react/src/components - Theme · Theme primitives and UI customizations.
frontend-react/src/theme - Keyly client · Secondary React client, likely extension-style because it includes a popup entrypoint.
keyly/src/popup.tsx - Keyly services · Auth, folder, and item API wrappers for the companion client.
keyly/src/api - Keyly pages · Home and login views for the companion client.
keyly/src/pages
Data and deployment
Database bootstrap and container/web server deployment assets.
- MySQL init · User, schema, trigger, and seed initialization scripts.
db/mysql-init - Nginx config · HTTPS and server configuration for deployed services.
nginx/conf.d - Compose stack · Container orchestration for backend, frontend, database, and proxy.
docker-compose.yml
Connections 26
- API app → Controllers: starts · Application boots the REST API layer.
- Controllers → Services: delegates · Controllers forward requests to business services.
- Services → Repositories: persists via · Services query and store through repositories.
- Services → Mappers: maps · Services or adjacent layers convert between entities and DTOs.
- Mappers → Domain model: transforms · Mappers bridge domain entities and API contracts.
- Repositories → Domain model: stores · Repositories operate on entities.
- Controllers → Domain model: accepts/returns · Request and response DTOs define the API boundary.
- Controllers → JWT security: protected by · REST endpoints are guarded by JWT security.
- JWT security → Controllers: filters · Security intercepts requests before controllers.
- Errors → Controllers: handles failures · Global exception handling shapes controller errors.
- Errors → Services: handles failures · Service exceptions are converted into API errors.
- Web app → Web APIs: calls · The web app uses API service modules.
- Web app → Pages: renders · App is composed from page-level views.
- Pages → UI components: uses · Screens assemble shared UI components.
- UI components → Theme: styled by · UI components are themed centrally.
- Web APIs → Controllers: HTTP to · Browser API calls hit backend controllers.
- Keyly client → Keyly services: calls · Companion client uses its API services.
- Keyly client → Keyly pages: renders · Popup and page views compose the client UI.
- Keyly services → Controllers: HTTP to · Companion client talks to the same backend API.
- Compose stack → API app: runs · Compose deploys the backend service.
- Compose stack → Web app: runs · Compose deploys the main web client.
- Compose stack → Nginx config: proxies through · Deployment routes traffic via Nginx.
- Compose stack → MySQL init: initializes · Compose wires in the database bootstrap scripts.
- MySQL init → Repositories: serves data for · Initialized MySQL schema supports repository persistence.
- Nginx config → Web app: serves · Nginx fronts the web client in deployment.
- Nginx config → API app: routes · Nginx can forward API traffic to the backend.