A small Express backend for the Macro Brain app — a demo user service that exposes simple authentication, profile and image-entry endpoints. This repo is intended as a lightweight backend for the frontend app and for learning / demo purposes.
Status: Prototype / demo (not production-ready — see Security notes).
- Simple in-memory user store (mocked data)
- Endpoints for sign-in, registration, profile lookup and image entry count
- Uses
express,cors, andbcrypt-nodejsfor password hashing demo
- Node.js + Express
- Dependencies listed in
package.json(seedependencies)
- Clone the repo and change to the project directory.
- Install dependencies:
npm installStart the server in development mode (uses nodemon as defined in
package.json):
npm startThe server is configured for local development. By default the example logs a
message referencing port 3000 — you may need to set a proper numeric port in
server.js or set process.env.PORT before running in environments that require
a specific port.
All examples assume the server is running on http://localhost:3000 (adjust
the host/port as needed).
-
GET
/— returns the list of users (mock data)Example:
curl http://localhost:3000/
-
GET
/profile/:id— get user profile by idExample:
curl http://localhost:3000/profile/123
-
POST
/signin— sign in user (demo: compares against first user)Request JSON body:
{ "email": "john@example.com", "password": "cookies" } -
POST
/register— register a new user (adds to in-memory store)Request JSON body:
{ "name": "Alice", "email": "alice@example.com", "password": "pw" } -
PUT
/image/:id— incremententriescount for user with given idExample:
curl -X PUT http://localhost:3000/image/123
Users are stored in an in-memory database object inside server.js. Each user
has the fields: id, name, email, password, entries, and joined.
- This project uses a mocked in-memory data store and stores example plaintext passwords in the demo users. Do not use this as-is in production.
- While
bcrypt-nodejsis included and demonstrated, the current registration flow does not persist hashed passwords to the in-memory store — consider updating the flow to properly hash and store passwords before deploying. - The
server.jscurrently binds to the literal string$PORT— adjust to a numeric port or useprocess.env.PORTfor real deployments.
This project is small and intended for demos. If you want to contribute:
- Open an issue for feature requests or bugs.
- Send a pull request with a focused change and tests if applicable.
See the LICENSE file in this repository.