A full-stack task management application built with React, Express, and MongoDB.
Features Β· Getting Started Β· Project Structure Β· API Reference Β· Environment Variables
OnTrack is a productivity-focused task manager that allows users to create, organize, and track tasks with ease. It features JWT-based authentication, a responsive React frontend powered by Vite, and a RESTful Express API backed by MongoDB.
- Authentication β Secure sign-up / login with JWT tokens and hashed passwords (bcrypt)
- Task CRUD β Create, read, update, and delete tasks
- Task Status β Track tasks as
Todo,In Progress, orDone - Priority Levels β Assign
Low,Medium, orHighpriority to each task - Due Dates β Set deadlines and receive overdue indicators
- Filtering & Sorting β Filter tasks by status, priority, or due date
- User Isolation β Each user only sees their own tasks
- Responsive UI β Works seamlessly on desktop and mobile
| Layer | Technology |
|---|---|
| Frontend | React 18 + Vite |
| Styling | CSS Modules / Tailwind CSS |
| Backend | Node.js + Express 4 |
| Database | MongoDB + Mongoose |
| Auth | JSON Web Tokens (JWT) + bcrypt |
| Dev Tools | ESLint, Nodemon, dotenv |
OnTrack/
βββ frontend/ # React + Vite application
β βββ public/
β βββ src/
β β βββ assets/
β β βββ components/ # Reusable UI components
β β β βββ TaskCard.jsx
β β β βββ TaskForm.jsx
β β β βββ Navbar.jsx
β β βββ pages/ # Route-level pages
β β β βββ Login.jsx
β β β βββ Register.jsx
β β β βββ Dashboard.jsx
β β βββ services/ # Axios API calls
β β β βββ api.js
β β βββ context/ # React context (Auth)
β β β βββ AuthContext.jsx
β β βββ App.jsx
β β βββ main.jsx
β βββ .env # Frontend env variables
β βββ index.html
β βββ vite.config.js
β βββ package.json
β
βββ backend/ # Express REST API
β βββ config/
β β βββ db.js # MongoDB connection
β βββ controllers/
β β βββ authController.js
β β βββ taskController.js
β βββ middleware/
β β βββ authMiddleware.js # JWT verification
β βββ models/
β β βββ User.js
β β βββ Task.js
β βββ routes/
β β βββ authRoutes.js
β β βββ taskRoutes.js
β βββ .env # Backend env variables
β βββ server.js
β βββ package.json
β
βββ README.md
- Node.js v20 or higher
- MongoDB running locally or a MongoDB Atlas cluster
- npm or yarn
git clone https://github.com/RAZAFITSALAMA-sandra/OnTrack.git
cd OnTrackPORT=3000
MONGO_URI=mongodb://admin:sandra@localhost:27017/taskflow?authSource=admin
JWT_SECRET=taskflow_secret_2024VITE_API_URL=http://localhost:3000/apiSecurity note: Never commit
.envfiles to version control. Both are already listed in.gitignore. -->
# Backend
cd backend
npm install
# Frontend
cd ../frontend
npm installBackend (runs on http://localhost:3000)
cd backend
npm run devFrontend (runs on http://localhost:5173)
cd frontend
npm run devOpen http://localhost:5173 in your browser.
# Build the frontend
cd frontend
npm run build
# Start the backend in production mode
cd ../backend
npm startThe compiled frontend assets will be in
frontend/dist/. You can serve them statically from Express or deploy them separately (Vercel, Netlify, etc.).
| Variable | Location | Description |
|---|---|---|
PORT |
backend/.env |
Port the Express server listens on |
MONGO_URI |
backend/.env |
Full MongoDB connection string |
JWT_SECRET |
backend/.env |
Secret key used to sign JWT tokens |
All endpoints are prefixed with /api.
Protected routes require a Authorization: Bearer <token> header.
| Method | Endpoint | Access | Description |
|---|---|---|---|
POST |
/api/auth/register |
Public | Create a new account |
POST |
/api/auth/login |
Public | Log in and receive a JWT |
GET |
/api/auth/me |
Protected | Get current user info |
| Method | Endpoint | Access | Description |
|---|---|---|---|
GET |
/api/tasks |
Protected | Get all tasks for the logged-in user |
POST |
/api/tasks |
Protected | Create a new task |
GET |
/api/tasks/:id |
Protected | Get a single task by ID |
PUT |
/api/tasks/:id |
Protected | Update a task |
DELETE |
/api/tasks/:id |
Protected | Delete a task |
Request
POST /api/tasks
Authorization: Bearer <your_jwt_token>
Content-Type: application/json
{
"title": "Write project documentation",
"description": "Cover setup, API, and deployment.",
"status": "todo",
"priority": "high",
"dueDate": "2024-12-31"
}Response 201 Created
{
"_id": "64f3a1c2e4b0c72d88f1a9d3",
"title": "Write project documentation",
"description": "Cover setup, API, and deployment.",
"status": "todo",
"priority": "high",
"dueDate": "2024-12-31T00:00:00.000Z",
"user": "64f3a0e1e4b0c72d88f1a9c1",
"createdAt": "2024-09-03T10:22:42.000Z",
"updatedAt": "2024-09-03T10:22:42.000Z"
}{
name: String, // required
email: String, // required, unique
password: String, // hashed with bcrypt
createdAt: Date
}{
title: String, // required
description: String,
status: enum ['todo', 'in-progress', 'done'], // default: 'todo'
priority: enum ['low', 'medium', 'high'], // default: 'medium'
dueDate: Date,
user: ObjectId (ref: 'User'), // required
createdAt: Date,
updatedAt: Date
}| Script | Command | Description |
|---|---|---|
dev |
nodemon server.js |
Start with hot reload |
start |
node server.js |
Start in production mode |
| Script | Command | Description |
|---|---|---|
dev |
vite |
Start the dev server |
build |
vite build |
Build for production |
preview |
vite preview |
Preview the production build |
lint |
eslint src |
Run ESLint |
- Set environment variables (
PORT,MONGO_URI,JWT_SECRET) in your hosting dashboard. - Push your code or connect your GitHub repository.
- The start command is
node server.js.
- Set
VITE_API_URLto your deployed backend URL. - Build command:
npm run build - Publish directory:
dist
Replace MONGO_URI with your Atlas connection string:
mongodb+srv://<user>:<password>@cluster0.xxxxx.mongodb.net/taskflow?retryWrites=true&w=majority
Contributions are welcome!
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m "feat: add my feature" - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
Please follow the Conventional Commits specification.
This project is licensed under the MIT License. See the LICENSE file for details.