Skip to content

An API for a mini projects platform where clients post projects and freelancers apply. It supports registration, login, project CRUD, application submission, and more.

Notifications You must be signed in to change notification settings

darionnuel/mini-projects-platform

Repository files navigation

Mini Projects Platform

Description

An API for a mini projects platform where clients post projects and freelancers apply. It supports registration, login, project CRUD, application submission, and more.

Requirements

  • Node.js (v16 or above)
  • PostgreSQL
  • Docker (optional for containerization)

Project structure

├── .env.example
├── .eslintrc.cjs
├── .gitignore
├── .prettierrc
├── Dockerfile
├── README.md
├── docker-compose.yml
├── package-lock.json
├── package.json
├── postman_collection.json
├── prisma
│   ├── schema.prisma
│   └── seed.js
└── src
├── app.js
├── env.js
├── logger.js
├── middlewares
│   ├── auth.js
│   ├── error.js
│   ├── rateLimit.js
│   ├── rbac.js
│   └── validate.js
├── modules
│   ├── applications
│   │   ├── routes.js
│   │   ├── schemas.js
│   │   └── service.js
│   ├── auth
│   │   ├── controller.js
│   │   ├── routes.js
│   │   └── schemas.js
│   └── projects
│   ├── controller.js
│   ├── routes.js
│   ├── schemas.js
│   └── service.js
├── prisma.js
└── server.js

Setup

  1. Clone the repository:

    git clone https://github.com/your-username/mini-projects-platform.git
    cd mini-projects-platform
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    Create a .env file based on .env.example and add your environment-specific values (e.g., JWT_SECRET).

  4. Run the application:

    npm run dev
  5. Docker Setup (optional):

    docker-compose up --build   # Builds the image and runs containers
    docker-compose up -d        # Run containers in detached mode
  6. Database

  • Start Postgres (Docker recommended):
    docker compose up -d db
  • Copy env and set secrets:
    cp .env.example .env
  • Generate client & run migrations:
    npx prisma generate
    npm run prisma:migrate # or `npx prisma migrate dev` for dev environments
  • Seed dev data:
    npm run seed
  1. Run API

    npm run dev
    # or production:
    npm run build && npm start

API Endpoints

Auth

  • POST api/auth/register: Register a new user with { name, email, password, role }
  • POST api/auth/login: Log in and get a JWT token with{ email, password }{ token }
    • Use header: Authorization: Bearer <token>

Projects

  • GET api/projects: List all projects with filters filters status, budgetMin, budgetMax, q, page, pageSize
  • GET api/projects/:id: Get a specific project by ID
  • POST api/projects: Create a project (CLIENT only) DRAFT
  • PATCH api/projects/:id: Update a project (CLIENT only)
  • DELETE api/projects/:id: Delete a project (CLIENT only)
  • POST api/projects/:id/open: Transition project from DRAFT→OPEN (CLIENT only)
  • POST api/projects/:id/close: Transition project from OPEN→CLOSED (CLIENT or ADMIN)

Applications

  • POST /projects/:id/applications: Apply to a project (FREELANCER only)
  • GET /projects/:id/applications: List applications for a project (CLIENT or ADMIN)
  • GET /projects/me/applications: List applications by the authenticated freelancer

Tooling

  • Logging: pino
  • Security: helmet, rate limiting (auth routes)
  • Validation: Zod
  • Lint/Format: ESLint + Prettier

Docker (Optional)

docker compose up --build

The API waits for migrations then starts on :PORT.


Notes

  • CORS: Adjust CORS settings in src/app.js if exposing publicly.
  • JWT Expiry/Refresh: Consider updating JWT expiry times or implementing a refresh token strategy for better session management in production.
  • OpenAPI Generation: Consider using zod-to-openapi or other OpenAPI tools for automatic documentation if needed.

About

An API for a mini projects platform where clients post projects and freelancers apply. It supports registration, login, project CRUD, application submission, and more.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published