Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f669232
chore: setup NestJS backend and Next.js frontend with env configs
lucasbachega Jun 3, 2025
569e76e
chore: setup backend folder git
lucasbachega Jun 3, 2025
300d3bb
chore: config Mongoose Module
lucasbachega Jun 3, 2025
998a705
chore: config docker compose
lucasbachega Jun 3, 2025
2673948
chore: setup Dockerfile backend
lucasbachega Jun 3, 2025
4520ac3
chore: ajusts docker compose front/back
lucasbachega Jun 3, 2025
4b01407
feat(books): add Book module with schema, DTO and basic setup
lucasbachega Jun 3, 2025
e7382c4
feat(books): implement create and list endpoints for Book resource
lucasbachega Jun 3, 2025
1beb1ba
feat(frontend): integrate React Query and Axios with backend book end…
lucasbachega Jun 3, 2025
ec11976
feat(ui): improve BookList styling and add text variant to Button com…
lucasbachega Jun 3, 2025
f05281a
feat(backend + ui): add page BookDetailPage and fetchBookById
lucasbachega Jun 3, 2025
758e01d
feat(backend): add description prop books schema
lucasbachega Jun 3, 2025
f0ce63f
feat(backend reviews): initial setup schemas, services, modules
lucasbachega Jun 3, 2025
1ebf174
feat(reviews): list books aggregate reviews count/avrg
lucasbachega Jun 3, 2025
dc0444f
feat: list reviews by book on frontend and backend
lucasbachega Jun 4, 2025
61ef330
feat: add book review submission with UI and backend integration
lucasbachega Jun 4, 2025
b28ccaa
feat(frontend): add date-fns and layout ajusts
lucasbachega Jun 4, 2025
7e9977f
feat(backend): add limit/sort avgRating in findAll books
lucasbachega Jun 4, 2025
23ea256
feat(backend): add seed + dockerfile
lucasbachega Jun 4, 2025
e7efaae
feat(frontend): final layout/text ajusts
lucasbachega Jun 4, 2025
a5dab77
update README
lucasbachega Jun 4, 2025
2c1374e
ajusts: docker compose and ts
lucasbachega Jun 4, 2025
e0d7142
add: tests e2e and update README
lucasbachega Jun 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 87 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,113 @@
# Tech-Assessment – Book Reviews Platform
# Book Reviews Platform

**Goal**
Build a small “Book Reviews” platform (CRUD books + reviews, plus an endpoint that returns the top-rated books).
A fullstack web application to explore books and leave reviews, built with modern tech from frontend to backend.

| Stack (mandatory) | Why |
|-------------------|-----|
| NestJS + MongoDB | API, data layer & aggregation |
| Next.js (App Router) | UI & SSR |
| React Query | Data fetching / cache |
| Tailwind CSS | Styling |
> Backend: **NestJS**
> Frontend: **Next.js (App Router)**
> Database: **MongoDB**
> DevOps: **Docker Compose**

> **Time-box:** aim for **4-8 h** of focused work.
> When time is up, push what you have — unfinished is OK, but document what’s missing.
---

## Features

- List books with average ratings
- Book detail pages with user reviews
- Submit reviews with form validation
- Data cached and refreshed with React Query
- Seed script for demo data

---

## 1. What you must deliver
## Running the App

### Option 1: With Docker (Recommended)

```bash
git clone https://github.com/lucasbachega/teste-fullstack.git
cd teste-fullstack
docker compose up --build -d
docker compose exec backend npm run seed
```

