Skip to content

SamiulIslam007/Food-Hub-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍔 FoodHub Server

Welcome to the backend API of FoodHub – a comprehensive food delivery and restaurant management platform. This server is built using modern web technologies to ensure scalability, robust performance, and type safety.


🚀 Tech Stack


📂 Project Structure (Modules)

The server follows a modular architecture. Core functionalities are divided into distinct domains:

  • User / Admin: Authentication, authorization, and administrative controls.
  • Provider / Restaurant: Management of restaurant details and profiles.
  • Category: Categorization of food items.
  • Meal: Endpoints for adding, updating, and fetching food items.
  • Cart: Shopping cart management for users.
  • Order: Order placement, tracking, and status updates.
  • Review: Customer ratings and reviews for meals/providers.
  • Favorite: Users' favorite meals or restaurants.

🛠️ Prerequisites

Make sure you have the following installed on your machine:


🏃‍♂️ Getting Started

1. Clone the repository

git clone <repository-url>
cd foodHub-server

2. Install Dependencies

npm install

3. Environment Variables

Create a .env file in the root directory and configure the following variables (use .env.example if available):

PORT=5000
DATABASE_URL="postgresql://user:password@localhost:5432/foodhub?schema=public"
JWT_SECRET="your_super_secret_jwt_key"
JWT_EXPIRES_IN="7d"

4. Database Setup (Prisma)

Generate the Prisma Client and push the schema to your database:

npx prisma generate
npx prisma db push

(Optional) If you have seed data configured:

npm run seed

5. Start the Server

For Development (Auto-restarts on save):

npm run dev

For Production:

npm run build
npm start

🌿 Branching Strategy

  • main: Production-ready and stable code. Only tested and reviewed changes are merged here.
  • dev: Active development branch. All new features and fixes should be developed on top of this branch.

Typical workflow:

  1. Checkout the dev branch: git checkout dev
  2. (Optional) Create a feature branch from dev: git checkout -b feature/<feature-name>
  3. Work on your changes and commit them.
  4. Merge your feature branch back into dev.
  5. After testing, dev is merged into main for release.

📜 Available Scripts

  • npm run dev: Starts the server in development mode using ts-node-dev.
  • npm run build: Compiles TypeScript files into the dist folder.
  • npm start: Runs the compiled server from dist/server.js.
  • npm run lint: Checks for linting errors using ESLint.
  • npm run lint:fix: Fixes auto-correctable linting errors.
  • npm run format: Formats code using Prettier.
  • npm run seed: Populates the database with initial seed data.

🔐 Authentication & Authorization

The API uses Bearer tokens (JWT) for secure routes.

  • Ensure you pass the token in the Authorization header: Bearer <your_token>
  • Different roles (e.g., user, admin, provider) have distinct access controls enforced via middleware.

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages