Aplicação full stack baseada no desafio da Frontend Mentor, Interactive comments section, com CRUD de comentários e respostas, votação e persistência em MongoDB.
- Buscar comentários e respectivas respostas
- Criar e responder comentários
- Editar comentário/resposta
- Excluir comentário/resposta com confirmação
- Upvote e downvote
- Exibir data em formato relativo (time ago), com base em timestamp salvo no banco
- React + Vite
- SWR (fetch)
- date-fns (formatação de tempo relativo)
- Node.js + Express
- MongoDB + Mongoose
- front: aplicação React
- back: API e servidor estático
- Node.js 18+
- MongoDB local ou remoto
Crie o arquivo back/.env com:
MONGODB_URI=mongodb://localhost:27017/seu-banco PORT=3001
Instale e execute:
cd back npm install npm run dev
Em outro terminal:
cd front npm install npm run dev
O backend serve os arquivos estáticos de front/dist.
Para atualizar a versão servida pelo backend:
cd front npm run build
Depois, acesse via backend (porta 3001).
Foi adicionado um script para resetar e popular comentários com base no data.json, convertendo os createdAt do dataset para timestamps reais.
Com o backend rodando:
cd back npm run reseed
Script: back/scripts/reseed-comments.mjs
- GET /api/comments
- POST /api/comments
- PATCH /api/comments/:id
- DELETE /api/comments/:id
- POST /api/comments/:id/replies
- GET /api/users/:id
Full-stack application based on the Frontend Mentor challenge, Interactive comments section, featuring comment/reply CRUD, voting, and MongoDB persistence.
- Fetch comments and related replies
- Create comments and replies
- Edit comments/replies
- Delete comments/replies with confirmation
- Upvote and downvote
- Display date in relative format (time ago), based on timestamps stored in the database
- React + Vite
- SWR (fetch)
- date-fns (relative time formatting)
- Node.js + Express
- MongoDB + Mongoose
- front: React application
- back: API and static server
- Node.js 18+
- Local or remote MongoDB
Create the back/.env file with:
MONGODB_URI=mongodb://localhost:27017/your-database PORT=3001
Install and run:
cd back npm install npm run dev
In another terminal:
cd front npm install npm run dev
The backend serves static files from front/dist.
To update the version served by the backend:
cd front npm run build
Then access the app through the backend (port 3001).
A script was added to reset and repopulate comments from data.json, converting dataset createdAt values into real timestamps.
With the backend running:
cd back npm run reseed
Script: back/scripts/reseed-comments.mjs
- GET /api/comments
- POST /api/comments
- PATCH /api/comments/:id
- DELETE /api/comments/:id
- POST /api/comments/:id/replies
- GET /api/users/:id
