Coder Social home page Coder Social logo

ink-backend's Introduction

Tattoo Studio API πŸ–‹οΈ

Welcome to the Tattoo Studio API documentation. This robust API manages user authentication, appointment scheduling, and tattoo artist portfolios. It's the 4th project of the GeeksHub Academy Fullstack Bootcamp, showcasing real-world backend development skills with TypeScript and Express.

Table of Contents πŸ—‚οΈ

Stack πŸ› οΈ

TypeScriptNode.jsExpress.jsMySQLDockerJWTSwaggerPostmanJWT

Features 🌟

  • User Authentication: Secure signup and login processes. πŸ”’
  • Appointment Creation: Users can book appointments, with date and user profile validation. πŸ“…
  • Tattoo Artist Portfolios: Tattooists can upload examples of their work. 🎨
  • Admin CRUD Endpoints: Full control over users, appointments, and tattoo works for administrators. πŸ‘©β€πŸ’ΌπŸ‘¨β€πŸ’Ό
  • Swagger Documentation: Fully documented API endpoints. πŸ“š
  • Docker Compose: Easy setup and deployment with Docker. 🐳
  • Google-Style JSON Responses: Consistently formatted responses. πŸ“
  • MySQL Database with TypeORM and Migrations: Robust database management. πŸ—„οΈ
  • Mock Data Generation: Realistic data generation with Faker.js. πŸ€–
  • JWT Authentication: Secure API endpoints with JSON Web Tokens. πŸ”‘
  • Error Handling: Custom error middleware for handling common API errors. πŸ“

Live Deployment πŸ“‘

Try out the API at:

https://tattoo-booking-api-production.up.railway.app/api

Installation πŸš€

Get a copy of the project up and running on your local machine for development and testing purposes.

git clone https://github.com/pedrogardim/tattoo-booking-api.git
cd tattoo-booking-api

Running with Docker βš“οΈ

docker-compose up --build

(You'll need Docker and Docker Compose installed on your machine.)

Running directly with Node

npm install             # Install dependecies
npm run migrations:run  # Run migrations
npm run seed            # Populate DB with mock
npm run dev             # Run server

You'll need add a .env based on the provided .env.example file with the database credentials, and have a MySQL server running.

API Documentation πŸ“˜

Access the Swagger documentation at:

Database Design πŸ“–

ERD

Relationships

  • Users to Appointments: Double one-to-many relationship where:
    • One user (as a client) can have many appointments.
    • One user (as a tattooist) can be associated with many appointments.
  • Users to Tattoo Works: One-to-many relationship where one tattooist can have many works

Indices and Constraints

  • Users table:
    • Unique constraint on email to ensure each user has a unique email address.
  • Appointments and Tattoo Works tables:
    • Foreign key constraint on client_id and tattooist_id referring to id in the Users table.

API Endpoints πŸ”Œ

Check the swagger documentation for a complete documentation of the API endpoints.

(Click to expand)

Documentation
  • GET /api-docs - Swagger documentation.
User Endpoints
Authentication πŸ”’
  • POST /api/auth/register - Register a new user.
  • POST /api/auth/login - Login an existing user.
Users πŸ‘€
  • GET /api/users/me - Retrieve authenticated user's profile.
  • PUT /api/users/me - Update authenticated user's profile.
  • DELETE /api/users/me - Delete authenticated user.
  • GET /api/users/getTattooists - List all tattooists.
User Appointments πŸ“…
  • GET /api/appointments/my - Retrieve user's appointments.
  • POST /api/appointments/my - Request a new appointment.
  • GET /api/appointments/my/{id} - Retrieve details of a specific appointment.
  • PUT /api/appointments/my/{id} - Update a specific appointment.
  • DELETE /api/appointments/my/{id} - Delete a specific appointment.
TattooWorks - Public 🌍
  • GET /api/tattooWorks - List all tattoo works.
  • GET /api/tattooWorks/{id} - Retrieve a specific tattoo work by ID.
TattooWorks - Tattooist 🎨
  • GET /api/tattooWorks/my - Retrieve a tattooist's works.
  • POST /api/tattooWorks/my - Create a new work for the authenticated tattooist.
  • PUT /api/tattooWorks/my/{id} - Update a specific tattoo work by ID.
  • DELETE /api/tattooWorks/my/{id} - Delete a specific tattoo work by ID.
Admin endpoints
Admin CRUD Endpoints - Users πŸ‘©β€πŸ’ΌπŸ‘¨β€πŸ’Ό
  • GET /api/users - List all users.
  • POST /api/users - Create a new user.
  • GET /api/users/{id} - Retrieve a user by ID.
  • PUT /api/users/{id} - Update a user by ID.
  • DELETE /api/users/{id} - Delete a user by ID.
  • PUT /api/users/setAsTattooist/{id} - Set a user as a tattooist.
Admin CRUD Endpoints - Appointments πŸ“…
  • GET /api/appointments - List all appointments.
  • POST /api/appointments - Create a new appointment.
  • GET /api/appointments/{id} - Retrieve a specific appointment by ID.
  • PUT /api/appointments/{id} - Update a specific appointment by ID.
  • DELETE /api/appointments/{id} - Delete a specific appointment by ID.
Admin CRUD Endpoints - TattooWorks 🎨
  • POST /api/tattooWorks - Create a new tattoo work.
  • PUT /api/tattooWorks/{id} - Update a tattoo work by ID.
  • DELETE /api/tattooWorks/{id} - Delete a tattoo work by ID.

Author βœ’οΈ

Roadmap πŸ›£οΈ

  • Add notifications - So users know when their appointments are modified, created or deleted.
  • Add a React frontend - So users can interact with the API from a web browser.

Acknowledgements πŸŽ“

  • A big shoutout to the Geekshubs Academy for the opportunity to learn and grow as a developer.

ink-backend's People

Contributors

pedrogardim avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.