Lojja is a code challenge project that implements an e-commerce store.
The purpose of this project is to demonstrate an (almost) real-world implementation of an e-commerce store that allows users to purchase items without needing to register beforehand. The store uses billing, shipping, and contact information to send updates to the user's email. The payment method is limited to PIX, Brazil's instant payment system released in 2020, and users can choose to pay in full or in installments.
The back-end API is located in the /apps/api directory and provides the core functionality for the e-commerce store. It is built using Node.js, TypeScript, Fastify, and GraphQL (via the Mercurius plugin). The API uses MongoDB as the primary data store, with Mongoose as the ODM. Tap is used for testing the API.
The front-end store is located in the /apps/store directory and provides the user interface for the e-commerce store. It is built using React and TypeScript, with Relay for handling data queries and mutations. The store is styled using Tailwind CSS.
Users can browse products and add them to their cart, and can choose to pay in full or in installments using the PIX payment method. Additionally, users can log in to the /admin
section of the store as an admin user to manage products and orders.
In the /admin
section, admins can add, edit, and delete products, as well as view and update order statuses. This section of the store is only accessible to users with admin privileges.
The current GraphQL schema looks like this:
directive @auth(
requires: Role = BUSINESS,
) on OBJECT | FIELD_DEFINITION
enum Role {
BUSINESS
VISITOR
}
scalar BigInt
enum Category {
ELECTRONICS
FASHION
HOME
GROCERY
SPORTS
TOYS
BOOKS
OTHER
}
type Product {
_id: ID!
name: String!
price: Int!
description: String!
category: Category!
images: [String!]!
createdAt: BigInt!
updatedAt: BigInt
quantity: Int!
}
type Query {
products: [Product!]!
product(_id: String!): Product
productsByCategory(category: Category!): [Product]!
}
type Mutation {
createProduct(name: String!, price: Int!, description: String!, category: Category!, images: [String!]!, quantity: Int!): Product! @auth(requires: USER)
updateProduct(_id: String!, name: String!, price: Int!, description: String!, category: Category!, images: [String!]!, quantity: Int!): Product! @auth(requires: USER)
deleteProduct(_id: String!): Product @auth(requires: USER)
}
This schema can be found at /apps/api/src/data/schema/index.ts. While epresenting all current possibilities with the Front-End only being allowed to read data from the API. The Admin interface is able to create, update and delete products.
To run the Lojja project, clone this repository to your local machine and follow the instructions for each project.
This project is a code challenge and is not currently accepting contributions. However, if you find a bug or have a suggestion for improvement, please feel free to open an issue.
This project is licensed under the MIT License. See the LICENSE file for details.