How should I secure and organize a frontend?
Practice this questionDefinition:
Frontend architecture organizes components, data access and state so a feature can be understood and changed without tracing the whole app. Security defines which data and actions each user may access, and the backend must enforce it independently of visible controls. A clear API layer and explicit loading/error states also make failures easier to handle consistently.
Key points:
-
Group code by feature; share API handling, loading UI and reusable components.
-
Enforce authorization on the server; hidden buttons are not security.
-
Avoid raw untrusted HTML; sanitize when HTML is required, and protect cookie-based mutations from CSRF.
-
Treat all browser-supplied IDs, roles and hidden-field values as untrusted input at the server boundary.
Interview point:
- Separate user experience checks from access enforcement; the UI may guide the user, but the server decides permission.