• Stars
    star
    652
  • Rank 69,062 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

✍️ Opinionated project architecture for Full-Stack JavaScript Applications.

Full-Stack JavaScript Architecture

Full-Stack JavaScript Architecture

Opinionated project architecture for Full-Stack JavaScript Applications.

About

Using JavaScript for full-stack has always been a challenge especially with architecting various pieces of the application, choosing technologies and managing devOps. This project provides a base for typical project consisting a Landing Website, Web and Mobile Applications, API service and easy deployment of these services. This project uses a microservice architecture where all individual project runs as a service (container).

A typical product (SaaS, etc.) usually consists of following services:

  • Landing page
    • Used for introducing your business to customers
    • Provide links to download the mobile application
    • Provide link to access web application
    • Contact page
    • Privacy policy page
    • Terms of use page
    • SEO friendly (should support server side rendering)
  • Web Application
    • Your actual application for your customers to use
    • Desktop browser
    • Tablet and mobile browser via responsive design
  • Mobile Application
    • Your actual application for your customers to use
    • Android (Mobile/Tablet)
    • iOS (Mobile/Tablet)

Core Structure

fsja
  ├── backend
  │   ├── api
  │   │   > NodeJS
  │   │   > PORT 8000
  │   │   > api.example.com
  │   │
  │   ├── database
  │   │   > MongoDB
  │   │   > PORT 27017
  │   │
  │   └── proxy
  │       > NGINX
  │       > PORT 80 / 443
  │
  ├── deployment
  │   > Docker Compose
  │
  ├── frontend
  │   ├── app
  │   │   ├── mobile
  │   │   │   > React Native
  │   │   │   > iOS (Apple App Store)
  │   │   │   > Android (Google Play Store)
  │   │   │
  │   │   └── web
  │   │       > React
  │   │       > Single page application
  │   │       > PORT 5000
  │   │       > app.example.com
  │   │
  │   └── landing
  │       > React
  │       > Server side rendered
  │       > PORT 3000
  │       > example.com
  │
  └── README.md (you are here)

Stack

Backend

  • API
    • NodeJS
    • Express
  • Database
    • MongoDB
  • Proxy
    • NGINX

Frontend

  • Landing

    • React
    • Next.js
    • Material UI
    • Server Side Rendering
  • Web

    • React
    • Redux
    • React Router
    • Material UI
  • Mobile (iOS, Android)

    • React Native
    • Redux
    • React Navigation

Deployment

  • Technologies
    • Docker
    • Docker compose

Setup and Running

  • Prerequisites

    • Node (v10.x)
    • MongoDB (v4.x)
    • Xcode (for iOS) (latest)
    • Android Studio (for Android) (latest)
    • Follow React Native Guide to setup your local machine
  • Clone repository git clone [email protected]:atulmy/fullstack-javascript-architecture.git fullstack

  • API

    • Info
      • Authentication strategy: JWT (JSON Web Token)
      • Current implementation uses RPC (Remote Procedure Call) for API endpoints (one endpoint URL, multiple operations) and can be easily replaced with REST.
      • Resources
    • Switch to api directory cd backend/api
    • Configuration
      • Create local environment file cp .env.dev.example .env.local
      • Modify .env.local for
        • PORT (8000)
        • NODE_ENV (development | production)
        • SECURITY_SECRET (Use PasswordsGenerators)
        • SECURITY_SALT_ROUNDS (10)
        • MONGO_URL (mongodb://localhost:27017/example)
        • LANDING_URL (http://localhost:3000)
        • WEB_URL (http://localhost:5000)
        • API_URL (http://localhost:8000)
        • EMAIL_ON (0 | 1 (in development, you can toggle to send emails or not))
        • EMAIL_TEST (send test emails to this address)
        • EMAIL_HOST, EMAIL_USER, EMAIL_PASSWORD (use any email service, eg. mailgun.com and get credentials to start sending emails
    • Setup
      • Install packages and seed database npm run setup
    • Run
  • Landing

    • Switch to landing directory cd frontend/landing
    • Configuration
      • Create local environment file cp .env.dev.example .env.local
      • Modify .env.local for
        • PORT (3000)
        • NODE_ENV (development | production)
        • URL_LANDING (http://localhost:3000)
        • URL_WEB (http://localhost:5000)
        • URL_API (http://localhost:8000)
        • GA_TRACKING_ID (Google analytics tracking ID)
    • Setup
      • Install dependencies: npm install
    • Run
    • Resources
  • Web

    • Switch to web directory cd frontend/app/web
    • Configuration
      • Create local environment file cp .env.dev.example .env.local
      • Modify .env.local for
        • PORT (5000)
        • REACT_APP_LANDING_URL (http://localhost:3000)
        • REACT_APP_WEB_URL (http://localhost:5000)
        • REACT_APP_API_URL (http://localhost:8000)
    • Setup
      • Install dependencies: npm install
    • Run
  • Deployment

    • Deploy code
      1. Login to the server (SSH)
      2. Create a new directory on server: mkdir /var/www/fullstack and switch to the directory cd /var/www/fullstack
      3. Clone repository git clone [email protected]:atulmy/fullstack-javascript-architecture.git .
      4. Switch to deployment directory cd deployment
      5. Build containers docker-compose up --build -d
        • up = Builds, (re)creates, starts, and attaches to containers for a service.
        • --build = Build images before starting containers
        • -d = Detached mode: Run containers in the background, print new container names
      6. Re-deploy with following steps:
        • Change directory cd /var/www/fullstack
        • Pull latest code git pull
        • Rebuild containers: docker-compose up --build -d
    • Resources
  • Mobile

    • Switch to mobile directory cd frontend/app/mobile
    • Configuration
      • Modify src/setup/config/env.js for
        • APP_ENV (development | production)
        • LANDING_URL (http://<your local network IP>:3000)
        • WEB_URL (http://<your local network IP>:5000)
        • API_URL (http://<your local network IP>:8000)
        • Tip: use ifconfig on macOS or Linux to get your local IP address
    • Setup
      • Install dependencies: npm install
    • Run
      • iOS react-native run-ios --simulator='iPhone 8'
      • Android react-native run-android (connect your Android phone via USB or use already created simulator with name Mobile_-_5 by running cd ~/Library/Android/sdk/tools && ./emulator -avd Mobile_-_5)
    • Publish
      • Android
        • Build: cd android && ./gradlew assembleRelease && cd ...
        • Upload frontend/app/mobile/android/app/build/outputs/apk/release/app-release.apk to Play Store.
      • iOS
        • Build: Open frontend/app/mobile/ios/example.xcodeproj in Xcode -> Choose Generic iOS Device (top left) -> Product (top menu) -> Archive.
        • Upload using Archiver (will open automatically once Archive is complete)
    • Resources

Screenshots

View all screenshots here.

Landing
Landing Landing
Web
Web Web
Mobile
Mobile Mobile

Authors

Collaborators

  • Hossein Nedaee - GitHub
  • [YOUR NAME HERE] - Feel free to contribute to the codebase by resolving any open issues, refactoring, adding new features, writing test cases or any other way to make the project better and helpful to the community. Feel free to fork and send pull requests.

Resources and Inspirations

  • 💁‍♂️ Hand picked collection of packages, tutorials and more for React Native - GitHub
  • 🌱 Lightweight (remote procedure call) API pattern - GitHub
  • 🛡 A simple validation library for server and client side applications - GitHubNPM
  • 🌐 Universal react application with server side rendering - GitHub
  • 📦 A sample web and mobile application built with Node, Express, React, React Native and Redux - GitHub
  • Start learning by looking at sample codes on GitHub: #LearnByExamples

Hire me

Looking for a developer to build your next idea or need a developer to work remotely? Get in touch: [email protected]

Donate

If you liked this project, you can donate to support it ❤️

Donate via PayPal

Thank you for donating:

License

Copyright (c) 2018 Atul Yadav http://github.com/atulmy

The MIT License (http://www.opensource.org/licenses/mit-license.php)

More Repositories

1

crate

👕 👖 📦 A sample web and mobile application built with Node, Express, React, React Native, Redux and GraphQL. Very basic replica of stitchfix.com / krate.in (allows users to get monthly subscription of trendy clothes and accessories).
JavaScript
2,400
star
2

fullstack-graphql

🌈 Simple Fullstack GraphQL Application. API built with Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with React + Redux to access the API. Written in ES6 using Babel + Webpack.
JavaScript
1,026
star
3

oauth

🔗 OAuth 2.0 implementation for various providers in one place.
JavaScript
426
star
4

gql-query-builder

🔧 Simple GraphQL Query Builder
TypeScript
354
star
5

node-express-react-redux-zwitter

🐣 A basic clone of Twitter (Boilerplate App) - Separate API (express+mongo) and Frontend (react+redux) folders using Node, Express, MongoDB, React (create-react-app), React Router v4 and Redux.
JavaScript
92
star
6

universal-react

🌐 A simple universal react application with server side rendering built with latest versions of React (v16+), React Router (v5+), Redux (v4+), Express (v5+), Webpack (v4+), Babel Preset ES6 👨‍💻
JavaScript
79
star
7

hire-smart

✅ HIRE SMART (community edition) - Streamline hiring process, scheduling interviews and tracking candidates.
JavaScript
70
star
8

react-recoil

A sample implementation of React Recoil.
JavaScript
44
star
9

react-native-curated

💁‍♂️ Hand picked collection of packages, tutorials and more for React Native.
43
star
10

wispy

🌱 An experimental lightweight (remote procedure call) API pattern.
JavaScript
36
star
11

meteor-react-simple-chat

💬 Basic chat application using Meteor 1.4 and React.
JavaScript
25
star
12

meteor-baseui

📱🖥 Basic UI: Mobile + Web
HTML
13
star
13

node-react-zwitter

🐧 NodeJS, Express, MySQL and React Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
13
star
14

cv

📄 Curriculum Vitae
12
star
15

meteor-bootstrap

🐣 Meteor Bootstrap / Boilerplate Project with essential folder structures and packages.
JavaScript
10
star
16

meteor-mafia

🎮 Mafia: The Party Game!
JavaScript
9
star
17

meteor-rock-paper-scissors

👊✋✌️ Rock Paper Scissors - Play online with your friends or with computer
JavaScript
7
star
18

meteor-tictactoe

🎮 Tic Tac Toe - Play multiplayer online with your friends
JavaScript
6
star
19

node-express-handlebars-zwitter

🐧 NodeJS, Express, Mongoose and Handlebars Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
5
star
20

jquery-connectors

🔗 Draws a path between two HTML elements.
JavaScript
5
star
21

fullstack-validator

🛡 A simple validation library for server and client side JavaScript applications.
TypeScript
5
star
22

meteor-1.4-zwitter

🐧 Meteor 1.4 Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
4
star
23

tool-aspectratio

📱 🖥 💻 Calculate aspect ratio online for images, display screens, montors and mobile easily.
PHP
4
star
24

php-angular-easyapp

An easy, flexible, very light weight, extendable, small to medium scale application template. Recommended for beginners exploring web technologies. Best suited for SPAs and RIAs.
PHP
4
star
25

node-basics

Basics of NodeJS
JavaScript
4
star
26

meteor-react-zwitter

🐧 Meteor + ReactJS Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
3
star
27

baseui

📱🖥 Basic UI: Mobile + Web
HTML
3
star
28

node-express-angular-job-finder

🔍 A sample app built on Mongo, Express and Angular and Node
CSS
2
star
29

workstation

1
star