Skip to content

Driedoutjerky/memory-egg-back

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

223 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nacimiento - Memory Egg Backend

This is the backend repository for Nacimiento - Memory Egg.

CI API Docs

Node.js Express SQLite JavaScript JWT Jest Swagger Render

Nacimiento - Memory Egg is a gamified journaling web application where users take care of a mysterious egg by writing notebook posts, completing quests, and earning credits called Will.

The egg changes over time through the accumulation of memories, reflections, and daily writing. Users can spend Will on egg appearance, background themes, music, and other care-related items.

The egg does not hatch from time.

It hatches from what is remembered.

Project Purpose

This project is not only about a game.

The egg represents something forgotten and fragile that the user chooses to care for. The application encourages users to spend small moments of their busy lives writing, reflecting, and recording memories. Through this habit, the egg gradually changes, symbolizing the user's own process of remembering and taking care of themselves.

Related Repositories

Deployed Backend

  • Backend API Base URL: https://memory-egg-back.onrender.com
  • Swagger / OpenAPI Documentation: https://memory-egg-back.onrender.com/api-docs

Backend Responsibilities

This backend handles:

  • User registration and login
  • JWT-based authentication
  • Protected API routes
  • Egg state and equipped items
  • Notebook post creation, retrieval, and deletion
  • Will reward calculation
  • Daily quest assignment and reward claiming
  • Shop and inventory logic
  • SQLite database persistence
  • API validation and security checks
  • Swagger / OpenAPI documentation
  • Unit and API-level tests
  • GitHub Actions continuous integration

Technology Stack

Area Technology Reason
Runtime Node.js JavaScript runtime for backend development
Server Framework Express Lightweight framework for REST API development
Database SQLite Chosen for lightweight implementation and simple project deployment
Authentication JWT Token-based authentication for protected routes
Password Security bcrypt Passwords are stored as hashes, not plaintext
API Documentation Swagger UI + OpenAPI YAML Documents API contract and request/response schemas
Testing Jest + Supertest Unit tests and API-level tests
CI GitHub Actions Automatically runs tests on push

Project Structure

src/
  controllers/
  routes/
  models/
  services/
  middleware/
  validators/
  tests/
  app.js
  server.js

docs/
  api/
    openapi.yaml

Environment Variables

Create a .env file using .env.example

cp .env.example .env

On Windows PowerShell, use:

Copy-Item .env.example .env

Then open .env and replace the placeholder values with your local configuration. To generate a strong JWT secret, you can run:

node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"

Never commit the real .env file to GitHub.

Setup and Run

1. Clone the repository

git clone https://github.com/Driedoutjerky/memory-egg-back.git
cd memory-egg-back

2. Install dependencies

npm install

3. Create .env

Create a .env file using the environment variable format above.

4. Start the server

npm start

The backend runs on:

http://localhost:5000

Health check:

GET http://localhost:5000/api/health

API documentation:

http://localhost:5000/api-docs

API Documentation

The OpenAPI specification file is located at:

docs/api/openapi.yaml

The Swagger UI documentation is served at /api-docs

Deployed documentation:

Hosted by Render : https://memory-egg-back.onrender.com/api-docs

Main API Endpoints

Method Path Purpose Auth Required
GET /api/health Check backend server status No
POST /api/auth/register Register new user and create starter egg No
POST /api/auth/login Login user No
GET /api/auth/me Get current user profile, egg, and equipped items Yes
GET /api/auth/me/inventory View owned items Yes
PATCH /api/egg/equip Equip background, music, or cosmetic item Yes
PATCH /api/egg/unequip Unequip background, music, or cosmetic item Yes
POST /api/posts Create notebook post Yes
GET /api/posts/all Get all posts created by current user Yes
GET /api/posts/:id Get one post Yes
DELETE /api/posts/:id Delete own post Yes
GET /api/quests/today Get today's assigned quests Yes
POST /api/quests/:id/claim Claim completed quest reward Yes
GET /api/shop/items Browse shop items Yes
POST /api/shop/purchase Buy item with Will Yes

Testing

Run all tests with:

npm test

Run tests with coverage:

npm run test:coverage

The test suite includes:

  • Unit tests for backend modules
  • API tests for authenticated routes
  • API tests for successful main flows
  • API tests for error cases such as 400, 401, 404, and 409

Continuous Integration

This repository uses GitHub Actions to run the test suite automatically on push.

The CI workflow helps verify that the backend remains stable after changes and that tests pass before evaluation.

AI Usage Disclosure

AI tools were used to help generate example mock data for development and testing. AI tools were not used as a replacement for understanding the submitted implementation.

License

This project is under the Apache-2.0 license.

About

Express REST API backend for Nacimiento - Memory Egg.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors