cd backend
npm install
npm run db
npm start # or: npm run devhttps://backend-8bxt.onrender.com
- GET /users → Returns a list of users with pagination support.
- GET /users/count → Returns the total number of users.
- GET /users/:id → Returns a single user with the total post count they have added.
- POST /users/adders → Adds an adder to a user.
- GET /posts → Returns posts filtered by a specific
userIdquery parameter.
Example:/posts?userId={userId} - GET /posts/count → Returns the total number of posts.
- POST /posts → Create a new post.
- DELETE /posts/:id → Delete a post.
cd frontend
npm install
npm start # or: npm run devhttps://frontend-web-bbrj.onrender.com
- View the list of users.
- View the list of posts by the user.
- Add a new post.
- Delete a post.
- View post creator data at the top.
- run
npm run test- to run the unit tests
erDiagram
USERS {
int id PK
string name
string email
string username
string phone
}
POSTS {
int id PK
string title
string body
datetime created_at
int user_id FK
}
ADDERS {
int id PK
string key
string value
int user_id FK
}
USERS ||--o{ POSTS : "has many"
USERS ||--o{ ADDERS : "has many"
SELECT *
FROM posts
WHERE user_id = ?
ORDER BY created_at DESC;SELECT COUNT(*) as postCount
FROM posts
WHERE user_id = ?;const check = {
title: title.trim().length > 0,
body: body.trim().length > 0,
};
setError(check);- Ensure React Query is used for fetching data.
- Backend is built with Node.js + Express + SQL.
- Frontend is built with React + React Query + React Router.