Coder Social home page Coder Social logo

Comments (6)

c0sogi avatar c0sogi commented on May 28, 2024

Do you mean you want to create an independent server that serves only html? If so, Ngnix can be used to serve static files. You can do this by creating a Ngnix container and setting the volume to ./app/web:/static in the volumes section. Of course, this also requires Traefik routing, and since Traefik's Host rule overlaps with the value used by the existing Fastapi server, you can move the hostrules to a different domain, so you can prevent access to FastAPI container.

from llmchat.

Torhamilton avatar Torhamilton commented on May 28, 2024

The plan is to use a single shared instances of mysql, qdrant, redis and if possible fastAPI. then the frontend is independent per domain. I am also investigation simply symlinking the app/ folder. Avoiding duplicated code base for multiple domains on same server. using Nginx and traefik on same deployment can lead to nightmares. Lets take our time on this one. No rush

from llmchat.

c0sogi avatar c0sogi commented on May 28, 2024

So you're saying that if you're running multiple domains, you want to set up the backend instance on a single server, and only assign the frontend to each domain.

I guess you want to replace the existing monolithic architecture with microservices.
Is this correct?

from llmchat.

Torhamilton avatar Torhamilton commented on May 28, 2024

Yes and no. More like make fastAPI a headless backend by decoupling web. Here is a simplified version:
`services:
core:
image: fastapi_core_image
environment:
# Pool configurations for each domain
POOL_1: "mysql+mysqlconnector://user1:password1@db:3306/db1"
POOL_2: "mysql+mysqlconnector://user2:password2@db:3306/db2"
REDIS_1: "redis://:password1@cache:6379/0"
REDIS_2: "redis://:password2@cache:6379/1"
QDRANT_1: "qdrant_collection_1"
QDRANT_2: "qdrant_collection_2"

domain1:
image: flutter_app
environment:
DOMAIN_ID: "1"
BACKEND_URL: "http://core:8000"

domain2:
image: flutter_app
environment:
DOMAIN_ID: "2"
BACKEND_URL: "http://core:8000"
`
This allows customization of frontend. Also it is a lighter architecture, web containers are thin clients.

For more complex systems, FastApi can stored the connection pool in a db instead of environment variables. This may be easier to implement and my preferred option. The db can be prepopulated with 20 connections or so. And a bash script runs the docker-compose instantiation.

Your thought?

from llmchat.

c0sogi avatar c0sogi commented on May 28, 2024

Clients will send API requests to the real domain rather than hitting the BACKEND_URL set to http://core:8000. Because it is the client's browser, not flutter_app, that sends the actual API request. So while it is possible to mediate APIs using internal service names, it seems unlikely that you will be able to completely separate backend and frontend.

from llmchat.

Torhamilton avatar Torhamilton commented on May 28, 2024

Okay for now I will symlink the code base among instances

from llmchat.

Related Issues (20)

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.