|
1 | 1 | # gogym-api |
2 | 2 | Application for registration and check-in at gyms |
| 3 | +# ποΈ GoGym - Gym Check-in Management System |
| 4 | + |
| 5 | +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. |
| 6 | + |
| 7 | +## π Features |
| 8 | + |
| 9 | +- **User Register**: Members can be registered on application. |
| 10 | +- **User Check-in**: Members can check in to gyms quickly and securely. |
| 11 | +- **Gym Management**: Owners can manage gym locations, memberships, and check-ins. |
| 12 | + |
| 13 | +## π§ Technologies Used |
| 14 | + |
| 15 | +- **Node.js** (Backend Runtime) |
| 16 | +- **Fastify** (Web Framework) |
| 17 | +- **Zod** (Schema Validation) |
| 18 | +- **dotenv** (Environment Variables) |
| 19 | +- **Prisma** (Serverless architecture ORM) |
| 20 | +- **BCryptjs** (Hashing lib for passwords) |
| 21 | +- **Vitest** (Unit tests enviroment) |
| 22 | + |
| 23 | +## π Project Structure |
| 24 | +```bash |
| 25 | +go-gym-api/ |
| 26 | +βββ prisma/ |
| 27 | +β βββ migrations # stored migration history |
| 28 | +β βββ schema.prisma # Database tables schemas |
| 29 | +βββ src/ |
| 30 | +β βββ @types/ # Store globals interfaces on project |
| 31 | +β βββ env/ |
| 32 | +β β βββ index.ts # Enviroment vars validation |
| 33 | +β βββ http/ |
| 34 | +β β βββ controllers/ # Handler of request response |
| 35 | +β β βββ middlewares # Functions to interact between controllers and endpoints |
| 36 | +β βββ lib/ |
| 37 | +β β βββ prisma.ts # Prisma client config |
| 38 | +β βββ repositories/ # Layer for database manipulation tools |
| 39 | +β β βββ in-memory/ |
| 40 | +β β βββ prisma/ |
| 41 | +β β βββ check-ins-repository.ts # Check-ins Interface |
| 42 | +β β βββ gyms-repository.ts # Check-ins Interface |
| 43 | +β β βββ users-repository.ts # Users Interface |
| 44 | +β βββ use-cases/ # Use cases layer for entities |
| 45 | +β β βββ errors/ # Use case error messages |
| 46 | +β β βββ factories/ # Use case factories for instances |
| 47 | +β βββ utils/ # Application utility functions |
| 48 | +β β βββ test/ # Utility functions for tests |
| 49 | +β βββ app.ts # Fastify app setup |
| 50 | +β βββ server.ts # Server setup config |
| 51 | +βββ env.example # Enviroment variables example |
| 52 | +βββ .eslintrc.json # ESLint Config |
| 53 | +βββ .gitignore |
| 54 | +βββ .npmrc # NPM config libs control |
| 55 | +βββ docker-compose.yml |
| 56 | +βββ LICENSE |
| 57 | +βββ package.json |
| 58 | +βββ tsconfig.json |
| 59 | +βββ vite.config.ts # Unit test config file |
| 60 | +βββ README.md |
| 61 | +``` |
| 62 | + |
| 63 | +## βοΈ Setup & Installation |
| 64 | + |
| 65 | +1. **Clone the repository**: |
| 66 | + ```bash |
| 67 | + git clone https://github.com/DevAnseSenior/gogym-api.git |
| 68 | + cd go-gym-api |
| 69 | + ``` |
| 70 | + |
| 71 | +2. **Install dependencies**: |
| 72 | + ```bash |
| 73 | + npm install |
| 74 | + ``` |
| 75 | + |
| 76 | +3. **Set up environment variables (create *.env* file)**: |
| 77 | + ```bash |
| 78 | + NODE_ENV="your_env" ("dev", "test", "production") |
| 79 | + PORT=3333 |
| 80 | + DATABASE_URL= |
| 81 | + ``` |
| 82 | + |
| 83 | +4. **Run the application**: |
| 84 | + ```bash |
| 85 | + docker compose up -d # Start the services |
| 86 | + npx prisma migrate dev # Execute migrations |
| 87 | + npm run start:dev # Run application on development mode |
| 88 | + ``` |
| 89 | + |
| 90 | + The API will be available at http://localhost:3333 |
| 91 | + |
| 92 | +5. **Run tests**: |
| 93 | + ```bash |
| 94 | + docker compose up -d # Start the services |
| 95 | + npm run test # Run the unit tests suits |
| 96 | + npm run test:e2e # Run the tests e2e suits |
| 97 | + npm run test:watch # Run the tests on watch mode |
| 98 | + npm run test:coverage # Verify the tests coverage (open index.html from dir coverage/) |
| 99 | + npm run test:ui # Execute the test client of vitest |
| 100 | + ``` |
| 101 | + |
| 102 | +## π Endpoints (Example) |
| 103 | +### Users |
| 104 | +- POST /users β Register new user. |
| 105 | +- POST /sessions β Authenticate (login). |
| 106 | +- GET /me β Get logged user info. |
| 107 | + |
| 108 | +### Gyms |
| 109 | +- POST /gyms β Create a new gym. |
| 110 | +- GET /gyms/search β Search gym by title. |
| 111 | +- GET /gyms/nearby β Search nearby user localization gyms. |
| 112 | + |
| 113 | +### Check-ins |
| 114 | +- POST /gyms/:gymId/check-ins β Check-in. |
| 115 | +- PATCH /check-ins/:checkInId/validate β Gym validations check-in. |
| 116 | +- GET /check-ins/history β Get check-ins history. |
| 117 | +- GET /check-ins/metrics β Get check-ins count of logged user. |
| 118 | + |
| 119 | +## π License |
| 120 | +This project is licensed under MIT [License](./LICENSE). |
| 121 | + |
| 122 | +Made with πͺ by Anderson Coelho |
| 123 | +π Powered by Fastify & Node.js |
0 commit comments