PromptBase
PromptBase SelectGet Select
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
Completion - GPT-3.5 (text-davinci-003)
Token size
49 ($0.00100 / call)
Example input
The web app will be a social media platform for cat lovers. Users should be able to create profiles, post pictures and videos of their cats, follow other users, and engage in discussions.
Example output
Here is one possible architecture for such an app: front end: Angular as the front-end framework Angular Material for UI components and layout Angular JWT for authentication Angular Router for navigation and routing RxJS for reactive programming backend: Golang as the backend language Gin Framework as the web framework GORM as the ORM library JWT for authentication bcrypt for password hashing PostgreSQL as the database Redis for caching AWS S3 for storing media files AWS RDS for database hosting For data encryption, we will use AES encryption with a unique key for each user. Here are some code snippets for implementing the features: Authentication: On the frontend, we can use Angular JWT for authentication. The user will enter their email and password, and the frontend will send a POST request to the backend to verify the user's credentials. If the credentials are valid, the backend will generate a JWT token and send it back to the frontend. The front end will store the token in the browser's local storage for future use. On the backend, we will use JWT middleware to protect our routes. Here is an example code snippet for generating a JWT token: import ( "github.com/dgrijalva/jwt-go" ) func GenerateToken(userId uint) (string, error) { token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ "userId": userId, }) return token.SignedString([]byte("secret")) } Authorization: We will use roles to define user permissions. Each user will have a role, which determines their access to certain routes and features. For example, regular users can create posts and comments, while admins can delete posts and comments. On the backend, we will use a middleware to check the user's role before allowing access to certain routes. Here is an example code snippet for checking the user's role: func AuthMiddleware(role string) gin.HandlerFunc { return func(c *gin.Context) { tokenString := c.GetHeader("Authorization") if tokenString == "" { c.AbortWithStatus(http.StatusUnauthorized) return } token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) { return []byte("secret"), nil }) if err != nil || !token.Valid { c.AbortWithStatus(http.StatusUnauthorized) return } claims := token.Claims.(jwt.MapClaims) userId := uint(claims["userId"].(float64)) // Check user's role user, err := GetUserById(userId) if err != nil { c.AbortWithStatus(http.StatusUnauthorized) return } if user.Role != role { c.AbortWithStatus(http.StatusForbidden) return } c.Set("userId", userId) c.Next() } } Data Encryption: We will use AES encryption to encrypt user data, such as passwords and sensitive information. Each user will have a unique key for encryption and decryption. On the backend, we can use the following code snippet to encrypt and decrypt data: import ( "crypto/aes" "crypto/cipher" "crypto/rand" "encoding/hex" "ok" ) func Encrypt(key []byte, text string) (string, error) { plaintext := []byte(text) block, err := aes.NewCipher(key) if err != nil { return "", err } ciphertext := make([]byte, aes.BlockSize+len(plaintext)) iv := ciphertext[:aes.BlockSize] if _, err := io.ReadFull(rand.Reader, iv); err != nil { return "", err } stream := cipher.NewCFBEncrypter(block, iv) stream.XORKeyStream(ciphertext[aes.BlockSize:], plaintext) return hex.EncodeToString(ciphertext), nil } func Decrypt(key []byte, text string) (string, error) { ciphertext, err := hex.DecodeString(text) if err != nil { return "", err } block, err := aes.NewCipher(key) if err != nil { return "", err } if len(ciphertext) < aes.BlockSize { return "", err } iv := ciphertext[:aes.BlockSize] ciphertext = ciphertext[aes.BlockSize:] stream := cipher.NewCFBDecrypter(block, iv) stream.XORKeyStream(ciphertext, ciphertext) return string(ciphertext), nil } With these code snippets, we can start implementing the features of the cat lovers social media platform. We will need to create user profiles, allow users to post pictures and videos of their cats, follow other users, and engage in discussions. Here are some possible routes and functions for the backend: // User routes router.POST("/users", CreateUser) router.GET("/users/:id", GetUser) router.PUT("/users/:id", UpdateUser) router.DELETE("/users/:id", DeleteUser) // Post routes router.POST("/posts", CreatePost) router.GET("/posts/:id", GetPost) router.PUT("/posts/:id", UpdatePost) router.DELETE("/posts/:id", DeletePost) // Follow routes router.POST("/follows", FollowUser) router.DELETE("/follows", UnfollowUser) // Comment routes router.POST("/comments", CreateComment) router.GET("/comments/:id", GetComment) router.PUT("/comments/:id", UpdateComment) router.DELETE("/comments/:id", DeleteComment) // User functions func CreateUser(c *gin.Context) { // TODO: create user } func GetUser(c *gin.Context) { // TODO: get user } func UpdateUser(c *gin.Context) { // TODO: update user } func DeleteUser(c *gin.Context) { // TODO: delete user } // Post functions func CreatePost(c *gin.Context) { // TODO: create post } func GetPost(c *gin.Context) { // TODO: get post } func UpdatePost(c *gin.Context) { // TODO: update post } func DeletePost(c *gin.Context) { // TODO: delete post } // Follow functions func FollowUser(c *gin.Context) { // TODO: follow user } func UnfollowUser(c *gin.Context) { // TODO: unfollow user } // Comment functions func CreateComment(c *gin.Context) { // TODO: create comment } func GetComment(c *gin.Context) { // TODO: get comment } func UpdateComment(c *gin.Context) { // TODO: update comment } func
GPT

Full Stack Developer

Add to Cart
PromptBase Select
Get this prompt + 9 more with Select$14 your first month, then $19/mo$14 first month, then $19/mo
View Select
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
TEXT-DAVINCI-003
Tested icon
Guide icon
Free credits icon
This prompt is to create a highly secure and responsive web application using Golang and Angular. The task involves providing an architecture and code snippets for implementation. The app will include features such as authentication, authorization, and data encryption. The goal is to showcase your skills in designing and developing secure and fast web applications.
...more
Added over 1 month ago
Report
Browse Marketplace