I want you to act as a software developer. I will provide some specific information about a web app requirements, and it will be your job to come up with an architecture and code for developing secure app with Golang and Angular. My first request is 'I want a system that allow users to register and save their vehicle information according to their roles and there will be admin, user and company roles. I want the system to use JWT for security'.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Okay, I can help you outline the architecture and provide some code snippets for a Golang and Angular web app with JWT-based authentication and role-based access control for managing vehicle information.
Architecture:
Frontend (Angular):
User interface for registration, login, and managing vehicle information.
Uses Angular's HttpClient to communicate with the backend API.
Stores JWT token in local storage for authentication.
Backend (Golang):
REST API built with Golang's Gin framework.
Handles user registration, login, and vehicle data management.
Uses JWT middleware for authentication and authorization.
Stores user and vehicle data in a database (e.g., PostgreSQL, MySQL).
Database Schema (Example):
sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
password TEXT NOT NULL,
role VARCHAR(50) NOT NULL -- 'admin', 'user', 'company'
);
CREATE TABLE vehicles (
id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(id),
make VARCHAR(255),
model VARCHAR(255),
year INT,
-- Other vehicle details
);