Skip to content

Latest commit

Β 

History

History
123 lines (105 loc) Β· 4.02 KB

File metadata and controls

123 lines (105 loc) Β· 4.02 KB

gogym-api

Application for registration and check-in at gyms

πŸ‹οΈ GoGym - Gym Check-in Management System

GoGym is a modern and efficient gym check-in management application built with Node.js and Fastify. It allows gym owners to manage their facilities and users to easily check in with a seamless experience.

πŸš€ Features

  • User Register: Members can be registered on application.
  • User Check-in: Members can check in to gyms quickly and securely.
  • Gym Management: Owners can manage gym locations, memberships, and check-ins.

πŸ”§ Technologies Used

  • Node.js (Backend Runtime)
  • Fastify (Web Framework)
  • Zod (Schema Validation)
  • dotenv (Environment Variables)
  • Prisma (Serverless architecture ORM)
  • BCryptjs (Hashing lib for passwords)
  • Vitest (Unit tests enviroment)

πŸ“‚ Project Structure

go-gym-api/
β”œβ”€β”€ prisma/
β”‚ β”œβ”€β”€ migrations # stored migration history
β”‚ └── schema.prisma # Database tables schemas
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ @types/ # Store globals interfaces on project
β”‚ β”œβ”€β”€ env/
β”‚ β”‚ └── index.ts # Enviroment vars validation
β”‚ β”œβ”€β”€ http/
β”‚ β”‚ β”œβ”€β”€ controllers/ # Handler of request response
β”‚ β”‚ └── middlewares # Functions to interact between controllers and endpoints
β”‚ β”œβ”€β”€ lib/
β”‚ β”‚ └── prisma.ts # Prisma client config
β”‚ β”œβ”€β”€ repositories/ # Layer for database manipulation tools
β”‚ β”‚ β”œβ”€β”€ in-memory/
β”‚ β”‚ β”œβ”€β”€ prisma/
β”‚ β”‚ β”œβ”€β”€ check-ins-repository.ts # Check-ins Interface
β”‚ β”‚ β”œβ”€β”€ gyms-repository.ts # Check-ins Interface
β”‚ β”‚ └── users-repository.ts # Users Interface
β”‚ β”œβ”€β”€ use-cases/ # Use cases layer for entities
β”‚ β”‚ β”œβ”€β”€ errors/ # Use case error messages
β”‚ β”‚ └── factories/ # Use case factories for instances
β”‚ β”œβ”€β”€ utils/ # Application utility functions
β”‚ β”‚ └── test/ # Utility functions for tests
β”‚ β”œβ”€β”€ app.ts # Fastify app setup
β”‚ └── server.ts # Server setup config
β”œβ”€β”€ env.example # Enviroment variables example
β”œβ”€β”€ .eslintrc.json # ESLint Config
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .npmrc # NPM config libs control
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ LICENSE
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ vite.config.ts # Unit test config file
└── README.md

βš™οΈ Setup & Installation

  1. Clone the repository:

    git clone https://github.com/DevAnseSenior/gogym-api.git
    cd go-gym-api
  2. Install dependencies:

    npm install
  3. Set up environment variables (create .env file):

    NODE_ENV="your_env" ("dev", "test", "production")
    PORT=3333
    DATABASE_URL=
  4. Run the application:

    docker compose up -d # Start the services
    npx prisma migrate dev # Execute migrations
    npm run start:dev # Run application on development mode

    The API will be available at http://localhost:3333

  5. Run tests:

    docker compose up -d # Start the services
    npm run test # Run the unit tests suits
    npm run test:e2e # Run the tests e2e suits
    npm run test:watch # Run the tests on watch mode
    npm run test:coverage # Verify the tests coverage (open index.html from dir coverage/)
    npm run test:ui # Execute the test client of vitest

πŸ“Œ Endpoints (Example)

Users

  • POST /users β†’ Register new user.
  • POST /sessions β†’ Authenticate (login).
  • GET /me β†’ Get logged user info.

Gyms

  • POST /gyms β†’ Create a new gym.
  • GET /gyms/search β†’ Search gym by title.
  • GET /gyms/nearby β†’ Search nearby user localization gyms.

Check-ins

  • POST /gyms/:gymId/check-ins β†’ Check-in.
  • PATCH /check-ins/:checkInId/validate β†’ Gym validations check-in.
  • GET /check-ins/history β†’ Get check-ins history.
  • GET /check-ins/metrics β†’ Get check-ins count of logged user.

πŸ“„ License

This project is licensed under MIT License.

Made with πŸ’ͺ by Anderson Coelho πŸš€ Powered by Fastify & Node.js