cursordocs

When to use?

Streamlit is suitable as a technical choice for the MVP phase, used for rapid system prototyping.

Project structure

This structure is based on industry best practices, taking into account frontend-backend decoupling, scalability, automated testing, CI/CD, and containerized deployment. It is suitable for the MVP phase and future evolution.

Important: System Directory Design and Optimization Principles

  1. Separate frontend and backend to facilitate future frontend architecture replacement (e.g., React/Vue)
  2. Separate configuration from code to support multi-environment switching
  3. Decouple business logic from infrastructure to improve maintainability
  4. Preset directories for testing, CI/CD, documentation, and containerization to support team collaboration and automation
  5. Follow First Principles and Occam’s Razor for a simple and extensible structure

Recommended Project Structure Example

project-root/
├── frontend/                      # Frontend (Streamlit in the first phase, can be switched to React/Vue later)
│   ├── app.py
│   ├── components/
│   ├── pages/
│   └── state.py
│
├── backend/                       # Backend
│   ├── api/                       # API layer (FastAPI, etc.)
│   │   ├── routes/
│   │   └── deps.py
│   ├── agents/                    # Various agents (core business logic)
│   │   ├── base.py
│   │   ├── writer_agent.py
│   │   └── __init__.py
│   ├── prompts/                   # Prompt templates, categorized by agent
│   ├── services/                  # Application service layer (orchestration + permissions + state)
│   │   ├── chat_service.py
│   │   ├── agent_orchestrator.py
│   │   └── file_service.py
│   ├── tools/                     # Tools available to agents (function call wrappers)
│   │   ├── search_tool.py
│   │   ├── calculator.py
│   │   └── __init__.py
│   ├── infrastructure/            # Infrastructure adaptation layer
│   │   ├── db/
│   │   │   ├── models/
│   │   │   ├── crud/
│   │   │   └── session.py
│   │   ├── queue/
│   │   │   ├── producer.py
│   │   │   ├── consumer.py
│   │   │   └── config.py
│   │   └── llm_provider/          # Multi-model adaptation (e.g., OpenAI, Claude, Llama)
│   │       ├── openai.py
│   │       ├── anthropic.py
│   │       └── llama_cpp.py
│   ├── common/                    # Common modules (config, constants, logger, exceptions, helpers, etc.)
│   │   ├── config.py
│   │   ├── constants.py
│   │   ├── logger.py
│   │   ├── exceptions.py
│   │   └── helpers.py
│   └── tests/                     # Test modules
│       ├── test_agents/
│       ├── test_services/
│       ├── test_api/
│       └── conftest.py
│
├── scripts/                       # Ops scripts, DB migration, model fine-tuning scripts, etc.
├── data/                          # Initial samples, knowledge base, uploaded files, etc.
│   ├── raw/
│   ├── processed/
│   └── external/
├── config/                        # Configuration files (split by environment/function)
│   ├── config_dev.py
│   ├── config_prod.py
│   └── ...
├── docs/                          # Design docs, API docs, architecture diagrams, etc.
├── .github/
│   └── workflows/                 # CI/CD pipeline configuration (e.g., GitHub Actions)
├── Dockerfile                     # Containerized deployment
├── docker-compose.yml             # Multi-service orchestration
├── requirements.txt               # Python dependencies
├── .env                           # Environment variables
└── README.md                      # Project documentation

Directory Optimization Notes


Technology Stack Recommendations

Below are some recommended technology stacks for each layer of the project. Choose according to your team expertise, project requirements, and scalability needs.

Frontend

Backend

API Framework

Documentation

Database

ORM/ODM

CI/CD

Containerization

Testing

Note: