Assessment rop for Workcity Africa
# WorkCity API
A RESTful API for client and project management built with Node.js, Express, and MongoDB. Features JWT authentication, role-based access control, and comprehensive rate limiting.
## Features
- **JWT Authentication** - Secure login/signup with token-based auth
- **Client Management** - CRUD operations for client records
- **Project Management** - Full project lifecycle management
- **Role-Based Access** - Admin and user permissions
- **Rate Limiting** - Multi-tier protection against abuse
- **Data Validation** - Comprehensive input validation with Joi
- **MongoDB Integration** - Scalable NoSQL database
## Quick Start
### Prerequisites
- Node.js (v14+)
- MongoDB (v4.4+)
- npm or yarn
### Installation
1. **Clone and install**
```bash
git clone
github.com
cd workcity-api
npm install
```
2. **Environment setup**
Create `.env` file:
```env
PORT=3040
MongoServer=mongodb://localhost:27017
DB_NAME=workcity
JWT_SECRET=your-super-secret-jwt-key-minimum-256-bits
NODE_ENV=development
APPLICATION_NAME="Work City Test"
APPLICATION_PROTOCOL=http
TOKEN_LIFETIME=360000
```
3. **Start the server**
```bash
# Development mode
npm run dev
# Production mode
npm start
```
## API Endpoints
### Authentication
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/auth/signup` | Register new user |
| POST | `/api/auth/login` | User login |
### Users
| Method | Endpoint | Description | Auth | Admin |
|--------|----------|-------------|------|-------|
| GET | `/api/users/profile` | Get current user | ✅ | ❌ |
| GET | `/api/users` | Get all users | ✅ | ✅ |
### Clients
| Method | Endpoint | Description | Auth |
|--------|----------|-------------|------|
| POST | `/api/clients` | Create client | ✅ |
| GET | `/api/clients` | Get all clients | ✅ |
| GET | `/api/clients/:id` | Get client by ID | ✅ |
| PUT | `/api/clients/:id` | Update client | ✅ |
| DELETE | `/api/clients/:id` | Delete client | ✅ |
### …