Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

How do route platform similar to Ghost blogging engine or Squarespace in Express.js? (routing dynamic subdomains)

Ok, this question is rather massive so ANY insight you may have on this would be greatly appreciated. I will try to break it in to smaller chunks and I don't expect a direct solution (but if you have one I will take it!) but would love to understand how these routes might work, learn new terms so I can research more / know what I am looking for, and all in all take a step towards building out this idea I have had forever.

So... First the goal:

1) Create an application using Express.js and MongoDB that will allow users to sign up and create an account and with that account they will be given a subdomain generated BY them i.e. myportfolio.portfolio.com (they get to choose the 'myportfolio' part). The features they would gain access to would be uploading their images, maybe a small blog engine, and a contact form that they can route to their email and create static HTML pages.

2) The user then gains access to their own dashboard / CMS where they can customize basic templates with HTML, CSS, JS (frontend) to customize their portfolio. Basically have their own mini website with my application powering the backend.

3) Add their own domain to complete their portfolio.

So, my questions and again, I am sorry if this seems like way too much but I am just looking for pointers to maybe some docs, models, build structures etc.

1) By letting users dynamically create their own subdomains, I understand I need to have a 'wildcard' set for my subdomain. My question is, how do I structure the application to allow users to re-use the 'CMS' type system I built while still saving their unique data to their domain / subdomain. I feel like I should create a REST API for some of this but I don't feel like I can use it for all features. I could be wrong.

2) How can I connect the user's dynamic route they created and their content they have created such as their blog posts and images? I again understand wildcard subdomains would be used but I want to use Express.js to connect everything and I don't have a clear idea in mind how I could connect the user consistently to their subdomain. I do have to save a few subdomains such as 'admin.portfolio.com' or 'api.portfolio.com'

3) Modeling, modeling, modeling... in MongoDB. Would the user end up being a bunch of referenced documents for each page they create?

Again, not looking for straight code (although if you did with the dynamic routing that would be amazing) but maybe some pointers to articles, documentation, or just any insights. I want to learn and I am ready to do so, I just don't even know the proper questions to ask at this point it feels.

Thank so much for even reading this post! Hope someone can help me get an idea of where to go!

Best wishes.