This is a node.js web application powered by Express and Reactjs that allows developer to create protfolio where they can share Education, Work experience, Skill sets, write a post, like and comment on a post.
API Documentatioin here
Extensive API documentation with examples here
- Signup/signin
- Create protfolio
- Add education detailes
- Add experiences
- Find other developers
- Make post
- Like and comment on a post.
-
Uses Express as the application Framework.
-
Manages Sessions using express-session package.
-
Authenticates via username and password using JsonwebToken and Passport.
-
Passwords are hashed using bcrypt-nodejs package.
-
Social Authentication via Facebook and Twitter using Passport.
-
Uses MongoDB, Mongoose and Mongodb Atles for storing and querying data.
-
Uses Gravatar to retrive profile image from Gamil.
-
UUID to generate unique user ID
Make sure you have Node.js and npm installed.
-
Clone or Download the repository
$ git clone https://github.com/soumanpaul/Developers-Profile-web-app $ cd Developers-Profile-web-app
-
Install Dependencies
- run this commend in project directory
$ npm install
- run this commend in client directory
$ yarn install
-
Edit configuration file in /config/default.json with your credentials(see Setup Configurations).
-
Start the application
-
To run both frontend and backend server together run :
$ npm run dev
Your app should now be running on localhost:3000.
Make sure you have the Heroku Toolbelt installed.
-
Create a new Heroku application, and push your chat application to a Git remote repository
$ heroku create $ git push heroku master
or
-
Now, you need to set up configuration variables on Heroku.
- Go to Settings -> Reveal Config Vars.
- Add configuration variables. All needed variables are inside app/config/index.js.
Typically, these are the configuration variables you need to assign:
{ dbURI, sessionSecret, facebookClientID, facebookClientSecret, twitterConsumerKey, twitterConsumerSecret }
(see Setup Configurations).
-
Open your chat application in the browser
$ heroku open
The configurations on production will be assigned from Environment Variables on Heroku, while the development configurations reside inside app/config/config.json file.
You need to create a database on MongoLab, then create a database user, get the MongoDB URI
, and assign it to dbURI
.
You need to register a new application on both Facebook, Twitter to get your tokens by which users can grant access to your application, and login using their social accounts.
- Go to Facebook Developers
- Add new app, and fill the required information.
- Get your
App ID
,App Secret
. - Go to Add Product -> Facebook Login -> Valid OAuth redirect URIs
- Add Valid Callback URIs
- Go to App Review -> Make your application public.
Now, you can assign the App ID
to facebookClientID
, and App Secret
to facebookClientSecret
.
- Go to Twitter Apps
- Create new app, and fill the required information.
- Add Website & Callback URL
- Get your
Consumer Key
,Consumer Secret
.
Now, you can assign the Consumer Key
to twitterConsumerKey
, and Consumer Secret
to twitterConsumerSecret
.
-
It can point back to your localhost; http://localhost:3000/auth/facebook/callback
-
When deploy to Heroku, you will have something look like this; http://my-chat-app.herokuapp.com/auth/facebook/callback
The session needs a random string to make sure the session id in the browser is random. That random string is used to encrypt the session id in the browser, Why? To prevent session id guessing.
Mongoose is used to interact with a MongoDB that's hosted by MongoLab.
There are two schemas; users and rooms.
Each user has a username, passowrd, social Id, and picture. If the user is logged via username and password, then social Id has to be null, and the if logged in via a social account, then the password will be null.
Each room has a title, and array of connections. Each item in the connections array represents a user connected through a unique socket; object composed of {userId + socketId}. Both of them together are unique.
Each model wraps Mongoose Model object, overrides and provides some methods. There are two models; User and Room.
Session in Express applications are best managed using express-session package. Session data are stored locally on your computer, while it's stored in the database on the production environment. Session data will be deleted upon logging out.
User can login using either a username and password, or login via a social account. User authentication is done using Passport. Passport has extensive, and step-by-step documentation on how to implement each way of authentication.
I've written this script in my free time during my studies. If you find it useful, please support the project by spreading the word.
Contribute by creating new issues, sending pull requests on Github or you can send an email at: paulchsouman@gmail.com
Built under MIT license.
- Version: 1.0.0
- License: MIT
- Author: Souman Paul