| Area | Minimum requirements |
|------|----------------------|
| **Backend** | *Connect to MongoDB* via env var<br>*Models*: `Book`, `Review` (rating 1-5)<br>*CRUD* endpoints for both entities (`/books`, `/books/:id/reviews`)<br>*Aggregation*: `GET /books/top?limit=10` returns avgRating + reviewCount, sorted desc<br>*Tests*: at least **one** e2e test hitting `/books/top` |
| **Frontend** | `/books` page listing the top books (uses React Query)<br>Book detail page showing reviews and a form to add a review (optimistic update welcome)<br>Responsive UI with Tailwind |
| **DX / Ops** | Clear local-dev instructions (README or Makefile)<br>`.env.example` with all needed vars<br>Lint + format commands<br>(Optional) Docker setup |
Docker Compose will:
- Start the **frontend** on `http://localhost:3500`
- Start the **backend** on `http://localhost:9100`
- Start **MongoDB**
- Auto-seed the DB with demo data

---

## 2. Local setup expected by reviewers
### Option 2: Manual Setup

#### Install Dependencies

```bash
pnpm install # monorepo or multiple projects — you choose
pnpm dev # should start both backend and frontend
# backend on :3001, frontend on :3000 is a common pattern
cd backend && npm install
cd frontend && npm install
```

If you rely on Docker (e.g. docker compose up mongo), document it.
#### Configure Environment Variables

**Backend → `backend/.env`:**

## 3. Submission guidelines
1. Fork this repo, build on main.
2. Open a pull request to your own fork when finished. In the PR description include:
- (i) What is done / not done,
- (ii) How to run tests and
- (iii) Any trade-offs or shortcuts
3. Do not open a PR against the original repo.
```env
PORT=9100
MONGO_URI=mongodb://localhost:27017/book-reviews
```

**Frontend → `frontend/.env.local`:**

## 4. Evaluation rubric
```env
NEXT_PUBLIC_API_URL=http://localhost:9100
```

Criterion Weight
#### Run Servers

- Correctness & tests 30 %
- Code quality / structure 20 %
- Data modelling & validation 15 %
- Aggregation query efficiency 10 %
- Frontend UX & accessibility 15 %
- Documentation 10 %
```bash
# Backend
cd backend
npm run start:dev

# Frontend
cd frontend
npm run dev
```

---

#### Tests e2e

## 5. Constraints & tips
To run the backend **end-to-end (E2E) tests**, follow these steps:

- TypeScript everywhere.
- Keep third-party libs minimal (testing & dev-tools are fine).
- Commit early & often — we read history.
- Feel free to use dev-containers / Codespaces; just explain how.
1. Create a `.env` file inside the `backend/` folder:
2. Add your test database connection string to it:

MONGO_URI=mongodb://localhost:27017/bookreviews_test

> Make sure MongoDB is running locally and the `bookreviews_test` database is available.

3. Inside the `backend/` folder, run:

npm run test:e2e

This will run the Jest test suite using the test database.

---

## Seeding Data

```bash
cd backend
npm run seed
```

---

## Stack Summary

Good luck 🚀
- NestJS + MongoDB
- Next.js + React Query
- Zod + RHF for forms
- TailwindCSS
- Docker
8 changes: 8 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
dist
.env
Dockerfile
docker-compose.yml
.git
.gitignore
README.md
24 changes: 24 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Node modules
node_modules/

# Build output
dist/

# Environment variables
.env

# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# IDEs and editors
.vscode/
.idea/
*.swp

# OS files
.DS_Store
Thumbs.db
4 changes: 4 additions & 0 deletions backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
8 changes: 8 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:20.5.1-alpine3.18
WORKDIR /app
COPY . .
RUN npm i -g @nestjs/cli
RUN npm install
RUN npm run build
ENV NODE_ENV=production
CMD ["npm", "run", "start:prod"]
98 changes: 98 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Project setup

```bash
$ npm install
```

## Compile and run the project

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

## Run tests

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov
```

## Deployment

When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.

If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:

```bash
$ npm install -g @nestjs/mau
$ mau deploy
```

With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.

## Resources

Check out a few resources that may come in handy when working with NestJS:

- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).

## Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
34 changes: 34 additions & 0 deletions backend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: ['eslint.config.mjs'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
sourceType: 'commonjs',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn'
},
},
);
8 changes: 8 additions & 0 deletions backend/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading