The backend powering the chest opening exerpience
View Site
ยท
Report Bug
ยท
Request Feature
Table of Contents
The frontend may capture the imagination with its 3D chest-opening experience, but it's the backend architecture that ensures this interactive adventure runs smoothly. Engineered for high performance and scalability, the backend framework supports a seamless user experience, managing game logic, content updates, and user data with efficiency.
Key Highlights:
- Robust Data Management: Leveraging Prisma alongside PostgreSQL, the backend adeptly handles complex data operations, guaranteeing data integrity and seamless access to game content and user progress.
- Scalable Architecture: Designed with future growth in mind, the architecture utilizes Docker for containerization, facilitating easy scalability as user demand grows.
- Secure Authentication: Advanced security measures are in place for managing user authentication and protecting data, ensuring a secure environment for all users.
- Dynamic Content Delivery: With Sanity.io, content updates and game asset management can occur in real-time, maintaining a fresh and engaging user experience.
- High-Performance Framework: Powered by Elysia, the backend enjoys fast response times and smooth interactions, catering to users worldwide with efficiency.
- Modern Development Tools: Embracing TypeScript for its type safety and Bun.js for its execution speed, the development process is both streamlined and efficient, fostering rapid iteration and deployment.
The backend's robust and dynamic platform underpins the chest-opening adventure, equipped with leading technologies to ensure a stable and evolving journey for the user community.
This backend leverages a stack designed for robustness, scalability, and ease of development. Here's what makes it tick:
-
- TypeScript brings static typing to JavaScript, enhancing code quality and developer productivity through its powerful type system and compilation for error-checking.
-
- Elysia is a high-performance, scalable framework for building efficient and secure APIs, offering out-of-the-box support for modern web standards.
-
- Prisma is an open-source ORM for Node.js and TypeScript, making database access easy with its auto-generated and type-safe query builder, simplifying data management and migrations.
-
- PostgreSQL is a powerful, open-source object-relational database system that uses and extends the SQL language combined with many features to safely store and scale the most complicated data workloads.
-
- Sanity.io provides a structured content management platform, enabling seamless collaboration on content editing and offering a source of truth for all forms of digital content.
-
- Docker simplifies deployment by allowing the application and its environment to be packaged as containers, ensuring consistency across various development and production settings.
-
- Bun.js is a modern JavaScript runtime like Node.js but focuses on offering better performance and a more comprehensive package manager, making development workflows faster and more efficient.
By combining these technologies, the backend architecture ensures a solid foundation for developing and scaling the chest-opening platform, focusing on performance, security, and developer experience.
To set up this project locally and explore the immersive 3D chest-opening experience, follow these steps.
Ensure you have either Node.js or Bun installed on your system to manage project dependencies and run the development server.
- For Node.js, download and install it from nodejs.org.
- For Bun, you can install it by running the following in your terminal (visit bun.sh for more details):
curl https://bun.sh/install | bash
- Clone the repository to get a local copy of the project:
git clone https://github.com/vinnyhoward/loot-chest-backend.git
cd loot-chest-backend
- Install dependencies using either npm (Node.js) or Bun. Choose the command based on your preference:
Using npm:
npm install
Using Bun:
bun install
- Configure environment variables by creating a .env file in the root directory of the project. Fill it with your specific values based on the provided .env template:
DATABASE_URL=<database_url>
SANITY_PROJECT_ID=<sanity_project_id>
SANITY_DATASET=<sanity_dataset>
SANITY_SECRET_TOKEN=<sanity_secret_token>
PORT=<port>
JWT_SECRETS=<jwt_secret>
JWT_NAME=<jwt_name>
MAILERSEND_API_KEY=<mailersend_api_key>
SITE_URL=<site_url>
Ensure to replace placeholder values with your actual settings. These values are critical for the proper operation of your application.
4, Prisma Setup: After installing your dependencies, run the following Prisma commands to set up your database schema, validate it, format it for readability, and apply the changes to your database:
bun prisma generate
bun prisma validate
bun prisma format
bun prisma db push
These commands help generate the Prisma client based on your schema, validate the schema, format it properly, and push the schema changes to your database, creating the necessary tables.
- Utilize Docker for environment consistency (optional but recommended):
-
If you haven't installed Docker and Docker Compose yet, follow the instructions on Docker's official website.
-
To build and run your application in a Docker container, execute:
docker-compose up --build
This command starts your application and database services as defined in docker-compose.yml
. Your backend should now be accessible at http://localhost:3000/
or another port if specified differently in your .env
file and Docker configuration.
- Run the development server locally without Docker:
Using npm:
npm run dev
Using Bun:
bun run dev
Access the application by navigating to http://localhost:<port>/
in your web browser, replacing <port>
with the port number you've specified in your .env
file.
You're now set to dive into the backend development, supporting the dynamic and engaging 3D chest-opening experience. Happy coding!
This backend server is designed to work seamlessly with its corresponding frontend and provides a comprehensive API for managing the chest-opening experience. You can interact with the server in two primary ways:
-
Ensure the Installation Steps are Completed: Before running the server, make sure you've followed the Installation steps to set up the project and its dependencies on your local machine.
-
Start the Server: Use the command appropriate for your package manager to start the server:
- With npm:
npm run dev
- With Bun:
bun run dev
This command initializes the development server and watches for any changes to the TypeScript files, recompiling and restarting the server as needed.
- With npm:
-
Access the API: With the server running, you can access the API endpoints through
http://localhost:<port>
, where<port>
is the value you've set in your.env
file (default is usually 3000).
For those who prefer to test and interact with the API via a graphical interface, a Postman collection is provided:
-
Download Postman: If you haven't already, download and install Postman from their official site.
-
Import the Collection: Download the Postman collection and import it into Postman. This collection contains prepared requests for each endpoint of the API, making it easy to test and explore the available functionalities.
-
Configure Environment Variables in Postman: Ensure you set up Postman environment variables such as the API URL to point to your local server or the deployed version, depending on where you're running the backend.
By following these steps, you can effectively utilize the backend server either directly through your local setup or via Postman, allowing for a versatile and comprehensive testing and development workflow.
- Forgot Password/Reset Password needs a expired token flow
- Welcome to Loot Chest email
Distributed under the MIT License. See LICENSE.txt
for more information.
Vincent Howard - @NiftyDeveloper - [email protected]
Project Link: https://github.com/vinnyhoward/loot-chest