Skip to content

GraphQL backend for ServiceAd, a platform to discover and promote local services. Features JWT auth, MongoDB, image uploads, and efficient GraphQL APIs for frontend clients.

Notifications You must be signed in to change notification settings

Andu-alem/serviceadgraphql

Repository files navigation

ServiceAd GraphQL Backend

A backend for the ultimate platform for discovering and promoting local services and businesses.

Whether you're a service provider looking to reach more customers or someone in need of a specific service, ServiceAd connects you with the best options in your area.


🚀 Features

Service Discovery: Search and filter local services by category, name, or location.
Service Promotion: Service providers can register and promote their services with detailed descriptions and images.
Authentication: Secure JWT-based signup, login, and token revalidation for user protection.
GraphQL API: Flexible, efficient data querying for frontend clients.
MongoDB Integration: Stores users, services, images, and categories with Mongoose schemas.
Image Handling: Supports service profile images via Base64 uploads.
Fully Deployed: Live backend on Render, frontend on Vercel, with Netlify deployment support included.


🛠️ Tech Stack

  • Backend: Node.js, Apollo Server (GraphQL), MongoDB, Mongoose
  • Auth: JWT, bcrypt
  • Frontend: (can be any frontend or mobile app with GraphQL client)
  • Deployment: Render (backend), Vercel & Netlify (frontend support)
  • Other Tools: dotenv, CORS, base64 image handling

📂 Folder Structure

``` root/ │ ├── api/ │ ├── index.js # Entry for Vercel deployment │ └── server.js │ ├── graphql/ │ ├── index.js │ ├── typeDefs.js │ └── resolvers.js │ ├── models/ │ ├── Category.js │ ├── Umage.js │ ├── Post.js │ ├── Service.js │ ├── Post.js │ ├── Review.js │ ├── ServiceType.js │ └── User.js │ ├── lib │ └── actions.js │ └── db-connection.js │ ├── netlify/functions/ │ └── server.js # Entry for Netlify deployment │ ├── index.js # Main entry point for local/dev ├── .env.example ├── .gitignore ├── netlify.toml ├── vercel.json └── package.json ```


⚙️ Setup and Development

1️⃣ Clone the repository

```bash git clone https://github.com/Andu-alem/serviceadgraphql.git cd servicead ```

2️⃣ Install dependencies

```bash npm install ```

3️⃣ Configure environment variables

Create a `.env` file based on `.env.example`:

``` MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_secret_key PORT=4000 ```

4️⃣ Run locally

```bash node index.js ```

The server will start at: ``` http://localhost:4000/ ```

Access the GraphQL Playground at: ``` http://localhost:4000/graphql ```


🛰️ Deployment

  • Vercel: Uses `api/index.js` and `api/server.js` for deployment.

  • Render: Deploy `index.js` as your server entry point with your environment variables set in the Render dashboard.

  • Netlify: Uses `netlify/functions/server.js` for Netlify Functions deployment.


🔍 Example Queries

✅ Register a user

```graphql mutation { signup(username: "john", email: "john@example.com", password: "password123") } ```

✅ Login

```graphql mutation { login(email: "john@example.com", password: "password123") } ```

✅ Register a service

```graphql mutation { registerService( serviceName: "Plumbing Service", serviceType: "Home Maintenance", category: "Plumbing", city: "Addis Ababa", uniqueaddress: "Bole Road", description: "Professional plumbing services for all your needs.", profileImage: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..." ) { id serviceName description address { city uniqueaddress } category { name } } } ```


👤 Author

Andualem Fereja Bayisa


📜 License

This project is licensed under the MIT License.


🚀 Contributing

Pull requests are welcome. If you wish to contribute:

  1. Fork the repo
  2. Create your feature branch (`git checkout -b feature/new-feature`)
  3. Commit your changes (`git commit -m 'Add new feature'`)
  4. Push to the branch (`git push origin feature/new-feature`)
  5. Open a pull request

🙌 Acknowledgements

Built to showcase GraphQL backend engineering, authentication, and deployment skills with a practical, live service promotion and discovery platform.

About

GraphQL backend for ServiceAd, a platform to discover and promote local services. Features JWT auth, MongoDB, image uploads, and efficient GraphQL APIs for frontend clients.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published