Skip to content

Latest commit

 

History

210 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Challenge GreyDive 🧭

This is a recovered legacy challenge repository. The frontend was originally built with Create React App and has been migrated to Vite as part of the recovery work, mainly to remove the deprecated react-scripts dependency and clean up security warnings from its transitive dependency tree.

The project is still being modernized incrementally. It now includes a Vite frontend and a TypeScript backend API.

Index 📚

Frontend ⚛️

The frontend lives in front/ and is a React application powered by Vite.

Stack 🧱

  • React 18
  • Vite
  • Chakra UI
  • React Router
  • Axios

Running Locally 🚀

From the repository root:

cd front
pnpm install
pnpm run dev

The app runs at:

http://localhost:3000

Build 🏗️

cd front
pnpm run build

Preview Production Build 👀

cd front
pnpm run preview

Migration Notes 🛠️

This frontend used to depend on Create React App through react-scripts. It was migrated to Vite to make the project easier to maintain and to remove deprecated tooling.

Relevant changes made during the migration:

  • Removed react-scripts.
  • Added vite and @vitejs/plugin-react.
  • Moved the app entry HTML to front/index.html.
  • Added front/vite.config.js.
  • Kept the development server on port 3000.
  • Added a Vite proxy for backend API calls to http://localhost:8080.
  • Replaced the old CRA runtime assumptions with Vite-compatible setup.

Routing 🧭

The frontend currently exposes:

/
/test/:id

Invalid routes render a not found state.

API Expectations 🔌

The frontend expects a backend running locally at:

http://localhost:8080

During development, Vite proxies frontend requests from /api to that backend.

The main endpoint currently used by the frontend is:

GET /api/clientes
GET /api/clientes/:id

Backend 🛠️

The backend lives in back/ and exposes the API consumed by the frontend.

Stack 🧱

  • Node.js
  • Express
  • TypeScript
  • Prisma
  • SQLite
  • dotenvx

Environment Variables 🔐

Create a local .env file inside back/ using .env.example as a guide:

cd back
cp .env.example .env

For local development, a typical .env looks like:

DATABASE_URL=file:./prisma.sqlite
PORT=8080
NODE_ENV=development

The SQLite database file is local-only and ignored by Git.

Install Dependencies 📦

cd back
pnpm install

First-Time Setup ⚙️

When running the project for the first time, create and populate the local SQLite database before starting the API:

cd back
pnpm run db:push
pnpm run seed
pnpm run dev

What each command does:

pnpm run db:push  -> Creates/synchronizes the SQLite schema from Prisma.
pnpm run seed     -> Inserts the mock test data into the database.
pnpm run dev      -> Starts the API server.

If db:push or seed are skipped, requests such as:

GET /api/clientes
GET /api/clientes/:id

may fail because the required tables or mock data do not exist yet.

Seed Mock Data 🌱

The backend uses mock test data from back/mocks/test.ts.

Before seeding a fresh SQLite database, sync the Prisma schema:

cd back
pnpm run db:push
cd back
pnpm run seed

This inserts the mock tests into the local SQLite database.

Running Locally 🚀

cd back
pnpm run dev

The API runs at:

http://localhost:8080

The dev command uses dotenvx to load .env and Node watch mode with ts-node/register.

Running the Full Application 🚀

Start the backend first:

cd back
pnpm run dev

Then start the frontend in a separate terminal:

cd front
pnpm run dev

Frontend:

http://localhost:3000

Backend:

http://localhost:8080

Prisma 🗄️

The Prisma schema lives in:

back/prisma/schema.prisma

The current model is Cliente. Its id is an auto-incrementing number, so seeded records can be fetched with numeric IDs like /api/clientes/1.

Build 🏗️

cd back
pnpm run build

Start Production Build ▶️

cd back
pnpm start

Backend Scripts 🧪

pnpm run dev
pnpm run build
pnpm start
pnpm run seed
pnpm run db:push
pnpm run generate
pnpm run lint
pnpm run format:check

API Endpoints 🔌

GET /api/clientes
GET /api/clientes/:id

Example:

curl http://localhost:8080/api/clientes/1

Current Status 🌱

This repository is being restored in small steps. Some legacy pieces may still exist and are being reviewed before removal or refactor.

Known frontend cleanup already started:

  • Vite migration.
  • Folder reorganization.
  • 404 state.
  • Empty states for missing test data.
  • Removal of unused route imports and components.

Known backend cleanup already started:

  • Migrated API to TypeScript.
  • Switched persistence from PostgreSQL to SQLite.
  • Replaced Sequelize with Prisma.
  • Added mock-based seed data.
  • Added dotenvx-based environment loading.

About

Recovery repository for the GreyDive technical challenge. Rebuilt to restore and preserve the original project.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages