GithubHelp home page GithubHelp logo

one-more-light's Introduction

Remix Indie Stack

The Remix Indie Stack

Learn more about Remix Stacks.

npx create-remix@latest --template remix-run/indie-stack

What's in the stack

Development

  • Initial setup:

    npm run setup
  • Start dev server:

    npm run dev

This starts your app in development mode, rebuilding assets on file changes.

The database seed script creates a new user with some data you can use to get started:

Relevant code:

This is a pretty simple note-taking app, but it's a good example of how you can build a full stack app with Prisma and Remix. The main functionality is creating users, logging in and out, and creating and deleting notes.

Deployment

This Remix Stack comes with two GitHub Actions that handle automatically deploying your app to production and staging environments.

Prior to your first deployment, you'll need to do a few things:

  • Install Fly

  • Sign up and log in to Fly

    fly auth signup

    Note: If you have more than one Fly account, ensure that you are signed into the same account in the Fly CLI as you are in the browser. In your terminal, run fly auth whoami and ensure the email matches the Fly account signed into the browser.

  • Remove docker-related and Fly config file in order to use new Fly setups:

    rm -f Dockerfile .dockerignore fly.toml
  • Initialize Fly apps. This will automatically recreate 3 files that we've just removed and also configure everything for Fly as recommended:

    Until Remix complete the process of simplify and modernize deploy flow with Fly, we'll use this setup. Details of rethinking Remix/Indie stack & Fly deploy setup can be find in Indie stack's issue #252

    fly launch
  • Give permission to run the start.sh script on docker: In Dockerfile, change the ENTRYPOINT line to

    RUN chmod +x "./start.sh"
    ENTRYPOINT [ "./start.sh" ]
    
  • Deploy our apps to Fly:

    fly deploy
  • Initialize Git.

    git init
  • Create a new GitHub Repository, and then add it as the remote for your project. Do not push your app yet!

    git remote add origin <ORIGIN_URL>
  • Add a FLY_API_TOKEN to your GitHub repo. To do this, go to your user settings on Fly and create a new token, then add it to your repo secrets with the name FLY_API_TOKEN.

Now that everything is set up you can commit and push your changes to your repo. Every commit to your main branch will trigger a deployment to your production environment, and every commit to your dev branch will trigger a deployment to your staging environment.

Fly has a default value auto_stop_machines = true and auto_start_machines = true, so the apps can take around ~10s to restart. We'll keep it this way for cost-reduction.

Connecting to your database

The sqlite database lives at /data/sqlite.db in your deployed application. You can connect to the live database by running fly ssh console -C database-cli.

Getting Help with Deployment

If you run into any issues deploying to Fly, make sure you've followed all of the steps above and if you have, then post as many details about your deployment (including your app name) to the Fly support community. They're normally pretty responsive over there and hopefully can help resolve any of your deployment issues and questions.

GitHub Actions

We use GitHub Actions for continuous integration and deployment. Anything that gets into the main branch will be deployed to production after running tests/build/etc. Anything in the dev branch will be deployed to staging.

Testing

Cypress

We use Cypress for our End-to-End tests in this project. You'll find those in the cypress directory. As you make changes, add to an existing file or create a new file in the cypress/e2e directory to test your changes.

We use @testing-library/cypress for selecting elements on the page semantically.

To run these tests in development, run npm run test:e2e:dev which will start the dev server for the app as well as the Cypress client. Make sure the database is running in docker as described above.

We have a utility for testing authenticated features without having to go through the login flow:

cy.login();
// you are now logged in as a new user

We also have a utility to auto-delete the user at the end of your test. Just make sure to add this in each test file:

afterEach(() => {
  cy.cleanupUser();
});

That way, we can keep your local db clean and keep your tests isolated from one another.

Vitest

For lower level tests of utilities and individual components, we use vitest. We have DOM-specific assertion helpers via @testing-library/jest-dom.

Type Checking

This project uses TypeScript. It's recommended to get TypeScript set up for your editor to get a really great in-editor experience with type checking and auto-complete. To run type checking across the whole project, run npm run typecheck.

Linting

This project uses ESLint for linting. That is configured in .eslintrc.js.

Formatting

We use Prettier for auto-formatting in this project. It's recommended to install an editor plugin (like the VSCode Prettier plugin) to get auto-formatting on save. There's also a npm run format script you can run to format all files in the project.

Import svg

This project uses React-SVGR to transform SVG Elements into React Elements, since React Elements are easier to use and type-safe.

Our conventions recommend adding SVG files to public/svgs and run

npm run svg

React components will be automatically created at app/components/svgs. There's a setup in SVGR's docs for Remix but we decided not to use it since it requires using a Prettier plugin, which can possibly conflict with other Prettier plugins.

Styling Guideline

Animation

Duration

  • For short animation (small UI components):
duration-200

Transition

  • Recommended (almost all the cases):
ease-out

Accessibility

  • For keyboard-interaction input:
focus-visible:outline-[choose-your-color]
  • For anything else (mouse/touchscreen):
focus:outline-[choose-your-color]

TODO List

  • Feature: Tag system for Blogs
  • Restructure design system & tailwind config
  • Chore: Remove notes
  • New page: All Links
  • New page: Portfolio
  • Feature: Blog Pagination
  • Feature: Footer with contact
  • New page: Reports and suggestions
  • New page: Showcase
  • New page: Landing page (replacement for current root page)
  • Testing (cypress, vitest)
  • Feature: Image hosting for Blog
  • Feature: Mail collector - Subscription (Mailgun?)
  • Feature: Sticky navbar ref

Coding Guideline

Conventions

Key for React Elements

`${componentName}-${itemId}`

For example, a Blog object in url blog will be rendered with the key:

`blog-${blog.id}`

Quality Assurance

User flows

Guest

  • Sign up (join)
  • Sign in
  • See all blogs
  • Read a blog

User

  • All Guest's flows
  • Sign out

Me

  • All User's flows
  • Post a blog

one-more-light's People

Contributors

ngtrthinh169tpc avatar

Watchers

 avatar

one-more-light's Issues

[FEATURE]: Preview for markdowns

Your suggestion

Allow preview when creating or editing things with markdown. Might be able to toggle this on or off.

Context of your idea

Creating and editing blogs doesn't have previews, so I cannot know if the markdown works as intended or not until it's posted. This makes the editing process repetitive.

Do you have a suggestion of how to do this?

eh, you do it

Disclaimer

  • I acknowledge that my idea will be used for this project with my consent

Contact Details

No response

[FEATURE]: Responsive UI

Your suggestion

Responsive to 3 sizes: Phone, tablet & PC

Context of your idea

Not all people use PC

Do you have a suggestion of how to do this?

No response

Disclaimer

  • I acknowledge that my idea will be used for this project with my consent

Contact Details

No response

[FEATURE]: Error handling on Input components

Your suggestion

Input components should show the error it encounters after validation or after posting and getting an error message

Context of your idea

Any forms that have error state (particularly blogs).

Do you have a suggestion of how to do this?

Take a look at signin & join pages

Disclaimer

  • I acknowledge that my idea will be used for this project with my consent

Contact Details

No response

[FEATURE]: Metadata, favicon and SEO

Your suggestion

Metadata system and favicons for every pages, maybe try to SEO-optimizing?

Context of your idea

It looks better and cooler

Do you have a suggestion of how to do this?

No response

Disclaimer

  • I acknowledge that my idea will be used for this project with my consent

Contact Details

No response

[FEATURE]: Authorization and permissions

Your suggestion

Permissions for 3 roles:

  • Guests & users: can view blogs
  • Admin: can do whatever I want

More things will be added later.

Context of your idea

Can't let people ruin my place ๐Ÿ™…

Do you have a suggestion of how to do this?

No response

Disclaimer

  • I acknowledge that my idea will be used for this project with my consent

Contact Details

No response

[FEATURE]: Confirm modals

Your suggestion

Make a modal component that pops up everytimes we need to confirm things.

Context of your idea

Deleting blogs and dangerous actions should have a confirmation.

Do you have a suggestion of how to do this?

nah

Disclaimer

  • I acknowledge that my idea will be used for this project with my consent

Contact Details

No response

[FEATURE]: Blog filter and sort

Your suggestion

Blog should have a filter and a sort function

Context of your idea

Easier to find a particular blog, easier to browse, and easier to flex your skills

Do you have a suggestion of how to do this?

No response

Disclaimer

  • I acknowledge that my idea will be used for this project with my consent

Contact Details

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.