

Ask HN: How to design an entirely client-side generated website - fgielow

Hello!<p>I would like to know if it is possible to build a website in a way that it depends only in the javascript running on the client-side, considering the needs specified below.<p>I want to have a server only to serve files, and then the content of the website itself would all be obtained and generated by the client browser, no server-side programming at all. I want to use amazon s3 for hosting the files.<p>Then, I would need to have a "public" database which could be read by anyone without any login, so I could retrieve all my data from there securely through javascript. I do not want a server listening for AJAX requests or anything like that, as I would still need to do some specific server-side programming there. Is there any possibility of using online available databases in a public way, easily and securely retrievable through a client-side javascript request? Something like amazon RDS or MongoHQ would be great, but I do not know if it is possible.<p>I do not know much advanced stuff regarding these topics, I am sorry if this is too obvious or if I did not make much sense.<p>Thanks in advance.
======
fgielow
Thanks for the replies so far!

I will give it a try today later. If I find any nice solutions I will give
feedback.

When I thought of doing this I thought: "Why haven't I seen this before?", as
it seems so feasible, but I never really read many discussions regarding this
topic. Anyways, I do not dive in web programming too much, there may exist
some solutions already.

I see that much of the programming that is done on the server-side could be
done in the client-side with no collateral effects at all, if some cares were
correctly taken!

Going even further, is there a way to securely manipulate remote databases
through javascript? Maybe have a pair of asymmetric keys on the client-
side/server-side (this server-side would be of the third party that offers the
service, not mine) so I can authenticate the user at the server side. The
client would then have to send this key with the operation he wants to perform
in the database. If he has access, the operation is performed. Otherwise, it
isn't.

Again, I do not know much about these topics. Maybe it is already done and I
don't know. If you guys know of something like what I am saying, please let me
know. It seems that it should not be very difficult to achieve these things in
practice.

------
aespinoza
I think you should be able to do it.

You can access S3 using this: <http://code.google.com/p/js3db/>

MongoHQ has a REST API, so calling it from Javascript should be easy. This
document might help you: [http://blog.mongohq.com/blog/2012/02/20/connecting-
to-mongoh...](http://blog.mongohq.com/blog/2012/02/20/connecting-to-mongohq)

~~~
pilom
Mind blown. MongoHQ is what I have been looking for but never knew that was
what they actually did. Thank you!!!

 _thinks of all sorts of 100% client side websites to make_

~~~
aespinoza
Actually this question made me think of the possibilities. There are
frameworks out there that support MVC, which would make a robust client-side
app running only in the browser.

I will be experimenting with this later today.

~~~
fgielow
My mind was blown when I started thinking on the possibilities of entirely
client-side running websites.

If the correct services exist, there are so many things that could be done
better.

------
pilom
I do something similar with whitewatermap.com. The problem with what you are
trying (which I have run into too) is that the javascript can only access
either AJAX calls on your own server (which I know you don't want to do) or
access items via a url. S3 allows you to make things accessible at known URL's
but it costs a lot per PUT request (relatively) so it makes databases
difficult. If you find a cloud/hosted database that makes all entities
accessible via URL I would be very interested too.

Edit: aespinoza pointed me to mongohq.com which does exactly what I wanted.
I'm so happy.

------
dwynings
Maybe this will help: <https://github.com/srhyne/jQuery-Parse>

