A simple application for creating and managing tasks, built with React + TypeScript (frontend), Node.js (backend), and PostgreSQL (database). Users can register, log in, and perform CRUD operations on tasks.
- Features
- Prerequisites
- Database Setup
- Environment Variables
- Backend Setup & Run
- Frontend Setup & Run
- Testing Notes
- Salary Expectations
- Contact Information
- User Authentication: Register and log in users with JWT-based authentication.
- Task Management: Create new tasks, view existing tasks, update them (mark complete), or delete them.
- Protected Routes: Only authenticated users can access task endpoints.
- Node.js (v16+ recommended)
- npm (v8+ recommended)
- PostgreSQL (any recent version)
- Install PostgreSQL if you haven’t already.
- Create a new database, for example:
CREATE DATABASE task_manager;
- Run migrations or manually create tables (
users,tasks) if you have a SQL script:CREATE TABLE users ( id SERIAL PRIMARY KEY, username VARCHAR(50) UNIQUE NOT NULL, password VARCHAR(200) NOT NULL ); CREATE TABLE tasks ( id SERIAL PRIMARY KEY, title VARCHAR(100) NOT NULL, description TEXT, is_complete BOOLEAN DEFAULT FALSE, user_id INTEGER REFERENCES users(id) ON DELETE CASCADE );
-
Backend Environment Variables
Create a file named
.envin your backend folder with the following (adjust values as needed):PORT=4000 DATABASE_URL=postgresql://<username>:<password>@localhost:5432/task_manager JWT_SECRET=SomeSuperSecretKeyVariable Description PORTThe port for your backend server (default: 4000). DATABASE_URLPostgreSQL connection string. JWT_SECRETSecret key for signing/verifying JWT tokens. -
Frontend Environment Variables (Create React App)
If you’re using Create React App, you can set frontend environment variables in an
.envfile inside thefrontend/folder. One common variable is the base URL for your backend API:REACT_APP_API_URL=http://localhost:4000Important: By default, Create React App requires that all environment variables start with
REACT_APP_. Any variable that doesn’t have this prefix will be ignored at build time.Variable Example Value Description REACT_APP_API_URL http://localhost:4000The base URL for your backend server. The frontend will use this to make requests to /auth,/tasks, etc.In your React files, you can access
REACT_APP_API_URLthrough:const apiUrl = process.env.REACT_APP_API_URL; // or const apiUrl = import.meta.env.VITE_API_URL; // (If using Vite)
(Adjust accordingly if you’re using Vite or another build setup.)
Note: Add .env to your .gitignore so you don’t commit sensitive credentials.
- Navigate to the backend folder:
cd backend - Install dependencies:
npm install
- Run in development mode:
The server should start on http://localhost:4000.
npm run dev
If you have a build script for production, you could do:
npm run build
npm run start- Navigate to the frontend folder:
cd frontend - Install dependencies:
npm install
- Run the development server:
By default, it should open at http://localhost:3000 (CRA) or http://localhost:5173 (Vite).
# If Create React App: npm start # If Vite: npm run dev
- If using Create React App, ensure you set
REACT_APP_API_URLin.env(frontend) to point to your backend. - If using Vite, ensure you set
VITE_API_URLin.envor in the code directly.
- Register a new user at
/register. - Log In to receive a JWT token, stored in
localStorage. - Manage Tasks:
- Create new tasks.
- Mark tasks as complete or edit them.
- Delete tasks as needed.
- Check the database to ensure tasks link to the correct user.
No Salary Expectations
Matthew Mancini - [email protected] - 860-462-9160