"Unicorn" is the project that aims to take my programming skills to the moon π
Let's get to the real description of this project. This app is mainly based on tinder logic (swiping, matching, messaging etc.)
If you don't know how tinder works, please familiarize yourself with this topic before reading further.
I thought it would be a good idea for the project, because tinder contains very interesting features such as:
- real time messaging
- matching and filtering users
- swiping
- premium accounts / time subscriptions
It may not seem like it, but the database architecture is really complicated and writing it from scratch was quite a challenge for me.
For detailed documentation of each feauture, please refer to the features section.
- ποΈ Installation
- β² Features
- π§ͺ Tests
- πΎ Seeders
- π» Developmnent
- π Environment variables
- π Scripts
- π€ Credits
-
Install all yarn dependiencies included in
package.json
yarn install
-
Configure the environment variables
-
Run Prisma commands to handle DB staff
prisma migrate dev
&&prisma generate
, you can also use created scriptsIf you face any troubles while running above prisma's commands, just install prisma globally via:
yarn add global prisma
-
Creating an account
-
Log in
-
Password change
- User can change his password using his old password, new password and repeating it
-
Email verification
- Account is created with an unverified email, you can verify it by clicking on the link sent to the email linked to the account
-
Email change
-
User can change his email address with a new e-mail (which is not already in the database) and his password (for security reasons)
-
After changing your email, you need to verify it
-
-
Password reset
-
If you forgot your password don't worry, just enter your email address and the server will send you a link to reset your password
-
The link can of course be used once and is canceled in the event of a change of email address
-
-
Log out
-
from the current sessions
-
from all sessions
-
-
Deleting an account
- password protected for security reasons
-
User profile
-
access to profile info
-
update general info (name,city,description etc.)
-
update matching info (showMeGender, showMeAgeLowerLimit etc.)
-
upload up to 9 profile photos (stored in 4 different sizes - large, medium, small ,thumbnail)
-
-
Matching
-
The entire matching process is based on user preferences, there are 4 key factors that influence which users you get to match
-
ShowMeGender - Male, Female, or All
-
ShowMeAgeLowerLimit and ShowMeAgeUpperLimit - based on birthday, filters users who are within a certain age range
-
ShowMeDistance - based on user current longitude and latitude, it filters out users that are no more than, for example, 30km away from the user
-
Whether you already like/reject/match with user (controlled by the likes and usersRelations tables)
-
-
-
Swiping
-
Default like or notInterested
-
Create a new conversation when users have liked each other
-
Daily like limit
-
-
Conversations
-
Rename
-
Delete the conversation (usersRelation type is set to "removed")
-
-
Messaging
-
Text, photo, video and voice messages
-
Real time with socket.io
-
You can delete the message, but a trace of it remains (content of messase is set to "", and isDeleted property is set to true (default false)), inspired by messenger
-
-
Account types
- Silver
- Gold
- Black
-
You can activate a premium account if you have a secret token and its ID
-
The token is hashed with the argon2 library so that in the event of a data leak, no one will be able to use it anyway (the same reason why you should hash passwords
-
{ id: "token1", token: "silverToken", daysOfValidity: 30, accountType: "silver", }, { id: "token2", token: "goldToken", daysOfValidity: 30, accountType: "gold", },
-
At this point there are 150 tests in total
Run it with the following command (reference to the script)
yarn test
Be sure to set up your environment variables and database first
ποΈ Auth
- π₯οΈ Source code
- βοΈ Tested features
- Creating an account
- Login
- Password change
- Email change
- Email verification
- Password reset
- Logout
- Deleting an account
π WebSockets
- π₯οΈ Source code
- βοΈ Tested features
- Socket.io authentication && authorization
- Sending and receiving messages
π€Ό Relations
- π₯οΈ Source code
- βοΈ Tested features
- Profile
- Update
- View users' photos
- Matching
- Proper filtering
- Likes
- Superlikes
- Not interested
- New pair
- Messages
- Text
- Photos
- Voice messages
- Videos
- Deleting
- Access to files
- Conversations
- Deleting
- Renaming
- Proper filtering
- Profile
π° Premium Accounts
- π₯οΈ Source code
- βοΈ Tested features
- Likes limit
- Rewind last like
- Superlikes / limitter
- Silver, gold and black account protected routes
Currenly in my project you can find two seed files that I use mainly them for testing
πΎ Main seed
- π₯οΈ Source code
- π» Data
- 48 users
- 5 likes
- 4 conversations
- 3 messages
- 6 users relations
- 4 premium account tokens
πΎ Like limit seed
- π₯οΈ Source code
- πΏ The purpose of this seed is to reach the like limit (set in constants) in order to test the premium account features
- π» Data to seed
- 2 likes
- 5 users relations
The client side is currently being developed just to test and learn about websockets. However, it works very well and will certainly be developed further.
π±οΈ At the beginning, start the client
yarn start
And you can log into 3 different accounts
After logging in, you will see the conversation page
PORT - port on which express server is running
ORIGIN - client hostname
DATABASE_URL - url of the development database
TEST_DATABASE_URL - url of the test database
MAIN_SECRET_TOKEN - token used to sign authentication tokens
ACCESS_TOKEN_TTL - access token time to live
REFRESH_TOKEN_TTL - refresh token time to live
MAX_AGE_TOKEN_COOKIE - cookie time to live, should be equal to REFRESH_TOKEN_TTL
SERVER_SUPPORT_EMAIL - server support email address, used to send account verification, password reset emails etc. Must be compatible with the transporter and inbox test. SERVER_SUPPORT_PASSWORD - password for server support email
EMAIL_SECRET_TOKEN - token used to sign tokens included in email links
EMAIL_TOKEN_TTL - email token time to live
FORCE_LOG - by default while NODE_ENV is set to "test", logger is disabled. You can change this (set value to "true"), if you want to see logs during testing TEST_EMAIL_ADDRESS - during testing, an account associated with this email is created, so the verification email is sent to it. Later I can check if everything was successful through inbox test TEST_EMAIL_PASSWORD - password for test email
- Start the client
"start": "react-scripts start",
-
Start the development server
"dev": "NODE_ENV=development ts-node-dev --respawn --transpile-only src/index.ts"
-
Clean up development files and data
"cleanupdev": "NODE_ENV=development ts-node src/prisma/cleanup/cleanUpDev.ts",
-
Generate prisma client
"gen": "prisma generate",
-
Synchronize your prisma schema with your database schema (can result in data loss)
"push": "prisma db push",
-
Run prisma studio
"studio": "prisma studio",
-
Create and apply migrations
"migrate": "prisma migrate dev",
-
Format .prisma files
"format": "prisma format",
-
Run inboxTest
"inboxtest": "ts-node src/tests/helpers/inboxTest.ts",
-
Run all tests
"test": "NODE_ENV=test jest --detectOpenHandles --runInBand && NODE_ENV=test FORCE_LOG=true ts-node src/prisma/cleanup/cleanUpAfterTests.ts",
-
Clean up files and test data ( includes inboxTest )
"cleanup": "NODE_ENV=test FORCE_LOG=true ts-node src/prisma/cleanup/cleanUpAfterTests.ts",
-
Seed the development database
"seeddev": "NODE_ENV=development ts-node src/prisma/seed/main.seed.ts",
-
Seed the test database
"seedtest": "NODE_ENV=test FORCE_LOG=true ts-node src/prisma/seed/main.seed.ts"
One man army - ποΈ DevKica